From 1a730fab1d31fca02f9013d3d5d257afc46bf767 Mon Sep 17 00:00:00 2001 From: Mike Connor Date: Thu, 3 Jan 2013 23:45:15 -0500 Subject: [PATCH] bug 809094 - update pref pane to support Firefox Health Report, r=gavin,gps --HG-- extra : rebase_source : 39ac9f3f0f107de91b17c136d6f06fe475858578 --- browser/app/profile/firefox.js | 4 + browser/components/preferences/advanced.js | 97 ++++++++++++++--- browser/components/preferences/advanced.xul | 100 ++++++++++++++---- .../preferences/in-content/advanced.js | 99 ++++++++++++++--- .../preferences/in-content/advanced.xul | 80 +++++++++++--- .../chrome/browser/preferences/advanced.dtd | 24 ++++- services/healthreport/healthreport-prefs.js | 2 +- 7 files changed, 340 insertions(+), 66 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index e2954eeb440..2606af4a99f 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -857,6 +857,10 @@ pref("breakpad.reportURL", "http://crash-stats.mozilla.com/report/index/"); pref("toolkit.crashreporter.pluginHangSubmitURL", "https://hang-reports.mozilla.org/submit"); +// URL for "Learn More" for Crash Reporter +pref("toolkit.crashreporter.infoURL", + "http://www.mozilla.com/legal/privacy/firefox.html#crash-reporter"); + // base URL for web-based support pages pref("app.support.baseURL", "http://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/"); diff --git a/browser/components/preferences/advanced.js b/browser/components/preferences/advanced.js index 01600da210d..7f884e1dd90 100644 --- a/browser/components/preferences/advanced.js +++ b/browser/components/preferences/advanced.js @@ -48,9 +48,11 @@ var gAdvancedPane = { #ifdef MOZ_CRASHREPORTER this.initSubmitCrashes(); #endif -#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT this.initTelemetry(); +#ifdef MOZ_SERVICES_HEALTHREPORT + this.initSubmitHealthReport(); #endif + this.updateActualCacheSize("disk"); this.updateActualCacheSize("offline"); @@ -129,6 +131,34 @@ var gAdvancedPane = { return checkbox.checked ? (this._storedSpellCheck == 2 ? 2 : 1) : 0; }, + /** + * When the user toggles the layers.acceleration.disabled pref, + * sync its new value to the gfx.direct2d.disabled pref too. + */ + updateHardwareAcceleration: function() + { +#ifdef XP_WIN + var fromPref = document.getElementById("layers.acceleration.disabled"); + var toPref = document.getElementById("gfx.direct2d.disabled"); + toPref.value = fromPref.value; +#endif + }, + + // DATA CHOICES TAB + + /** + * Set up or hide the Learn More links for various data collection options + */ + _setupLearnMoreLink: function(pref, element) { + // set up the Learn More link with the correct URL + let url = Services.prefs.getCharPref(pref); + let el = document.getElementById(element); + if (url) + el.setAttribute("href", url); + else + el.setAttribute("hidden", "true"); + }, + /** * */ @@ -142,6 +172,7 @@ var gAdvancedPane = { } catch (e) { checkbox.style.display = "none"; } + this._setupLearnMoreLink("toolkit.crashreporter.infoURL", "crashReporterLearnMore"); }, /** @@ -157,16 +188,19 @@ var gAdvancedPane = { } catch (e) { } }, -#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT + /** * When telemetry is opt-out, verify if the user explicitly rejected the * telemetry prompt, and if so reflect his choice in the current preference * value. This doesn't cover the case where the user refused telemetry in the * prompt but later enabled it in preferences in builds before the fix for * bug 737600. + * + * In all cases, set up the Learn More link sanely */ initTelemetry: function () { +#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabledPreRelease"; let enabled = Services.prefs.getBoolPref(PREF_TELEMETRY_ENABLED); let rejected = false; @@ -176,8 +210,9 @@ var gAdvancedPane = { if (enabled && rejected) { Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, false); } - }, #endif + this._setupLearnMoreLink("toolkit.telemetry.infoURL", "telemetryLearnMore"); + }, /** * When the user toggles telemetry, update the rejected value as well, so we @@ -191,19 +226,57 @@ var gAdvancedPane = { displayed.value = @MOZ_TELEMETRY_DISPLAY_REV@; }, +#ifdef MOZ_SERVICES_HEALTHREPORT /** - * When the user toggles the layers.acceleration.disabled pref, - * sync its new value to the gfx.direct2d.disabled pref too. + * Initialize the health report service reference and checkbox. */ - updateHardwareAcceleration: function() - { -#ifdef XP_WIN - var fromPref = document.getElementById("layers.acceleration.disabled"); - var toPref = document.getElementById("gfx.direct2d.disabled"); - toPref.value = fromPref.value; -#endif + initSubmitHealthReport: function () { + this._setupLearnMoreLink("healthreport.infoURL", "FHRLearnMore"); + + let reporter = Components.classes["@mozilla.org/healthreport/service;1"] + .getService(Components.interfaces.nsISupports) + .wrappedJSObject + .reporter; + + let checkbox = document.getElementById("submitHealthReportBox"); + + if (!reporter) { + checkbox.setAttribute("disabled", "true"); + return; + } + + checkbox.checked = reporter.dataSubmissionPolicyAccepted; }, + /** + * Update the health report policy acceptance with state from checkbox. + */ + updateSubmitHealthReport: function () { + let reporter = Components.classes["@mozilla.org/healthreport/service;1"] + .getService(Components.interfaces.nsISupports) + .wrappedJSObject + .reporter; + + if (!reporter) { + return; + } + + let checkbox = document.getElementById("submitHealthReportBox"); + + let accepted = reporter.dataSubmissionPolicyAccepted; + + if (checkbox.checked && !accepted) { + reporter.recordPolicyAcceptance("pref-checkbox-checked"); + return; + } + + if (!checkbox.checked && accepted) { + reporter.recordPolicyRejection("pref-checkbox-unchecked"); + return; + } + }, +#endif + // NETWORK TAB /* diff --git a/browser/components/preferences/advanced.xul b/browser/components/preferences/advanced.xul index a53d2cd86b9..bf00de5a913 100644 --- a/browser/components/preferences/advanced.xul +++ b/browser/components/preferences/advanced.xul @@ -50,6 +50,8 @@ type="bool"/> #endif + + #ifdef MOZ_TELEMETRY_REPORTING - + - + #ifdef MOZ_UPDATER @@ -115,7 +117,7 @@ name="security.disable_button.openDeviceManager" type="bool"/> - + #ifdef HAVE_SHELL_SERVICE @@ -128,6 +130,7 @@ + @@ -180,11 +183,11 @@ preference="layout.spellcheckDefault"/> +#ifdef HAVE_SHELL_SERVICE -#ifdef HAVE_SHELL_SERVICE @@ -197,20 +200,71 @@ &isDefault.label; -#ifdef MOZ_CRASHREPORTER - -#endif -#endif -#ifdef MOZ_TELEMETRY_REPORTING - -#endif +#endif +#ifndef MOZ_TELEMETRY_REPORTING +#ifndef MOZ_SERVICES_HEALTHREPORT +#ifndef MOZ_CRASHREPORTER +#define HIDE_DATACHOICES +#endif +#endif +#endif +#ifndef HIDE_DATACHOICES + + +#ifdef MOZ_TELEMETRY_REPORTING + + + &telemetryDesc.label; + + + + + +#endif +#ifdef MOZ_SERVICES_HEALTHREPORT + + + &FHRDesc.label; + + + + + +#endif +#ifdef MOZ_CRASHREPORTER + + + &crashReporterDesc.label; + + + + + + +#endif + +#endif @@ -239,11 +293,11 @@ @@ -389,9 +443,9 @@ - - @@ -402,15 +456,15 @@ #endif