Bug 1404601 - Declare and rename debug function in nsSidebar.js. r=IanN a=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Tue, 03 Oct 2017 13:48:38 +0200
changeset 29797 f1b007502af6cee39e705049ec5940aacb91f141
parent 29796 8d15df25387ffe060b05e32414357ae672aa045f
child 29798 dc978dd570e89b7441f5e4b514735122d75ab123
push id378
push userclokep@gmail.com
push dateMon, 13 Nov 2017 18:45:35 +0000
reviewersIanN, IanN
bugs1404601
Bug 1404601 - Declare and rename debug function in nsSidebar.js. r=IanN a=IanN
suite/common/src/nsSidebar.js
--- a/suite/common/src/nsSidebar.js
+++ b/suite/common/src/nsSidebar.js
@@ -40,17 +40,17 @@ Components.utils.import("resource://gre/
 
 function nsSidebar()
 {
     const RDF_CONTRACTID = "@mozilla.org/rdf/rdf-service;1";
     const nsIRDFService = Components.interfaces.nsIRDFService;
 
     this.rdf = Components.classes[RDF_CONTRACTID].getService(nsIRDFService);
     this.datasource_uri = getSidebarDatasourceURI(PANELS_RDF_FILE);
-    debug('datasource_uri is ' + this.datasource_uri);
+    gDebugLog('datasource_uri is ' + this.datasource_uri);
     this.resource = 'urn:sidebar:current-panel-list';
     this.datasource = this.rdf.GetDataSource(this.datasource_uri);
 }
 
 nsSidebar.prototype.nc = "http://home.netscape.com/NC-rdf#";
 
 nsSidebar.prototype.isPanel =
 function (aContentURL)
@@ -72,26 +72,26 @@ function sidebarURLSecurityCheck(url)
     if (!/(^http:|^ftp:|^https:)/i.test(url))
         throw "Script attempted to add sidebar panel from illegal source";
 }
 
 /* decorate prototype to provide ``class'' methods and property accessors */
 nsSidebar.prototype.addPanel =
 function (aTitle, aContentURL, aCustomizeURL)
 {
-    debug("addPanel(" + aTitle + ", " + aContentURL + ", " +
+    gDebugLog("addPanel(" + aTitle + ", " + aContentURL + ", " +
           aCustomizeURL + ")");
 
     return this.addPanelInternal(aTitle, aContentURL, aCustomizeURL, false);
 }
 
 nsSidebar.prototype.addPersistentPanel =
 function(aTitle, aContentURL, aCustomizeURL)
 {
-    debug("addPersistentPanel(" + aTitle + ", " + aContentURL + ", " +
+    gDebugLog("addPersistentPanel(" + aTitle + ", " + aContentURL + ", " +
            aCustomizeURL + ")\n");
 
     return this.addPanelInternal(aTitle, aContentURL, aCustomizeURL, true);
 }
 
 nsSidebar.prototype.addPanelInternal =
 function (aTitle, aContentURL, aCustomizeURL, aPersist)
 {
@@ -99,17 +99,17 @@ function (aTitle, aContentURL, aCustomiz
 
     // Create a "container" wrapper around the current panels to
     // manipulate the RDF:Seq more easily.
     var panel_list = this.datasource.GetTarget(this.rdf.GetResource(this.resource), this.rdf.GetResource(nsSidebar.prototype.nc+"panel-list"), true);
     if (panel_list) {
         panel_list.QueryInterface(Components.interfaces.nsIRDFResource);
     } else {
         // Datasource is busted. Start over.
-        debug("Sidebar datasource is busted\n");
+        gDebugLog("Sidebar datasource is busted\n");
     }
 
     var container = Components.classes[CONTAINER_CONTRACTID].createInstance(nsIRDFContainer);
     container.Init(this.datasource, panel_list);
 
     /* Create a resource for the new panel and add it to the list */
     var panel_resource =
         this.rdf.GetResource("urn:sidebar:3rdparty-panel:" + aContentURL);
@@ -213,17 +213,17 @@ function (engineURL, iconURL)
     if (!isWeb.test(engineURL))
       throw "Unsupported search engine URL";
 
     if (iconURL && !isWeb.test(iconURL))
       throw "Unsupported search icon URL.";
   }
   catch(ex)
   {
-    debug(ex);
+    gDebugLog(ex);
     Components.utils.reportError("Invalid argument passed to window.sidebar.addSearchEngine: " + ex);
 
     var searchBundle = Services.strings.createBundle("chrome://global/locale/search/search.properties");
     var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
     var brandName = brandBundle.GetStringFromName("brandShortName");
     var title = searchBundle.GetStringFromName("error_invalid_engine_title");
     var msg = searchBundle.formatStringFromName("error_invalid_engine_msg",
                                                 [brandName], 1);
@@ -234,17 +234,17 @@ function (engineURL, iconURL)
   return true;
 }
 
 // The suggestedTitle and suggestedCategory parameters are ignored, but remain
 // for backward compatibility.
 nsSidebar.prototype.addSearchEngine =
 function (engineURL, iconURL, suggestedTitle, suggestedCategory)
 {
-  debug("addSearchEngine(" + engineURL + ", " + iconURL + ", " +
+  gDebugLog("addSearchEngine(" + engineURL + ", " + iconURL + ", " +
         suggestedCategory + ", " + suggestedTitle + ")");
 
   if (!this.validateSearchEngine(engineURL, iconURL))
     return;
 
   // OpenSearch files will likely be far more common than Sherlock files, and
   // have less consistent suffixes, so we assume that ".src" is a Sherlock
   // (text) file, and anything else is OpenSearch (XML).
@@ -307,21 +307,23 @@ nsSidebar.prototype.classInfo = XPCOMUti
 
 nsSidebar.prototype.QueryInterface =
     XPCOMUtils.generateQI([nsISidebar]);
 
 nsSidebar.prototype.classID = SIDEBAR_CID;
 
 var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsSidebar]);
 
+var gDebugLog;
+
 /* static functions */
 if (DEBUG)
-    debug = function (s) { dump("-*- sidebar component: " + s + "\n"); }
+    gDebugLog = function (s) { dump("-*- sidebar component: " + s + "\n"); }
 else
-    debug = function (s) {}
+    gDebugLog = function (s) {}
 
 function getSidebarDatasourceURI(panels_file_id)
 {
     try
     {
         /* use the fileLocator to look in the profile directory
          * to find 'panels.rdf', which is the
          * database of the user's currently selected panels.
@@ -329,24 +331,24 @@ function getSidebarDatasourceURI(panels_
          *bin/defaults/profile/panels.rdf to <profile>/panels.rdf */
         var sidebar_file = Services.dirsvc.get(panels_file_id,
                                                Components.interfaces.nsIFile);
 
         if (!sidebar_file.exists())
         {
             /* this should not happen, as GetFileLocation() should copy
              * defaults/panels.rdf to the users profile directory */
-            debug("sidebar file does not exist");
+            gDebugLog("sidebar file does not exist");
             return null;
         }
 
         var file_handler = Services.io.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
         var sidebar_uri = file_handler.getURLSpecFromFile(sidebar_file);
-        debug("sidebar uri is " + sidebar_uri);
+        gDebugLog("sidebar uri is " + sidebar_uri);
         return sidebar_uri;
     }
     catch (ex)
     {
         /* this should not happen */
-        debug("caught " + ex + " getting sidebar datasource uri");
+        gDebugLog("caught " + ex + " getting sidebar datasource uri");
         return null;
     }
 }