Bug 620523 - Use Firefox error console pref and dont require restart [r=mfinkle]
authorWes Johnston <wjohnston@mozilla.com>
Mon, 03 Jan 2011 17:06:27 -0800
changeset 67201 096154dce06b94652329f4b677b0efd0712d3b84
parent 67200 49fc3ddc19eb68301321734bf6a4c39239e21090
child 67202 c34f1e8ffbe76549b256eebd12db10b0bd44d180
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs620523
Bug 620523 - Use Firefox error console pref and dont require restart [r=mfinkle]
mobile/app/mobile.js
mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.xul
mobile/chrome/content/browser.js
mobile/chrome/content/console.js
--- a/mobile/app/mobile.js
+++ b/mobile/app/mobile.js
@@ -360,17 +360,17 @@ pref("content.sink.perf_parse_time", 500
 
 pref("javascript.options.mem.gc_frequency", 300);
 pref("javascript.options.methodjit.chrome", false);
 
 pref("dom.max_chrome_script_run_time", 0); // disable slow script dialog for chrome
 pref("dom.max_script_run_time", 20);
 
 // JS error console
-pref("browser.console.showInPanel", false);
+pref("devtools.errorconsole.enabled", false);
 
 // kinetic tweakables
 pref("browser.ui.kinetic.updateInterval", 30);
 pref("browser.ui.kinetic.decelerationRate", 20);
 pref("browser.ui.kinetic.speedSensitivity", 80);
 pref("browser.ui.kinetic.swipeLength", 160);
 
 // zooming
@@ -506,8 +506,9 @@ pref("services.sync.client.type", "mobil
 pref("services.sync.registerEngines", "Tab,Bookmarks,Form,History,Password");
 pref("services.sync.autoconnectDelay", 5);
 
 // threshold where a tap becomes a drag, in 1/240" reference pixels
 pref("ui.dragThreshold", 24);
 
 pref("layers.accelerate-all", false);
 
+pref("notification.feature.enabled", true);
--- a/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.xul
+++ b/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.xul
@@ -64,15 +64,15 @@
           </settings>
           <settings id="feedback-information" label="&feedback.information.title;">
             <setting id="feedback-about" title="&feedback.about.title;" type="control">
               <button id="feedback-about-button" label="&feedback.about.button;" oncommand="Feedback.openReadme();"/>
             </setting>
           </settings>
           <settings id="feedback-tools" label="&feedback.tools.title;">
             <setting pref="extensions.checkCompatibility.4.0b" title="&feedback.forceCompat.title;" type="bool" inverted="true" oninputchanged="Feedback.updateRestart();"/>
-            <setting pref="browser.console.showInPanel" title="&feedback.errorConsole.title;" type="bool" oninputchanged="Feedback.updateRestart();"/>
+            <setting pref="devtools.errorconsole.enabled" title="&feedback.errorConsole.title;" type="bool"/>
           </settings>
         </richlistbox>
       </notificationbox>
     </vbox>
   </deck>
 </overlay>
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -380,22 +380,16 @@ var Browser = {
 
       // Also open any commandline URLs, except the homepage
       if (commandURL && commandURL != this.getHomePage())
         this.addTab(commandURL, true);
     } else {
       this.addTab(commandURL || this.getHomePage(), true);
     }
 
-    // JavaScript Error Console
-    if (Services.prefs.getBoolPref("browser.console.showInPanel")){
-      let button = document.getElementById("tool-console");
-      button.hidden = false;
-    }
-
     // If some add-ons were disabled during during an application update, alert user
     if (Services.prefs.prefHasUserValue("extensions.disabledAddons")) {
       let addons = Services.prefs.getCharPref("extensions.disabledAddons").split(",");
       if (addons.length > 0) {
         let disabledStrings = Strings.browser.GetStringFromName("alertAddonsDisabled");
         let label = PluralForm.get(addons.length, disabledStrings).replace("#1", addons.length);
 
         let alerts = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
--- a/mobile/chrome/content/console.js
+++ b/mobile/chrome/content/console.js
@@ -38,16 +38,17 @@
 let ConsoleView = {
   _list: null,
   _inited: false,
   _evalTextbox: null,
   _evalFrame: null,
   _evalCode: "",
   _bundle: null,
   _showChromeErrors: -1,
+  _enabledPref: "devtools.errorconsole.enabled",
 
   init: function cv_init() {
     if (this._list)
       return;
 
     this._list = document.getElementById("console-box");
     this._evalTextbox = document.getElementById("console-eval-textbox");
     this._bundle = Strings.browser;
@@ -59,16 +60,28 @@ let ConsoleView = {
     let panels = document.getElementById("panel-items");
 
     panels.addEventListener("select",
                             function(aEvent) {
                               if (panels.selectedPanel.id == "console-container")
                                 self._delayedInit();
                             },
                             false);
+
+    try {
+      // update users using the legacy pref
+      if (Services.prefs.getBoolPref("browser.console.showInPanel")) {
+        Services.prefs.setBoolPref(this._enabledPref, true);
+        Services.prefs.clearUserPref("browser.console.showInPanel");
+      }
+    } catch(ex) {
+      // likely don't have an old pref
+    }
+    this.updateVisibility();
+    Services.prefs.addObserver(this._enabledPref, this, false);
   },
 
   _delayedInit: function cv__delayedInit() {
     if (this._inited)
       return;
     this._inited = true;
 
     Services.console.registerListener(this);
@@ -83,20 +96,34 @@ let ConsoleView = {
 
     let self = this;
     this._evalFrame.addEventListener("load", function() { self.loadOrDisplayResult(); }, true);
   },
 
   uninit: function cv_uninit() {
     if (this._inited)
       Services.console.unregisterListener(this);
+
+    Services.prefs.removeObserver(this._enabledPref, this, false);
+  },
+
+  get enabled() {
+    return Services.prefs.getBoolPref(this._enabledPref);
   },
 
-  observe: function(aObject) {
-    this.appendItem(aObject);
+  updateVisibility: function ec_updateVisibility(aVal, aPref) {
+    let button = document.getElementById("tool-console");
+    button.hidden = !this.enabled;
+  },
+
+  observe: function(aSubject, aTopic, aData) {
+    if (aTopic == "nsPref:changed")
+      this.updateVisibility();
+    else
+      this.appendItem(aSubject);
   },
 
   showChromeErrors: function() {
     if (this._showChromeErrors != -1)
       return this._showChromeErrors;
 
     try {
       let pref = Services.prefs;