Fix review comments from bug 568691 comment 45.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Thu, 24 Jun 2010 11:56:28 -0400
changeset 47040 fa3febb60a8ca125cc55c8c9b20c24ebc94c9ff1
parent 47039 aae6f414c19ac3d7847712e6f9f20cfbc7ecf191
child 47041 60c84aedde372108cc1ed42a25152e728496f504
push idunknown
push userunknown
push dateunknown
bugs568691
milestone1.9.3a6pre
Fix review comments from bug 568691 comment 45.
browser/components/BrowserComponents.manifest
browser/components/feeds/src/FeedConverter.js
browser/components/nsBrowserContentHandler.js
browser/components/sidebar/src/nsSidebar.manifest
browser/fuel/src/fuelApplication.manifest
content/xslt/src/xslt/txEXSLTRegExFunctions.js
netwerk/test/httpserver/httpd.js
toolkit/components/exthelper/extApplication.js
xpcom/ds/nsINIProcessor.js
--- a/browser/components/BrowserComponents.manifest
+++ b/browser/components/BrowserComponents.manifest
@@ -1,8 +1,9 @@
+# nsBrowserContentHandler.js
 component {5d0ce354-df01-421a-83fb-7ead0990c24e} nsBrowserContentHandler.js application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/browser/clh;1 {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 component {47cd0651-b1be-4a0f-b5c4-10e5a573ef71} nsBrowserContentHandler.js application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/browser/final-clh;1 {47cd0651-b1be-4a0f-b5c4-10e5a573ef71} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/uriloader/content-handler;1?type=text/html {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/uriloader/content-handler;1?type=application/vnd.mozilla.xul+xml {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 #ifdef MOZ_SVG
 contract @mozilla.org/uriloader/content-handler;1?type=image/svg+xml {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
@@ -18,13 +19,15 @@ contract @mozilla.org/uriloader/content-
 contract @mozilla.org/uriloader/content-handler;1?type=image/png {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/uriloader/content-handler;1?type=image/bmp {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/uriloader/content-handler;1?type=image/x-icon {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/uriloader/content-handler;1?type=image/vnd.microsoft.icon {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/uriloader/content-handler;1?type=application/http-index-format {5d0ce354-df01-421a-83fb-7ead0990c24e} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 category command-line-handler m-browser @mozilla.org/browser/clh;1 application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 category command-line-handler x-default @mozilla.org/browser/final-clh;1 application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 category command-line-validator b-browser @mozilla.org/browser/clh;1 application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+
+# nsBrowserGlue.js
 component {eab9012e-5f74-4cbc-b2b5-a590235513cc} nsBrowserGlue.js application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/browser/browserglue;1 {eab9012e-5f74-4cbc-b2b5-a590235513cc} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 category app-startup nsBrowserGlue service,@mozilla.org/browser/browserglue;1 application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 component {C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5} nsBrowserGlue.js application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 contract @mozilla.org/geolocation/prompt;1 {C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
--- a/browser/components/feeds/src/FeedConverter.js
+++ b/browser/components/feeds/src/FeedConverter.js
@@ -362,18 +362,18 @@ FeedConverter.prototype = {
     throw Cr.NS_ERROR_NO_INTERFACE;
   },
 };
 
 /**
  * Keeps parsed FeedResults around for use elsewhere in the UI after the stream
  * converter completes. 
  */
-function FeedResultService()
-{ }
+function FeedResultService() {
+}
 
 FeedResultService.prototype = {
   classID: Components.ID("{2376201c-bbc6-472f-9b62-7548040a61c6}"),
   
   /**
    * A URI spec -> [nsIFeedResult] hash. We have to keep a list as the
    * value in case the same URI is requested concurrently.
    */
@@ -515,41 +515,42 @@ FeedResultService.prototype = {
 };
 
 /**
  * A protocol handler that attempts to deal with the variant forms of feed:
  * URIs that are actually either http or https.
  */
 function GenericProtocolHandler() {
 }
-FeedProtocolHandler.prototype = {
-  _init: function FPH_init() {
+GenericProtocolHandler.prototype = {
+  _init: function GPH_init(scheme) {
     var ios = 
       Cc["@mozilla.org/network/io-service;1"].
       getService(Ci.nsIIOService);
     this._http = ios.getProtocolHandler("http");
+    this._scheme = scheme;
   },
 
   get scheme() {
     return this._scheme;
   },
   
   get protocolFlags() {
     return this._http.protocolFlags;
   },
   
   get defaultPort() {
     return this._http.defaultPort;
   },
   
-  allowPort: function FPH_allowPort(port, scheme) {
+  allowPort: function GPH_allowPort(port, scheme) {
     return this._http.allowPort(port, scheme);
   },
   
-  newURI: function FPH_newURI(spec, originalCharset, baseURI) {
+  newURI: function GPH_newURI(spec, originalCharset, baseURI) {
     // See bug 408599 - feed URIs can be either standard URLs of the form
     // feed://example.com, in which case the real protocol is http, or nested
     // URIs of the form feed:realscheme:. When realscheme is either http or
     // https, we deal with the way that creates a standard URL with the
     // realscheme as the host by unmangling in newChannel; for others, we fail
     // rather than let it wind up loading something like www.realscheme.com//foo
 
     const feedSlashes = "feed://";
@@ -565,17 +566,17 @@ FeedProtocolHandler.prototype = {
     var uri = 
         Cc["@mozilla.org/network/standard-url;1"].
         createInstance(Ci.nsIStandardURL);
     uri.init(Ci.nsIStandardURL.URLTYPE_STANDARD, 80, spec, originalCharset,
              baseURI);
     return uri;
   },
   
-  newChannel: function FPH_newChannel(aUri) {
+  newChannel: function GPH_newChannel(aUri) {
     var ios = 
         Cc["@mozilla.org/network/io-service;1"].
         getService(Ci.nsIIOService);
     // feed: URIs either start feed://, in which case the real scheme is http:
     // or feed:http(s)://, (which by now we've changed to feed://realscheme//)
     var feedSpec = aUri.spec;
     const httpsChunk = "feed://https//";
     const httpChunk = "feed://http//";
@@ -590,34 +591,33 @@ FeedProtocolHandler.prototype = {
     var channel =
       ios.newChannelFromURI(uri, null).QueryInterface(Ci.nsIHttpChannel);
     // Set this so we know this is supposed to be a feed
     channel.setRequestHeader("X-Moz-Is-Feed", "1", false);
     channel.originalURI = aUri;
     return channel;
   },
   
-  QueryInterface: function FPH_QueryInterface(iid) {
+  QueryInterface: function GPH_QueryInterface(iid) {
     if (iid.equals(Ci.nsIProtocolHandler) ||
         iid.equals(Ci.nsISupports))
       return this;
     throw Cr.NS_ERROR_NO_INTERFACE;
   }  
 };
 
-function FeedProtocolHandler()
-{
-  this._init();
+function FeedProtocolHandler() {
+  this._init('feed');
 }
 FeedProtocolHandler.prototype = new GenericProtocolHandler();
-FeedProtocolHandler.prototype._scheme = "feed";
 FeedProtocolHandler.classID = Components.ID("{4f91ef2e-57ba-472e-ab7a-b4999e42d6c0}");
 
-function PCastProtocolHandler()
-{
-  this._init();
+function PodCastProtocolHandler() {
+  this._init('pcast');
 }
-PCastProtocolHandler.prototype = new GenericProtocolHandler();
-PCastProtocolHandler.prototype._scheme = "pcast";
-PCastProtocolHandler.prototype.classID = Components.ID("{1c31ed79-accd-4b94-b517-06e0c81999d5}");
+PodCastProtocolHandler.prototype = new GenericProtocolHandler();
+PodCastProtocolHandler.prototype.classID = Components.ID("{1c31ed79-accd-4b94-b517-06e0c81999d5}");
 
-var components = [FeedConverter, FeedResultService, FeedProtocolHandler, PCastProtocolHandler];
+var components = [FeedConverter,
+                  FeedResultService,
+                  FeedProtocolHandler,
+                  PodCastProtocolHandler];
 var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -327,18 +327,17 @@ function doSearch(searchTerm, cmdLine) {
 
   return wwatch.openWindow(null, gBrowserContentHandler.chromeURL,
                            "_blank",
                            "chrome,dialog=no,all" +
                            gBrowserContentHandler.getFeatures(cmdLine),
                            sa);
 }
 
-function nsBrowserContentHandler()
-{
+function nsBrowserContentHandler() {
 }
 nsBrowserContentHandler.prototype = {
   classID: Components.ID("{5d0ce354-df01-421a-83fb-7ead0990c24e}"),
 
   _xpcom_factory: {
     createInstance: function bch_factory_ci(outer, iid) {
       if (outer)
         throw Components.results.NS_ERROR_NO_AGGREGATION;
@@ -358,26 +357,20 @@ nsBrowserContentHandler.prototype = {
     var prefb = Components.classes["@mozilla.org/preferences-service;1"]
                           .getService(nsIPrefBranch);
     this.mChromeURL = prefb.getCharPref("browser.chromeURL");
 
     return this.mChromeURL;
   },
 
   /* nsISupports */
-  QueryInterface : function bch_QI(iid) {
-    if (!iid.equals(nsISupports) &&
-        !iid.equals(nsICommandLineHandler) &&
-        !iid.equals(nsIBrowserHandler) &&
-        !iid.equals(nsIContentHandler) &&
-        !iid.equals(nsICommandLineValidator))
-      throw Components.results.NS_ERROR_NO_INTERFACE;
-
-    return this;
-  },
+  QueryInterface : XPCOMUtils.generateQI([nsICommandLineHandler,
+                                          nsIBrowserHandler,
+                                          nsIContentHandler,
+                                          nsICommandLineValidator]),
 
   /* nsICommandLineHandler */
   handle : function bch_handle(cmdLine) {
     if (cmdLine.handleFlag("browser", false)) {
       // Passing defaultArgs, so use NO_EXTERNAL_URIS
       openWindow(null, this.chromeURL, "_blank",
                  "chrome,dialog=no,all" + this.getFeatures(cmdLine),
                  this.defaultArgs, NO_EXTERNAL_URIS);
@@ -730,18 +723,17 @@ function handURIToExistingBrowser(uri, l
   var rootItem = navNav.QueryInterface(nsIDocShellTreeItem).rootTreeItem;
   var rootWin = rootItem.QueryInterface(nsIInterfaceRequestor)
                         .getInterface(nsIDOMWindow);
   var bwin = rootWin.QueryInterface(nsIDOMChromeWindow).browserDOMWindow;
   bwin.openURI(uri, null, location,
                nsIBrowserDOMWindow.OPEN_EXTERNAL);
 }
 
-function nsDefaultCommandLineHandler()
-{
+function nsDefaultCommandLineHandler() {
 }
 
 nsDefaultCommandLineHandler.prototype = {
   classID: Components.ID("{47cd0651-b1be-4a0f-b5c4-10e5a573ef71}"),
 
   /* nsISupports */
   QueryInterface : function dch_QI(iid) {
     if (!iid.equals(nsISupports) &&
--- a/browser/components/sidebar/src/nsSidebar.manifest
+++ b/browser/components/sidebar/src/nsSidebar.manifest
@@ -1,4 +1,4 @@
 component {22117140-9c6e-11d3-aaf1-00805f8a4905} nsSidebar.js
 contract @mozilla.org/sidebar;1 {22117140-9c6e-11d3-aaf1-00805f8a4905}
 category JavaScript-global-property sidebar @mozilla.org/sidebar;1
-category JavaScript-global-property sidebar @mozilla.org/sidebar;1
+category JavaScript-global-property external @mozilla.org/sidebar;1
--- a/browser/fuel/src/fuelApplication.manifest
+++ b/browser/fuel/src/fuelApplication.manifest
@@ -1,2 +1,3 @@
 component {fe74cf80-aa2d-11db-abbd-0800200c9a66} fuelApplication.js
 contract @mozilla.org/fuel/application;1 {fe74cf80-aa2d-11db-abbd-0800200c9a66}
+category JavaScript-global-privileged-property extApplication @mozilla.org/fuel/application;1
--- a/content/xslt/src/xslt/txEXSLTRegExFunctions.js
+++ b/content/xslt/src/xslt/txEXSLTRegExFunctions.js
@@ -34,27 +34,29 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-const EXSLT_REGEXP_DESC = "EXSLT RegExp extension functions"
+const EXSLT_REGEXP_CID = Components.ID("{18a03189-067b-4978-b4f1-bafe35292ed6}");
 
 const CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1";
 const NODESET_CONTRACTID = "@mozilla.org/transformiix-nodeset;1";
 
 const Ci = Components.interfaces;
 
 function txEXSLTRegExFunctions()
 {
 }
 
+var SingletonInstance = null;
+
 txEXSLTRegExFunctions.prototype = {
     classID: Components.ID("{18a03189-067b-4978-b4f1-bafe35292ed6}"),
 
     QueryInterface: function(iid) {
         if (iid.equals(Ci.nsISupports) ||
             iid.equals(Ci.txIEXSLTRegExFunctions))
             return this;
 
@@ -94,61 +96,44 @@ txEXSLTRegExFunctions.prototype = {
 
         return str.replace(re, replace);
     },
 
     test: function(str, regex, flags) {
         var re = new RegExp(regex, flags);
 
         return re.test(str);
+    },
+
+    _xpcom_factory: {
+        QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory,
+                                               Ci.nsIClassInfo]),
+
+        createInstance: function(outer, iid) {
+            if (outer != null)
+                throw Components.results.NS_ERROR_NO_AGGREGATION;
+
+            if (SingletonInstance == null)
+                SingletonInstance = new txEXSLTRegExFunctions();
+
+            return SingletonInstance.QueryInterface(iid);
+        },
+
+        getInterfaces: function(countRef) {
+            var interfaces = [
+                Ci.txIEXSLTRegExFunctions
+            ];
+            countRef.value = interfaces.length;
+
+            return interfaces;
+        },
+
+        getHelperForLanguage: function(language) {
+            return null;
+        },
+
+        classID: EXSLT_REGEXP_CID,
+        implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
+        flags: Ci.nsIClassInfo.SINGLETON
     }
 }
 
-var SingletonInstance = null;
-
-function NSGetFactory(cid)
-{
-    if (!cid.equals(EXSLT_REGEXP_CID))
-        throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-
-
-    return kFactory;
-}
-
-const kFactory = {
-    QueryInterface: function(iid) {
-        if (iid.equals(Ci.nsISupports) ||
-            iid.equals(Ci.nsIFactory) ||
-            iid.equals(Ci.nsIClassInfo))
-            return this;
-
-        throw Components.results.NS_ERROR_NO_INTERFACE;
-    },
-
-    createInstance: function(outer, iid) {
-        if (outer != null)
-            throw Components.results.NS_ERROR_NO_AGGREGATION;
-
-        if (SingletonInstance == null)
-            SingletonInstance = new txEXSLTRegExFunctions();
-
-        return SingletonInstance.QueryInterface(iid);
-    },
-
-    getInterfaces: function(countRef) {
-        var interfaces = [
-            Ci.txIEXSLTRegExFunctions
-        ];
-        countRef.value = interfaces.length;
-
-        return interfaces;
-    },
-
-    getHelperForLanguage: function(language) {
-        return null;
-    },
-
-    contractID: EXSLT_REGEXP_CONTRACTID,
-    classDescription: EXSLT_REGEXP_DESC,
-    classID: EXSLT_REGEXP_CID,
-    implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
-    flags: Ci.nsIClassInfo.SINGLETON
-};
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([txEXSLTRegExFunctions]);
--- a/netwerk/test/httpserver/httpd.js
+++ b/netwerk/test/httpserver/httpd.js
@@ -41,16 +41,18 @@
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * An implementation of an HTTP server both as a loadable script and as an XPCOM
  * component.  See the accompanying README file for user documentation on
  * httpd.js.
  */
 
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 const CC = Components.Constructor;
 
 const PR_UINT32_MAX = Math.pow(2, 32) - 1;
 
@@ -395,16 +397,18 @@ function nsHttpServer()
   /**
    * Hash of all open connections, indexed by connection number at time of
    * creation.
    */
   this._connections = {};
 }
 nsHttpServer.prototype =
 {
+  classID: Components.ID("{54ef6f81-30af-4b1d-ac55-8ba811293e41}"),
+
   // NSISERVERSOCKETLISTENER
 
   /**
    * Processes an incoming request coming in on the given socket and contained
    * in the given transport.
    *
    * @param socket : nsIServerSocket
    *   the socket through which the request was served
@@ -5106,52 +5110,17 @@ Request.prototype =
     if (!this._bag)
       this._bag = new WritablePropertyBag();
   }
 };
 
 
 // XPCOM trappings
 
-/**
- * Creates a factory for instances of an object created using the passed-in
- * constructor.
- */
-function makeFactory(ctor)
-{
-  function ci(outer, iid)
-  {
-    if (outer != null)
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
-    return (new ctor()).QueryInterface(iid);
-  } 
-
-  return {
-           createInstance: ci,
-           lockFactory: function(lock) { },
-           QueryInterface: function(aIID)
-           {
-             if (Ci.nsIFactory.equals(aIID) ||
-                 Ci.nsISupports.equals(aIID))
-               return this;
-             throw Cr.NS_ERROR_NO_INTERFACE;
-           }
-         };
-}
-
-const kServerCID = Components.ID("{54ef6f81-30af-4b1d-ac55-8ba811293e41}");
-const kServerFactory = makeFactory(nsHttpServer);
-
-function NSGetFactory(cid)
-{
-  if (cid.equals(kServerCID))
-    return kServerFactory;
-    
-  throw Cr.NS_ERROR_FACTORY_NOT_REGISTERED;
-}
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsHttpServer]);
 
 /**
  * Creates a new HTTP server listening for loopback traffic on the given port,
  * starts it, and runs the server until the server processes a shutdown request,
  * spinning an event loop so that events posted by the server's socket are
  * processed.
  *
  * This method is primarily intended for use in running this script from within
--- a/toolkit/components/exthelper/extApplication.js
+++ b/toolkit/components/exthelper/extApplication.js
@@ -551,22 +551,16 @@ extApplication.prototype = {
     // references to various services, and to remove itself as
     // observer of any other notifications.
     this._obs = Cc["@mozilla.org/observer-service;1"].
                 getService(Ci.nsIObserverService);
     this._obs.addObserver(this, "xpcom-shutdown", false);
     this._registered = {"unload": true};
   },
 
-  // get this contractID registered for certain categories via XPCOMUtils
-  _xpcom_categories: [
-    // add Application as a global property for easy access
-    { category: "JavaScript-global-privileged-property" }
-  ],
-
   // for nsIClassInfo
   flags : Ci.nsIClassInfo.SINGLETON,
   implementationLanguage : Ci.nsIProgrammingLanguage.JAVASCRIPT,
 
   getInterfaces : function app_gi(aCount) {
     var interfaces = [Ci.extIApplication, Ci.nsIObserver, Ci.nsIClassInfo];
     aCount.value = interfaces.length;
     return interfaces;
--- a/xpcom/ds/nsINIProcessor.js
+++ b/xpcom/ds/nsINIProcessor.js
@@ -41,18 +41,16 @@ const Cr = Components.results;
 const Cu = Components.utils;
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function INIProcessorFactory() {
 }
 
 INIProcessorFactory.prototype = {
-    classDescription: "INIProcessorFactory",
-    contractID: "@mozilla.org/xpcom/ini-processor-factory;1",
     classID: Components.ID("{6ec5f479-8e13-4403-b6ca-fe4c2dca14fd}"),
     QueryInterface : XPCOMUtils.generateQI([Ci.nsIINIParserFactory]),
 
     createINIParser : function (aINIFile) {
         return new INIProcessor(aINIFile);
     }
 
 }; // end of INIProcessorFactory implementation
@@ -199,11 +197,9 @@ stringEnumerator.prototype = {
     },
 
     getNext : function() {
         return this._strings[this._enumIndex++];
     }
 };
 
 let component = [INIProcessorFactory];
-function NSGetModule (compMgr, fileSpec) {
-    return XPCOMUtils.generateModule(component);
-}
+var NSGetFactory = XPCOMUtils.generateNSGetFactory(component);