Bug 1075055 - Make it impossible to turn on telemetry unless FHR is also turned on. r=jaws
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Thu, 19 Feb 2015 12:06:00 -0800
changeset 229939 460076a2e344166156dccbb013236a0178cb450e
parent 229938 9e4ee18f745a6d21d97985ebe38d81e556ce15c6
child 229940 ac7c99989aa56f04e181ed5fe63b8540cf9cd06f
push id28303
push usercbook@mozilla.com
push dateFri, 20 Feb 2015 14:07:30 +0000
treeherdermozilla-central@80bd1ae9dd0a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1075055
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1075055 - Make it impossible to turn on telemetry unless FHR is also turned on. r=jaws
browser/components/preferences/advanced.js
browser/components/preferences/advanced.xul
browser/components/preferences/in-content/advanced.js
browser/components/preferences/in-content/advanced.xul
toolkit/themes/shared/in-content/common.inc.css
--- a/browser/components/preferences/advanced.js
+++ b/browser/components/preferences/advanced.js
@@ -229,16 +229,34 @@ var gAdvancedPane = {
    */
   initTelemetry: function ()
   {
 #ifdef MOZ_TELEMETRY_REPORTING
     this._setupLearnMoreLink("toolkit.telemetry.infoURL", "telemetryLearnMore");
 #endif
   },
 
+  /**
+   * Set the status of the telemetry controls based on the input argument.
+   * @param {Boolean} aEnabled False disables the controls, true enables them.
+   */
+  setTelemetrySectionEnabled: function (aEnabled)
+  {
+#ifdef 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.
+      document.getElementById("submitTelemetryBox").checked = false;
+    }
+    document.getElementById("telemetryDataDesc").disabled = disabled;
+#endif
+  },
+
 #ifdef MOZ_SERVICES_HEALTHREPORT
   /**
    * Initialize the health report service reference and checkbox.
    */
   initSubmitHealthReport: function () {
     this._setupLearnMoreLink("datareporting.healthreport.infoURL", "FHRLearnMore");
 
     let policy = Components.classes["@mozilla.org/datareporting/service;1"]
@@ -249,16 +267,17 @@ var gAdvancedPane = {
     let checkbox = document.getElementById("submitHealthReportBox");
 
     if (!policy || policy.healthReportUploadLocked) {
       checkbox.setAttribute("disabled", "true");
       return;
     }
 
     checkbox.checked = policy.healthReportUploadEnabled;
+    this.setTelemetrySectionEnabled(checkbox.checked);
   },
 
   /**
    * Update the health report policy acceptance with state from checkbox.
    */
   updateSubmitHealthReport: function () {
     let policy = Components.classes["@mozilla.org/datareporting/service;1"]
                                    .getService(Components.interfaces.nsISupports)
@@ -267,16 +286,17 @@ var gAdvancedPane = {
 
     if (!policy) {
       return;
     }
 
     let checkbox = document.getElementById("submitHealthReportBox");
     policy.recordHealthReportUploadEnabled(checkbox.checked,
                                            "Checkbox from preferences pane");
+    this.setTelemetrySectionEnabled(checkbox.checked);
   },
 #endif
 
   // NETWORK TAB
 
   /*
    * Preferences:
    *
--- a/browser/components/preferences/advanced.xul
+++ b/browser/components/preferences/advanced.xul
@@ -162,61 +162,60 @@
                       onsynctopreference="return gAdvancedPane.writeCheckSpelling();"
                       preference="layout.spellcheckDefault"/>
           </groupbox>
         </tabpanel>
 
 #ifdef MOZ_DATA_REPORTING
         <!-- Data Choices -->
         <tabpanel id="dataChoicesPanel" orient="vertical">
-#ifdef MOZ_TELEMETRY_REPORTING
-          <groupbox>
-            <caption label="&telemetrySection.label;"/>
-            <description>&telemetryDesc.label;</description>
-            <hbox>
-              <checkbox id="submitTelemetryBox"
-                        preference="toolkit.telemetry.enabled"
-                        label="&enableTelemetry.label;"
-                        accesskey="&enableTelemetry.accesskey;"/>
-              <spacer flex="1"/>
-              <label id="telemetryLearnMore"
-                     class="text-link"
-                     value="&telemetryLearnMore.label;"
-                     onclick="gAdvancedPane.openTextLink(event)"/>
-            </hbox>
-          </groupbox>
-#endif
 #ifdef MOZ_SERVICES_HEALTHREPORT
           <groupbox>
-            <caption label="&healthReportSection.label;"/>
-            <description>&healthReportDesc.label;</description>
-            <hbox>
-              <checkbox id="submitHealthReportBox"
+            <caption>
+              <checkbox id="submitHealthReportBox" label="&enableHealthReport.label;"
                         oncommand="gAdvancedPane.updateSubmitHealthReport();"
-                        label="&enableHealthReport.label;"
                         accesskey="&enableHealthReport.accesskey;"/>
-              <spacer flex="1"/>
-              <label id="FHRLearnMore"
-                     class="text-link"
-                     value="&healthReportLearnMore.label;"
-                     onclick="gAdvancedPane.openTextLink(event)"/>
-            </hbox>
+            </caption>
+            <vbox>
+              <hbox class="indent">
+                <label flex="1">&healthReportDesc.label;</label>
+                <spacer flex="10"/>
+                <label id="FHRLearnMore" class="text-link"
+                       value="&healthReportLearnMore.label;"
+                       onclick="gAdvancedPane.openTextLink(event)"/>
+              </hbox>
+#ifdef MOZ_TELEMETRY_REPORTING
+              <hbox class="indent">
+                <vbox flex="1">
+                  <checkbox id="submitTelemetryBox" label="&enableTelemetryData.label;"
+                            preference="toolkit.telemetry.enabled"
+                            accesskey="&enableTelemetryData.accesskey;"/>
+                  <hbox class="indent">
+                    <label id="telemetryDataDesc" flex="1">&telemetryDesc.label;</label>
+                    <spacer flex="10"/>
+                    <label id="telemetryLearnMore" class="text-link"
+                           value="&telemetryLearnMore.label;"
+                           onclick="gAdvancedPane.openTextLink(event)"/>
+                  </hbox>
+                </vbox>
+              </hbox>
+#endif
+            </vbox>
           </groupbox>
 #endif
 #ifdef MOZ_CRASHREPORTER
           <groupbox>
-            <caption label="&crashReporterSection.label;"/>
-            <description>&crashReporterDesc.label;</description>
-            <hbox>
-              <checkbox id="submitCrashesBox"
+            <caption>
+              <checkbox id="submitCrashesBox" label="&enableCrashReporter.label;"
                         oncommand="gAdvancedPane.updateSubmitCrashes();"
-                        label="&enableCrashReporter.label;"
                         accesskey="&enableCrashReporter.accesskey;"/>
-
-              <spacer flex="1"/>
+            </caption>
+            <hbox class="indent">
+              <label flex="1">&crashReporterDesc.label;</label>
+              <spacer flex="10"/>
               <label id="crashReporterLearnMore"
                      class="text-link"
                      value="&crashReporterLearnMore.label;"
                      onclick="gAdvancedPane.openTextLink(event)"/>
             </hbox>
           </groupbox>
 #endif
         </tabpanel>
--- a/browser/components/preferences/in-content/advanced.js
+++ b/browser/components/preferences/in-content/advanced.js
@@ -258,16 +258,34 @@ var gAdvancedPane = {
    */
   initTelemetry: function ()
   {
 #ifdef MOZ_TELEMETRY_REPORTING
     this._setupLearnMoreLink("toolkit.telemetry.infoURL", "telemetryLearnMore");
 #endif
   },
 
+  /**
+   * Set the status of the telemetry controls based on the input argument.
+   * @param {Boolean} aEnabled False disables the controls, true enables them.
+   */
+  setTelemetrySectionEnabled: function (aEnabled)
+  {
+#ifdef 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.
+      document.getElementById("submitTelemetryBox").checked = false;
+    }
+    document.getElementById("telemetryDataDesc").disabled = disabled;
+#endif
+  },
+
 #ifdef MOZ_SERVICES_HEALTHREPORT
   /**
    * Initialize the health report service reference and checkbox.
    */
   initSubmitHealthReport: function () {
     this._setupLearnMoreLink("datareporting.healthreport.infoURL", "FHRLearnMore");
 
     let policy = Components.classes["@mozilla.org/datareporting/service;1"]
@@ -278,16 +296,17 @@ var gAdvancedPane = {
     let checkbox = document.getElementById("submitHealthReportBox");
 
     if (!policy || policy.healthReportUploadLocked) {
       checkbox.setAttribute("disabled", "true");
       return;
     }
 
     checkbox.checked = policy.healthReportUploadEnabled;
+    this.setTelemetrySectionEnabled(checkbox.checked);
   },
 
   /**
    * Update the health report policy acceptance with state from checkbox.
    */
   updateSubmitHealthReport: function () {
     let policy = Components.classes["@mozilla.org/datareporting/service;1"]
                                    .getService(Components.interfaces.nsISupports)
@@ -296,16 +315,17 @@ var gAdvancedPane = {
 
     if (!policy) {
       return;
     }
 
     let checkbox = document.getElementById("submitHealthReportBox");
     policy.recordHealthReportUploadEnabled(checkbox.checked,
                                            "Checkbox from preferences pane");
+    this.setTelemetrySectionEnabled(checkbox.checked);
   },
 #endif
 
   // NETWORK TAB
 
   /*
    * Preferences:
    *
--- a/browser/components/preferences/in-content/advanced.xul
+++ b/browser/components/preferences/in-content/advanced.xul
@@ -187,55 +187,58 @@
                   onsyncfrompreference="return gAdvancedPane.readCheckSpelling();"
                   onsynctopreference="return gAdvancedPane.writeCheckSpelling();"
                   preference="layout.spellcheckDefault"/>
       </groupbox>
     </tabpanel>
 #ifdef MOZ_DATA_REPORTING
     <!-- Data Choices -->
     <tabpanel id="dataChoicesPanel" orient="vertical">
-#ifdef MOZ_TELEMETRY_REPORTING
-      <groupbox>
-        <caption><label>&telemetrySection.label;</label></caption>
-        <description>&telemetryDesc.label;</description>
-        <hbox>
-          <checkbox id="submitTelemetryBox"
-                    preference="toolkit.telemetry.enabled"
-                    label="&enableTelemetry.label;"
-                    accesskey="&enableTelemetry.accesskey;"/>
-          <spacer flex="1"/>
-          <label id="telemetryLearnMore"
-                 class="text-link">&telemetryLearnMore.label;</label>
-        </hbox>
-      </groupbox>
-#endif
 #ifdef MOZ_SERVICES_HEALTHREPORT
       <groupbox>
-        <caption><label>&healthReportSection.label;</label></caption>
-        <description>&healthReportDesc.label;</description>
-        <hbox>
-          <checkbox id="submitHealthReportBox"
-                    label="&enableHealthReport.label;"
+        <caption>
+          <checkbox id="submitHealthReportBox" label="&enableHealthReport.label;"
                     accesskey="&enableHealthReport.accesskey;"/>
-          <spacer flex="1"/>
-          <label id="FHRLearnMore"
-                 class="text-link">&healthReportLearnMore.label;</label>
-        </hbox>
+        </caption>
+        <vbox>
+          <hbox class="indent">
+            <label flex="1">&healthReportDesc.label;</label>
+            <spacer flex="10"/>
+            <label id="FHRLearnMore"
+                   class="text-link">&healthReportLearnMore.label;</label>
+          </hbox>
+#ifdef MOZ_TELEMETRY_REPORTING
+          <hbox class="indent">
+            <groupbox flex="1">
+              <caption>
+                <checkbox id="submitTelemetryBox" preference="toolkit.telemetry.enabled"
+                          label="&enableTelemetryData.label;"
+                          accesskey="&enableTelemetryData.accesskey;"/>
+              </caption>
+              <hbox class="indent">
+                <label id="telemetryDataDesc" flex="1">&telemetryDesc.label;</label>
+                <spacer flex="10"/>
+                <label id="telemetryLearnMore"
+                       class="text-link">&telemetryLearnMore.label;</label>
+              </hbox>
+            </groupbox>
+          </hbox>
+#endif
+        </vbox>
       </groupbox>
 #endif
 #ifdef MOZ_CRASHREPORTER
       <groupbox>
-        <caption><label>&crashReporterSection.label;</label></caption>
-        <description>&crashReporterDesc.label;</description>
-        <hbox>
-          <checkbox id="submitCrashesBox"
-                    label="&enableCrashReporter.label;"
+        <caption>
+          <checkbox id="submitCrashesBox" label="&enableCrashReporter.label;"
                     accesskey="&enableCrashReporter.accesskey;"/>
-
-          <spacer flex="1"/>
+        </caption>
+        <hbox class="indent">
+          <label flex="1">&crashReporterDesc.label;</label>
+          <spacer flex="10"/>
           <label id="crashReporterLearnMore"
                  class="text-link">&crashReporterLearnMore.label;</label>
         </hbox>
       </groupbox>
 #endif
     </tabpanel>
 #endif
 
--- a/toolkit/themes/shared/in-content/common.inc.css
+++ b/toolkit/themes/shared/in-content/common.inc.css
@@ -35,16 +35,17 @@ html|hr {
   border-color: #c1c1c1;
 }
 
 xul|caption {
   -moz-appearance: none;
   margin: 0;
 }
 
+xul|caption > xul|checkbox,
 xul|caption > xul|label {
   font-size: 1.3rem;
   font-weight: bold;
   line-height: 22px;
   margin: 0 !important;
 }
 
 xul|description {