Bug 947078 - Make the "Include URLs" option for the crash reporter into a checkbox instead of a toggle.r=mbrubeck a=metro-only
authorAllison Naaktgeboren <ally@mozilla.com>
Wed, 15 Jan 2014 11:32:22 -0800
changeset 175939 486101f1073a8920135d9b03881b88e07a2ef3e1
parent 175938 a673eac28120315af742d9701eb7d66bce65b94b
child 175940 b8fb14d0d1a3eb5eecf9747fa0998d70f3dd2ad1
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck, metro-only
bugs947078
milestone28.0a2
Bug 947078 - Make the "Include URLs" option for the crash reporter into a checkbox instead of a toggle.r=mbrubeck a=metro-only
browser/metro/base/content/browser-ui.js
browser/metro/base/content/browser.xul
browser/metro/base/content/flyoutpanels/PrefsFlyoutPanel.js
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -959,16 +959,17 @@ var BrowserUI = {
       case "cmd_quit":
       case "cmd_close":
       case "cmd_newTab":
       case "cmd_newTabKey":
       case "cmd_closeTab":
       case "cmd_undoCloseTab":
       case "cmd_actions":
       case "cmd_panel":
+      case "cmd_reportingCrashesSubmitURLs":
       case "cmd_flyout_back":
       case "cmd_sanitize":
       case "cmd_volumeLeft":
       case "cmd_volumeRight":
       case "cmd_openFile":
       case "cmd_savePage":
         isSupported = true;
         break;
@@ -1066,16 +1067,20 @@ var BrowserUI = {
         this.undoCloseTab();
         break;
       case "cmd_sanitize":
         this.confirmSanitizeDialog();
         break;
       case "cmd_flyout_back":
         FlyoutPanelsUI.onBackButton();
         break;
+      case "cmd_reportingCrashesSubmitURLs":
+        let urlCheckbox = document.getElementById("prefs-reporting-submitURLs");
+        Services.prefs.setBoolPref('app.crashreporter.submitURLs', urlCheckbox.checked);
+        break;
       case "cmd_panel":
         PanelUI.toggle();
         break;
       case "cmd_openFile":
         this.openFile();
         break;
       case "cmd_savePage":
         this.savePage();
--- a/browser/metro/base/content/browser.xul
+++ b/browser/metro/base/content/browser.xul
@@ -92,16 +92,17 @@
     <command id="cmd_actions" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_panel" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_flyout_back" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_addBookmark" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_bookmarks" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_history" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_sanitize" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_contextUI" oncommand="CommandUpdater.doCommand(this.id);"/>
+    <command id="cmd_reportingCrashesSubmitURLs" oncommand="CommandUpdater.doCommand(this.id);"/>
 
     <!-- scrolling -->
     <command id="cmd_scrollPageUp" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_scrollPageDown" oncommand="CommandUpdater.doCommand(this.id);"/>
 
     <!-- editing -->
     <command id="cmd_cut" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_copy" oncommand="CommandUpdater.doCommand(this.id);"/>
@@ -673,20 +674,20 @@ Desktop browser's sync prefs.
           </deck>
         </hbox>
       </settings>
       <setting pref="signon.rememberSignons" title="&optionsHeader.privacy.passwords.label;" type="bool"/>
       <settings id="prefs-reporting" label="&optionsHeader.reporting.title;">
         <setting pref="app.crashreporter.autosubmit"
                  type="bool"
                  title="&optionsHeader.reporting.crashes.label;" />
-        <setting pref="app.crashreporter.submitURLs"
-                 id="prefs-reporting-submitURLs"
-                 type="bool"
-                 title="&optionsHeader.reporting.crashes.submitURLs;" />
+        <checkbox id="prefs-reporting-submitURLs"
+                  cropped="end"
+                  label="&optionsHeader.reporting.crashes.submitURLs;"
+                  command="cmd_reportingCrashesSubmitURLs"/>
       </settings>
       <settings id="prefs-telemetry" label="&optionsHeader.telemetry.title;">
         <setting
 #ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
           pref="toolkit.telemetry.enabledPreRelease"
 #else
           pref="toolkit.telemetry.enabled"
 #endif
--- a/browser/metro/base/content/flyoutpanels/PrefsFlyoutPanel.js
+++ b/browser/metro/base/content/flyoutpanels/PrefsFlyoutPanel.js
@@ -24,43 +24,44 @@ let PrefsFlyoutPanel = {
       ['PrefsFlyoutPanel',  'prefs-flyoutpanel'],
     ].forEach(function(aElement) {
       let [name, id] = aElement;
       XPCOMUtils.defineLazyGetter(self._elements, name, function() {
         return document.getElementById(id);
       });
     });
 
-    this._prefObserver(null, null, "privacy.donottrackheader.value");
+    this.observe(null, null, "privacy.donottrackheader.value");
+    this._updateSubmitURLs();
     this._topmostElement = this._elements.PrefsFlyoutPanel;
   },
 
   _show: function() {
     if (!this._hasShown) {
       SanitizeUI.init();
       this._hasShown = true;
 
       Services.prefs.addObserver("privacy.donottrackheader.value",
-                                 this._prefObserver,
+                                 this,
                                  false);
       Services.prefs.addObserver("privacy.donottrackheader.enabled",
-                                 this._prefObserver,
+                                 this,
                                  false);
       Services.prefs.addObserver("app.crashreporter.autosubmit",
-                                 this._prefObserver,
+                                 this,
                                  false);
       Services.prefs.addObserver("app.crashreporter.submitURLs",
-                                 this._prefObserver,
+                                 this,
                                  false);
     }
 
     this._topmostElement.show();
   },
 
-  _prefObserver: function(subject, topic, data) {
+  observe: function(subject, topic, data) {
     let value = -1;
     try {
       value = Services.prefs.getIntPref("privacy.donottrackheader.value");
     } catch(e) {
     }
 
     let isEnabled = Services.prefs.getBoolPref("privacy.donottrackheader.enabled");
 
@@ -85,31 +86,35 @@ let PrefsFlyoutPanel = {
         // other pref as well so our UI doesn't give false information
         if (((1 == value) || (0 == value)) && !isEnabled) {
           Services.prefs.setIntPref('privacy.donottrackheader.value', -1);
         }
         break;
 
       case "app.crashreporter.autosubmit":
         let autosubmit = Services.prefs.getBoolPref("app.crashreporter.autosubmit");
+        let urlCheckbox = document.getElementById("prefs-reporting-submitURLs");
         if (!autosubmit) {
-          // If the user has selected not to submit crash reports, the UI
-          // should reflect also that URLs will not be included.
-          // TODO: Ideally we would grey out the text and the toggle for
-          // the "include URLs" pref, but the |setting| binding doesn't
-          // appear to support enabling/disabling. In the meantime, we just
-          // set the "include URLs" pref to false if the "send crash reports"
-          // pref has been set to false.
-          Services.prefs.setBoolPref('app.crashreporter.submitURLs', false);
+          // disables the submitURLs ui if no crashreports will be submited, but doesn't change the pref 
+          urlCheckbox.setAttribute("disabled", true);
+        }
+        else {
+          urlCheckbox.setAttribute("disabled", false);
         }
         break;
 
       case "app.crashreporter.submitURLs":
-        let submitURLs = Services.prefs.getBoolPref("app.crashreporter.submitURLs");
-        if (submitURLs) {
-          // If the user has selected to submit URLs, they are implicitly also
-          // selecting to submit crash reports. Let's update the autosubmit pref
-          Services.prefs.setBoolPref('app.crashreporter.autosubmit', true);
-        }
-      break;
+        this._updateSubmitURLs();
+        break;
+    }
+  },
+
+  _updateSubmitURLs: function() {
+    let submitURLs = Services.prefs.getBoolPref("app.crashreporter.submitURLs");
+    let urlCheckbox = document.getElementById("prefs-reporting-submitURLs");
+    if (submitURLs) {
+      urlCheckbox.checked = true; 
+    }
+    else {
+      urlCheckbox.checked = false;
     }
   },
 };