Bug 528445 - change app.update.log.* in updates.js to app.update.log for UI logging. r=dtownsend
authorRobert Strong <robert.bugzilla@gmail.com>
Fri, 13 Nov 2009 13:11:07 -0800
changeset 34837 13e619b6a8ec94c8256bd6cd1b3ff105a0047847
parent 34836 bd37d4d849c49896b45827c2931ab545cbcd1746
child 34838 9327ef16ef5945ecb7d1330ffa1ef3216fd01b89
push idunknown
push userunknown
push dateunknown
reviewersdtownsend
bugs528445
milestone1.9.3a1pre
Bug 528445 - change app.update.log.* in updates.js to app.update.log for UI logging. r=dtownsend
toolkit/mozapps/update/content/updates.js
--- a/toolkit/mozapps/update/content/updates.js
+++ b/toolkit/mozapps/update/content/updates.js
@@ -44,17 +44,17 @@ Components.utils.import("resource://gre/
 // so we have to use different names.
 const CoC = Components.classes;
 const CoI = Components.interfaces;
 const CoR = Components.results;
 
 const XMLNS_XUL               = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 const PREF_UPDATE_MANUAL_URL        = "app.update.url.manual";
-const PREF_APP_UPDATE_LOG_BRANCH    = "app.update.log.";
+const PREF_APP_UPDATE_LOG           = "app.update.log";
 const PREF_UPDATE_TEST_LOOP         = "app.update.test.loop";
 const PREF_UPDATE_NEVER_BRANCH      = "app.update.never.";
 const PREF_AUTO_UPDATE_ENABLED      = "app.update.enabled";
 const PREF_PLUGINS_UPDATEURL        = "plugins.update.url";
 
 const UPDATE_TEST_LOOP_INTERVAL     = 2000;
 
 const URI_UPDATES_PROPERTIES  = "chrome://mozapps/locale/update/updates.properties";
@@ -66,25 +66,25 @@ const STATE_SUCCEEDED         = "succeed
 const STATE_DOWNLOAD_FAILED   = "download-failed";
 const STATE_FAILED            = "failed";
 
 const SRCEVT_FOREGROUND       = 1;
 const SRCEVT_BACKGROUND       = 2;
 
 var gConsole    = null;
 var gPref       = null;
-var gLogEnabled = { };
+var gLogEnabled = false;
 
 /**
  * Logs a string to the error console.
  * @param   string
  *          The string to write to the error console..
  */
 function LOG(module, string) {
-  if (module in gLogEnabled || "all" in gLogEnabled) {
+  if (gLogEnabled) {
     dump("*** AUS:UI " + module + ":" + string + "\n");
     gConsole.logStringMessage("AUS:UI " + module + ":" + string);
   }
 }
 
 /**
  * Opens a URL using the event target's url attribute for the URL. This is a
  * workaround for Bug 263433 which prevents respecting tab browser preferences
@@ -307,17 +307,17 @@ var gUpdates = {
    */
   onLoad: function() {
     this.wiz = document.documentElement;
 
     gPref = CoC["@mozilla.org/preferences-service;1"].
             getService(CoI.nsIPrefBranch2);
     gConsole = CoC["@mozilla.org/consoleservice;1"].
                getService(CoI.nsIConsoleService);
-    this._initLoggingPrefs();
+    gLogEnabled = getPref("getBoolPref", PREF_APP_UPDATE_LOG, false)
 
     this.strings = document.getElementById("updateStrings");
     var brandStrings = document.getElementById("brandStrings");
     this.brandName = brandStrings.getString("brandShortName");
 
     var pages = gUpdates.wiz.childNodes;
     for (var i = 0; i < pages.length; ++i) {
       var page = pages[i];
@@ -335,36 +335,16 @@ var gUpdates = {
 
     // Advance to the Start page.
     var startPage = this.startPage;
     LOG("gUpdates", "onLoad - setting current page to startpage " + startPage.id);
     gUpdates.wiz.currentPage = startPage;
   },
 
   /**
-   * Initialize Logging preferences, formatted like so:
-   *  app.update.log.<moduleName> = <true|false>
-   */
-  _initLoggingPrefs: function() {
-    try {
-      var ps = CoC["@mozilla.org/preferences-service;1"].
-               getService(CoI.nsIPrefService);
-      var logBranch = ps.getBranch(PREF_APP_UPDATE_LOG_BRANCH);
-      var modules = logBranch.getChildList("");
-
-      for (var i = 0; i < modules.length; ++i) {
-        if (logBranch.prefHasUserValue(modules[i]))
-          gLogEnabled[modules[i]] = logBranch.getBoolPref(modules[i]);
-      }
-    }
-    catch (e) {
-    }
-  },
-
-  /**
    * Return the <wizardpage> object that should be displayed first.
    *
    * This is determined by how we were called by the update prompt:
    *
    * Prompt Method:       Arg0:         Update State: Src Event:  Failed:   Result:
    * showUpdateAvailable  nsIUpdate obj --            background  --        incompatibleCheck
    * showUpdateDownloaded nsIUpdate obj pending       background  --        finishedBackground
    * showUpdateInstalled  "installed"   --            --          --        installed