Bug 1355522 - Move Telemetry and Health Report prefs to Privacy & Security section. r?florian draft
authorJared Wein <jwein@mozilla.com>
Wed, 12 Apr 2017 10:14:51 -0400
changeset 562933 e3ce8a0f87c61ab3f32c9c6952c23f1a01d984ee
parent 562653 f77f3057b8ee04f1a7546e9cd69066d201e9a221
child 562934 2d2dde2334c710736f019294fa26b50d5bca05e8
push id54171
push userbmo:jaws@mozilla.com
push dateFri, 14 Apr 2017 19:28:43 +0000
reviewersflorian
bugs1355522
milestone55.0a1
Bug 1355522 - Move Telemetry and Health Report prefs to Privacy & Security section. r?florian MozReview-Commit-ID: 1Ybpr68SKC0
browser/base/content/browser-data-submission-info-bar.js
browser/components/preferences/in-content/advanced.js
browser/components/preferences/in-content/advanced.xul
browser/components/preferences/in-content/privacy.js
browser/components/preferences/in-content/privacy.xul
browser/components/preferences/in-content/tests/browser_bug1020245_openPreferences_to_paneContent.js
--- a/browser/base/content/browser-data-submission-info-bar.js
+++ b/browser/base/content/browser-data-submission-info-bar.js
@@ -66,17 +66,17 @@ var gDataNotificationInfoBar = {
       popup: null,
       callback: () => {
         this._actionTaken = true;
         // The advanced subpanes are only supported in the old organization, which will
         // be removed by bug 1349689.
         if (Preferences.get("browser.preferences.useOldOrganization", false)) {
           window.openAdvancedPreferences("dataChoicesTab");
         } else {
-          window.openPreferences("advanced-reports");
+          window.openPreferences("privacy-reports");
         }
       },
     }];
 
     this._log.info("Creating data reporting policy notification.");
     this._notificationBox.appendNotification(
       message,
       this._DATA_REPORTING_NOTIFICATION,
--- a/browser/components/preferences/in-content/advanced.js
+++ b/browser/components/preferences/in-content/advanced.js
@@ -4,18 +4,16 @@
 
 /* import-globals-from preferences.js */
 
 // Load DownloadUtils module for convertByteUnits
 Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
 Components.utils.import("resource://gre/modules/LoadContextInfo.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
-
 var gAdvancedPane = {
   _inited: false,
 
   /**
    * Brings the appropriate tab to the front and initializes various bits of UI.
    */
   init() {
     function setEventListener(aId, aEventType, aCallback) {
@@ -28,39 +26,25 @@ var gAdvancedPane = {
     if (AppConstants.MOZ_UPDATER) {
       let onUnload = function() {
         window.removeEventListener("unload", onUnload);
         Services.prefs.removeObserver("app.update.", this);
       }.bind(this);
       window.addEventListener("unload", onUnload);
       Services.prefs.addObserver("app.update.", this, false);
       this.updateReadPrefs();
-    }
-    if (AppConstants.MOZ_CRASHREPORTER) {
-      this.initSubmitCrashes();
-    }
-    this.initTelemetry();
-    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
-      this.initSubmitHealthReport();
+      setEventListener("updateRadioGroup", "command",
+                       gAdvancedPane.updateWritePrefs);
+      setEventListener("showUpdateHistory", "command",
+                       gAdvancedPane.showUpdates);
     }
     this.updateOnScreenKeyboardVisibility();
 
     setEventListener("layers.acceleration.disabled", "change",
                      gAdvancedPane.updateHardwareAcceleration);
-    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
-      setEventListener("submitHealthReportBox", "command",
-                       gAdvancedPane.updateSubmitHealthReport);
-    }
-
-    if (AppConstants.MOZ_UPDATER) {
-      setEventListener("updateRadioGroup", "command",
-                       gAdvancedPane.updateWritePrefs);
-      setEventListener("showUpdateHistory", "command",
-                       gAdvancedPane.showUpdates);
-    }
   },
 
 
   // GENERAL TAB
 
   /*
    * Preferences:
    *
@@ -133,99 +117,16 @@ var gAdvancedPane = {
   updateHardwareAcceleration() {
     if (AppConstants.platform == "win") {
       var fromPref = document.getElementById("layers.acceleration.disabled");
       var toPref = document.getElementById("gfx.direct2d.disabled");
       toPref.value = fromPref.value;
     }
   },
 
-  // DATA CHOICES TAB
-
-  /**
-   * Set up or hide the Learn More links for various data collection options
-   */
-  _setupLearnMoreLink(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");
-    }
-  },
-
-  /**
-   *
-   */
-  initSubmitCrashes() {
-    this._setupLearnMoreLink("toolkit.crashreporter.infoURL",
-                             "crashReporterLearnMore");
-  },
-
-  /**
-   * The preference/checkbox is configured in XUL.
-   *
-   * In all cases, set up the Learn More link sanely.
-   */
-  initTelemetry() {
-    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
-      this._setupLearnMoreLink("toolkit.telemetry.infoURL", "telemetryLearnMore");
-    }
-  },
-
-  /**
-   * Set the status of the telemetry controls based on the input argument.
-   * @param {Boolean} aEnabled False disables the controls, true enables them.
-   */
-  setTelemetrySectionEnabled(aEnabled) {
-    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
-      // If FHR is disabled, additional data sharing should be disabled as well.
-      let disabled = !aEnabled;
-      document.getElementById("submitTelemetryBox").disabled = disabled;
-      if (disabled) {
-        // If we disable FHR, untick the telemetry checkbox.
-        Services.prefs.setBoolPref("toolkit.telemetry.enabled", false);
-      }
-      document.getElementById("telemetryDataDesc").disabled = disabled;
-    }
-  },
-
-  /**
-   * Initialize the health report service reference and checkbox.
-   */
-  initSubmitHealthReport() {
-    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
-      this._setupLearnMoreLink("datareporting.healthreport.infoURL", "FHRLearnMore");
-
-      let checkbox = document.getElementById("submitHealthReportBox");
-
-      if (Services.prefs.prefIsLocked(PREF_UPLOAD_ENABLED)) {
-        checkbox.setAttribute("disabled", "true");
-        return;
-      }
-
-      checkbox.checked = Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED);
-      this.setTelemetrySectionEnabled(checkbox.checked);
-    }
-  },
-
-  /**
-   * Update the health report preference with state from checkbox.
-   */
-  updateSubmitHealthReport() {
-    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
-      let checkbox = document.getElementById("submitHealthReportBox");
-      Services.prefs.setBoolPref(PREF_UPLOAD_ENABLED, checkbox.checked);
-      this.setTelemetrySectionEnabled(checkbox.checked);
-    }
-  },
-
   updateOnScreenKeyboardVisibility() {
     if (AppConstants.platform == "win") {
       let minVersion = Services.prefs.getBoolPref("ui.osk.require_win10") ? 10 : 6.2;
       if (Services.vc.compare(Services.sysinfo.getProperty("version"), minVersion) >= 0) {
         document.getElementById("useOnScreenKeyboard").hidden = false;
       }
     }
   },
--- a/browser/components/preferences/in-content/advanced.xul
+++ b/browser/components/preferences/in-content/advanced.xul
@@ -7,23 +7,16 @@
 <script type="application/javascript"
         src="chrome://browser/content/preferences/in-content/advanced.js"/>
 
 <preferences id="advancedPreferences" hidden="true" data-category="paneAdvanced">
   <preference id="browser.preferences.advanced.selectedTabIndex"
               name="browser.preferences.advanced.selectedTabIndex"
               type="int"/>
 
-<!-- Data Choices tab -->
-#ifdef MOZ_CRASHREPORTER
-  <preference id="browser.crashReports.unsubmittedCheck.autoSubmit"
-              name="browser.crashReports.unsubmittedCheck.autoSubmit"
-              type="bool"/>
-#endif
-
 <!-- Update tab -->
 #ifdef MOZ_UPDATER
   <preference id="app.update.enabled"
               name="app.update.enabled"
               type="bool"/>
   <preference id="app.update.auto"
               name="app.update.auto"
               type="bool"/>
@@ -91,59 +84,8 @@
 #endif
 <groupbox id="updateOthers" align="start" data-category="paneAdvanced" hidden="true">
   <caption><label>&autoUpdateOthers.label;</label></caption>
   <checkbox id="enableSearchUpdate"
             label="&enableSearchUpdate.label;"
             accesskey="&enableSearchUpdate.accesskey;"
             preference="browser.search.update"/>
 </groupbox>
-
-<!-- Data Choices -->
-#ifdef MOZ_TELEMETRY_REPORTING
-<groupbox id="historyGroup" data-category="paneAdvanced" data-subcategory="reports" hidden="true">
-<caption><label>&reports.label;</label></caption>
-  <vbox>
-    <caption>
-    <checkbox id="submitHealthReportBox" label="&enableHealthReport.label;"
-              accesskey="&enableHealthReport.accesskey;"/>
-  </caption>
-    <hbox class="indent" flex="1">
-      <label flex="1">&healthReportDesc.label;</label>
-      <label id="FHRLearnMore" flex="1"
-             class="learnMore text-link">&healthReportLearnMore.label;</label>
-    </hbox>
-    <hbox class="indent">
-      <groupbox flex="1">
-        <caption>
-          <checkbox id="submitTelemetryBox" preference="toolkit.telemetry.enabled"
-                    label="&enableTelemetryData.label;"
-                    accesskey="&enableTelemetryData.accesskey;"/>
-        </caption>
-        <hbox class="indent" flex="1">
-          <label id="telemetryDataDesc" flex="1">&telemetryDesc.label;</label>
-          <label id="telemetryLearnMore" flex="1"
-                 class="learnMore text-link">&telemetryLearnMore.label;</label>
-        </hbox>
-      </groupbox>
-    </hbox>
-  </vbox>
-</groupbox>
-#endif
-
-#ifdef MOZ_DATA_REPORTING
-#ifdef MOZ_CRASHREPORTER
-<groupbox data-category="paneAdvanced" data-subcategory="reports" hidden="true">
-  <caption>
-    <checkbox id="automaticallySubmitCrashesBox"
-              preference="browser.crashReports.unsubmittedCheck.autoSubmit"
-              label="&alwaysSubmitCrashReports.label;"
-              accesskey="&alwaysSubmitCrashReports.accesskey;"/>
-  </caption>
-  <hbox class="indent" flex="1">
-    <label flex="1">&crashReporterDesc2.label;</label>
-    <label id="crashReporterLearnMore" flex="1"
-           class="learnMore text-link">&crashReporterLearnMore.label;</label>
-  </hbox>
-</groupbox>
-
-#endif
-#endif
\ No newline at end of file
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -13,16 +13,18 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/PluralForm.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "LoginHelper",
                                   "resource://gre/modules/LoginHelper.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "SiteDataManager",
                                   "resource:///modules/SiteDataManager.jsm");
 
 Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
 
+const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
+
 XPCOMUtils.defineLazyGetter(this, "AlertsServiceDND", function() {
   try {
     let alertsService = Cc["@mozilla.org/alerts-service;1"]
                           .getService(Ci.nsIAlertsService)
                           .QueryInterface(Ci.nsIAlertsDoNotDisturb);
     // This will throw if manualDoNotDisturb isn't implemented.
     alertsService.manualDoNotDisturb;
     return alertsService;
@@ -281,36 +283,43 @@ var gPrivacyPane = {
                        gPrivacyPane.showSiteDataSettings);
       let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "storage-permissions";
       document.getElementById("siteDataLearnMoreLink").setAttribute("href", url);
       let siteDataGroup = document.getElementById("siteDataGroup");
       siteDataGroup.hidden = false;
       siteDataGroup.removeAttribute("data-hidden-from-search");
     }
 
-
     let notificationInfoURL =
       Services.urlFormatter.formatURLPref("app.support.baseURL") + "push";
     document.getElementById("notificationsPolicyLearnMore").setAttribute("href",
                                                                          notificationInfoURL);
-
     let drmInfoURL =
       Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content";
     document.getElementById("playDRMContentLink").setAttribute("href", drmInfoURL);
     let emeUIEnabled = Services.prefs.getBoolPref("browser.eme.ui.enabled");
     // Force-disable/hide on WinXP:
     if (navigator.platform.toLowerCase().startsWith("win")) {
       emeUIEnabled = emeUIEnabled && parseFloat(Services.sysinfo.get("version")) >= 6;
     }
     if (!emeUIEnabled) {
       // Don't want to rely on .hidden for the toplevel groupbox because
       // of the pane hiding/showing code potentially interfering:
       document.getElementById("drmGroup").setAttribute("style", "display: none !important");
     }
 
+    if (AppConstants.MOZ_CRASHREPORTER) {
+      this.initSubmitCrashes();
+    }
+    this.initTelemetry();
+    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
+      this.initSubmitHealthReport();
+      setEventListener("submitHealthReportBox", "command",
+                       gPrivacyPane.updateSubmitHealthReport);
+    }
   },
 
   // TRACKING PROTECTION MODE
 
   /**
    * Selects the right item of the Tracking Protection radiogroup.
    */
   trackingProtectionReadPrefs() {
@@ -1290,16 +1299,97 @@ var gPrivacyPane = {
 
     let result = Services.prompt.confirmEx(
       window, title, text, flags, btn0Label, null, null, null, {});
     if (result == 0) {
       SiteDataManager.removeAll();
     }
   },
 
+  initSubmitCrashes() {
+    this._setupLearnMoreLink("toolkit.crashreporter.infoURL",
+                             "crashReporterLearnMore");
+  },
+
+  /**
+   * The preference/checkbox is configured in XUL.
+   *
+   * In all cases, set up the Learn More link sanely.
+   */
+  initTelemetry() {
+    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
+      this._setupLearnMoreLink("toolkit.telemetry.infoURL", "telemetryLearnMore");
+    }
+  },
+
+  /**
+   * Set up or hide the Learn More links for various data collection options
+   */
+  _setupLearnMoreLink(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");
+    }
+  },
+
+  /**
+   * Set the status of the telemetry controls based on the input argument.
+   * @param {Boolean} aEnabled False disables the controls, true enables them.
+   */
+  setTelemetrySectionEnabled(aEnabled) {
+    if (!AppConstants.MOZ_TELEMETRY_REPORTING) {
+      return;
+    }
+    // If FHR is disabled, additional data sharing should be disabled as well.
+    let disabled = !aEnabled;
+    document.getElementById("submitTelemetryBox").disabled = disabled;
+    if (disabled) {
+      // If we disable FHR, untick the telemetry checkbox.
+      Services.prefs.setBoolPref("toolkit.telemetry.enabled", false);
+    }
+    document.getElementById("telemetryDataDesc").disabled = disabled;
+  },
+
+  /**
+   * Initialize the health report service reference and checkbox.
+   */
+  initSubmitHealthReport() {
+    if (!AppConstants.MOZ_TELEMETRY_REPORTING) {
+      return;
+    }
+    this._setupLearnMoreLink("datareporting.healthreport.infoURL", "FHRLearnMore");
+
+    let checkbox = document.getElementById("submitHealthReportBox");
+
+    if (Services.prefs.prefIsLocked(PREF_UPLOAD_ENABLED)) {
+      checkbox.setAttribute("disabled", "true");
+      return;
+    }
+
+    checkbox.checked = Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED);
+    this.setTelemetrySectionEnabled(checkbox.checked);
+  },
+
+  /**
+   * Update the health report preference with state from checkbox.
+   */
+  updateSubmitHealthReport() {
+    if (!AppConstants.MOZ_TELEMETRY_REPORTING) {
+      return;
+    }
+    let checkbox = document.getElementById("submitHealthReportBox");
+    Services.prefs.setBoolPref(PREF_UPLOAD_ENABLED, checkbox.checked);
+    this.setTelemetrySectionEnabled(checkbox.checked);
+  },
+
   // Methods for Offline Apps (AppCache)
 
   /**
    * Clears the application cache.
    */
   clearOfflineAppCache() {
     Components.utils.import("resource:///modules/offlineAppCache.jsm");
     OfflineAppCacheHelper.clear();
--- a/browser/components/preferences/in-content/privacy.xul
+++ b/browser/components/preferences/in-content/privacy.xul
@@ -136,29 +136,36 @@
 
   <preference id="browser.safebrowsing.downloads.remote.block_potentially_unwanted"
               name="browser.safebrowsing.downloads.remote.block_potentially_unwanted"
               type="bool"/>
   <preference id="browser.safebrowsing.downloads.remote.block_uncommon"
               name="browser.safebrowsing.downloads.remote.block_uncommon"
               type="bool"/>
 
-   <!-- Network tab -->
+  <!-- Network tab -->
   <preference id="browser.cache.disk.capacity"
               name="browser.cache.disk.capacity"
               type="int"/>
   <preference id="browser.offline-apps.notify"
               name="browser.offline-apps.notify"
               type="bool"/>
 
   <preference id="browser.cache.disk.smart_size.enabled"
               name="browser.cache.disk.smart_size.enabled"
               inverted="true"
               type="bool"/>
 
+  <!-- Data Choices tab -->
+#ifdef MOZ_CRASHREPORTER
+  <preference id="browser.crashReports.unsubmittedCheck.autoSubmit"
+              name="browser.crashReports.unsubmittedCheck.autoSubmit"
+              type="bool"/>
+#endif
+
 </preferences>
 
 <stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences/preferences.properties"/>
 
 <hbox id="header-privacy"
       class="header"
       hidden="true"
       data-category="panePrivacy">
@@ -669,8 +676,59 @@
             label="&clearSiteData.label;" accesskey="&clearSiteData.accesskey;"/>
   </hbox>
   <vbox align="end">
     <button id="siteDataSettings"
             label="&siteDataSettings.label;"
             accesskey="&siteDataSettings.accesskey;"/>
   </vbox>
 </groupbox>
+
+<!-- Data Choices -->
+#ifdef MOZ_TELEMETRY_REPORTING
+<groupbox id="historyGroup" data-category="panePrivacy" data-subcategory="reports" hidden="true">
+<caption><label>&reports.label;</label></caption>
+  <vbox>
+    <caption>
+    <checkbox id="submitHealthReportBox" label="&enableHealthReport.label;"
+              accesskey="&enableHealthReport.accesskey;"/>
+  </caption>
+    <hbox class="indent" flex="1">
+      <label flex="1">&healthReportDesc.label;</label>
+      <label id="FHRLearnMore" flex="1"
+             class="learnMore text-link">&healthReportLearnMore.label;</label>
+    </hbox>
+    <hbox class="indent">
+      <groupbox flex="1">
+        <caption>
+          <checkbox id="submitTelemetryBox" preference="toolkit.telemetry.enabled"
+                    label="&enableTelemetryData.label;"
+                    accesskey="&enableTelemetryData.accesskey;"/>
+        </caption>
+        <hbox class="indent" flex="1">
+          <label id="telemetryDataDesc" flex="1">&telemetryDesc.label;</label>
+          <label id="telemetryLearnMore" flex="1"
+                 class="learnMore text-link">&telemetryLearnMore.label;</label>
+        </hbox>
+      </groupbox>
+    </hbox>
+  </vbox>
+</groupbox>
+#endif
+
+#ifdef MOZ_DATA_REPORTING
+#ifdef MOZ_CRASHREPORTER
+<groupbox data-category="panePrivacy" data-subcategory="reports" hidden="true">
+  <caption>
+    <checkbox id="automaticallySubmitCrashesBox"
+              preference="browser.crashReports.unsubmittedCheck.autoSubmit"
+              label="&alwaysSubmitCrashReports.label;"
+              accesskey="&alwaysSubmitCrashReports.accesskey;"/>
+  </caption>
+  <hbox class="indent" flex="1">
+    <label flex="1">&crashReporterDesc2.label;</label>
+    <label id="crashReporterLearnMore" flex="1"
+           class="learnMore text-link">&crashReporterLearnMore.label;</label>
+  </hbox>
+</groupbox>
+
+#endif
+#endif
--- a/browser/components/preferences/in-content/tests/browser_bug1020245_openPreferences_to_paneContent.js
+++ b/browser/components/preferences/in-content/tests/browser_bug1020245_openPreferences_to_paneContent.js
@@ -15,22 +15,22 @@ add_task(function*() {
   prefs = yield openPreferencesViaHash("privacy");
   is(prefs.selectedPane, "panePrivacy", "Privacy pane is selected when hash is 'privacy'");
   prefs = yield openPreferencesViaOpenPreferencesAPI("nonexistant-category");
   is(prefs.selectedPane, "paneGeneral", "General pane is selected by default when a nonexistant-category is requested");
   prefs = yield openPreferencesViaHash("nonexistant-category");
   is(prefs.selectedPane, "paneGeneral", "General pane is selected when hash is a nonexistant-category");
   prefs = yield openPreferencesViaHash();
   is(prefs.selectedPane, "paneGeneral", "General pane is selected by default");
-  prefs = yield openPreferencesViaOpenPreferencesAPI("advanced-reports", {leaveOpen: true});
-  is(prefs.selectedPane, "paneAdvanced", "Advanced pane is selected by default");
+  prefs = yield openPreferencesViaOpenPreferencesAPI("privacy-reports", {leaveOpen: true});
+  is(prefs.selectedPane, "panePrivacy", "Privacy pane is selected by default");
   let doc = gBrowser.contentDocument;
-  is(doc.location.hash, "#advanced", "The subcategory should be removed from the URI");
-  ok(doc.querySelector("#updateOthers").hidden, "Search Updates should be hidden when only Reports are requested");
-  ok(!doc.querySelector("#header-advanced").hidden, "The header should be visible when a subcategory is requested");
+  is(doc.location.hash, "#privacy", "The subcategory should be removed from the URI");
+  ok(doc.querySelector("#locationBarGroup").hidden, "Location Bar prefs should be hidden when only Reports are requested");
+  ok(!doc.querySelector("#header-privacy").hidden, "The header should be visible when a subcategory is requested");
   yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
   prefs = yield openPreferencesViaOpenPreferencesAPI("general-search", {leaveOpen: true});
   is(prefs.selectedPane, "paneGeneral", "General pane is selected by default");
   doc = gBrowser.contentDocument;
   is(doc.location.hash, "#general", "The subcategory should be removed from the URI");
   ok(doc.querySelector("#startupGroup").hidden, "Startup should be hidden when only Search is requested");
   ok(!doc.querySelector("#engineList").hidden, "The search engine list should be visible when Search is requested");
   yield BrowserTestUtils.removeTab(gBrowser.selectedTab);