Bug 576900 Make suite XPCOM components use new manifests and data tables. Browser JS Components. r=IanN a=Callek CLOSED TREE
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sat, 10 Jul 2010 18:41:56 +0800
changeset 5952 5e438936f3fa2073c26f617b401ee9b7460ac2ee
parent 5951 6192acf65e8d72ec9e404b86182d03a779ec514f
child 5953 f13a1ff86839e6232b1dc7601a7b384dcd6c5661
push idunknown
push userunknown
push dateunknown
reviewersIanN, Callek
bugs576900
Bug 576900 Make suite XPCOM components use new manifests and data tables. Browser JS Components. r=IanN a=Callek CLOSED TREE
suite/browser/Makefile.in
suite/browser/SuiteBrowser.manifest
suite/browser/nsAboutAbout.js
suite/browser/nsAboutRights.js
suite/browser/nsBrowserContentHandler.js
suite/browser/nsTypeAheadFind.js
--- a/suite/browser/Makefile.in
+++ b/suite/browser/Makefile.in
@@ -44,16 +44,17 @@ include $(DEPTH)/config/autoconf.mk
 
 PARALLEL_DIRS = public src
 
 ifdef ENABLE_TESTS
 PARALLEL_DIRS += test
 endif
 
 EXTRA_COMPONENTS = \
+	SuiteBrowser.manifest \
 	nsAboutAbout.js \
 	nsAboutRights.js \
 	nsBrowserContentHandler.js \
 	nsTypeAheadFind.js \
 	$(NULL)
 
 PREF_JS_EXPORTS = $(srcdir)/browser-prefs.js \
 		  $(srcdir)/channel-prefs.js \
new file mode 100644
--- /dev/null
+++ b/suite/browser/SuiteBrowser.manifest
@@ -0,0 +1,27 @@
+component {2a57d8af-8728-4e63-b01e-29f4a4ebf9a7} nsAboutAbout.js
+contract @mozilla.org/network/protocol/about;1?what=about {2a57d8af-8728-4e63-b01e-29f4a4ebf9a7}
+component {89e9da80-4c03-46a0-a357-cf77bbef98b9} nsAboutRights.js
+contract @mozilla.org/network/protocol/about;1?what=rights {89e9da80-4c03-46a0-a357-cf77bbef98b9}
+component {c2343730-dc2c-11d3-98b3-001083010e9b} nsBrowserContentHandler.js
+contract @mozilla.org/uriloader/content-handler;1?type=text/html" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=application/vnd.mozilla.xul+xml" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=image/svg+xml" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=text/rdf" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=text/xml" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=application/xhtml+xml" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=text/css" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=text/plain" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=image/gif" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=image/jpeg" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=image/jpg" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=image/png" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=image/bmp" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=image/x-icon" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=image/vnd.microsoft.icon" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/uriloader/content-handler;1?type=application/http-index-format" {c2343730-dc2c-11d3-98b3-001083010e9b}
+contract @mozilla.org/commandlinehandler/general-startup;1?type=browser {c2343730-dc2c-11d3-98b3-001083010e9b}
+category command-line-handler x-default @mozilla.org/commandlinehandler/general-startup;1?type=browser
+category command-line-validator b-default @mozilla.org/commandlinehandler/general-startup;1?type=browser
+component {45c8f75b-a299-4178-a461-f63690389055} nsTypeAheadFind.js
+contract @mozilla.org/suite/typeaheadfind;1 {45c8f75b-a299-4178-a461-f63690389055}
+category app-startup SuiteTypeAheadFind service,@mozilla.org/suite/typeaheadfind;1
--- a/suite/browser/nsAboutAbout.js
+++ b/suite/browser/nsAboutAbout.js
@@ -30,105 +30,42 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * 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 nsISupports           = Components.interfaces.nsISupports;
 const nsIAboutModule        = Components.interfaces.nsIAboutModule;
 const nsIFactory            = Components.interfaces.nsIFactory;
 const nsIIOService          = Components.interfaces.nsIIOService;
 const nsIComponentRegistrar = Components.interfaces.nsIComponentRegistrar;
 
 const ABOUTABOUT_URI = "chrome://navigator/content/aboutAbout.html";
 
-var nsAboutAbout = {
-  /* nsISupports */
-  QueryInterface: function QueryInterface(iid) {
-    if (iid.equals(nsISupports) ||
-        iid.equals(nsIAboutModule) ||
-        iid.equals(nsIFactory))
-      return this;
-
-    throw Components.results.NS_ERROR_NO_INTERFACE;
+function AboutAbout() {}
+AboutAbout.prototype = {
+  classID: Components.ID("{2a57d8af-8728-4e63-b01e-29f4a4ebf9a7}"),
+  QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIAboutModule]),
+  getURIFlags: function getURIFlags(aURI) {
+    return 0;
   },
-
-  /* nsIAboutModule */
   newChannel: function newChannel(aURI) {
     var ioService = Components.classes["@mozilla.org/network/io-service;1"]
                               .getService(nsIIOService);
 
     var channel = ioService.newChannel(ABOUTABOUT_URI, null, null);
 
     channel.originalURI = aURI;
 
     return channel;
   },
-
-  getURIFlags: function getURIFlags(aURI) {
-    return 0;
-  },
-
-  /* nsIFactory */
-  createInstance: function createInstance(outer, iid) {
-    if (outer != null)
-      throw Components.results.NS_ERROR_NO_AGGREGATION;
-
-    return this.QueryInterface(iid);
-  },
-
   lockFactory: function lockFactory(lock) {
     /* no-op */
   }
 };
 
-const NS_ABOUT_MODULE_CONTRACTID = "@mozilla.org/network/protocol/about;1";
-const NS_ABOUT_MODULE_CONTRACTID_PREFIX = NS_ABOUT_MODULE_CONTRACTID + "?what=";
-const ABOUTABOUT_CONTRACTID = NS_ABOUT_MODULE_CONTRACTID_PREFIX + "about";
-
-const ABOUTABOUT_CID = Components.ID("{2a57d8af-8728-4e63-b01e-29f4a4ebf9a7}");
-
-var Module = {
-  /* nsISupports */
-  QueryInterface: function QueryInterface(iid) {
-    if (iid.equals(Components.interfaces.nsIModule) ||
-        iid.equals(Components.interfaces.nsISupports))
-      return this;
-
-    throw Components.results.NS_ERROR_NO_INTERFACE;
-  },
-
-  /* nsIModule */
-  getClassObject: function getClassObject(compMgr, cid, iid) {
-    if (cid.equals(ABOUTABOUT_CID))
-      return nsAboutAbout.QueryInterface(iid);
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutAbout]);
 
-    throw Components.results.NS_ERROR_FACTORY_NOT_REGISTERED;
-  },
-    
-  registerSelf: function registerSelf(compMgr, fileSpec, location, type) {
-    var compReg = compMgr.QueryInterface(nsIComponentRegistrar);
-
-    compReg.registerFactoryLocation(ABOUTABOUT_CID,
-                                    "about:about",
-                                    ABOUTABOUT_CONTRACTID,
-                                    fileSpec,
-                                    location,
-                                    type);
-  },
-    
-  unregisterSelf: function unregisterSelf(compMgr, location, type) {
-    var compReg = compMgr.QueryInterface(nsIComponentRegistrar);
-    compReg.unregisterFactoryLocation(ABOUTABOUT_CID, location);
-  },
-
-  canUnload: function canUnload(compMgr) {
-    return true;
-  }
-};
-
-// NSGetModule: Return the nsIModule object.
-function NSGetModule(compMgr, fileSpec) {
-  return Module;
-}
--- a/suite/browser/nsAboutRights.js
+++ b/suite/browser/nsAboutRights.js
@@ -34,18 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function AboutRights() {}
 AboutRights.prototype = {
-  classDescription: "about:rights",
-  contractID: "@mozilla.org/network/protocol/about;1?what=rights",
   classID: Components.ID("{89e9da80-4c03-46a0-a357-cf77bbef98b9}"),
   QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIAboutModule]),
   getURIFlags: function(aURI) {
     return (Components.interfaces.nsIAboutModule.ALLOW_SCRIPT |
             Components.interfaces.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT);
   },
 
   newChannel: function(aURI) {
@@ -61,11 +59,10 @@ AboutRights.prototype = {
 
     channel.originalURI = aURI;
     channel.owner = principal;
 
     return channel;
   }
 };
 
-function NSGetModule(compMgr, fileSpec)
-  XPCOMUtils.generateModule([AboutRights]);
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutRights]);
 
--- a/suite/browser/nsBrowserContentHandler.js
+++ b/suite/browser/nsBrowserContentHandler.js
@@ -620,98 +620,15 @@ var nsBrowserContentHandler = {
     return this.QueryInterface(iid);
   },
     
   lockFactory: function lockFactory(lock) {
     /* no-op */
   }
 };
 
-const CONTRACTID_PREFIX = "@mozilla.org/uriloader/content-handler;1?type=";
-const BROWSER_CONTRACTID = NS_GENERAL_STARTUP_PREFIX + "browser";
 const BROWSER_CID = Components.ID("{c2343730-dc2c-11d3-98b3-001083010e9b}");
 
-var Module = {
-  /* nsISupports */
-  QueryInterface: function QueryInterface(iid) {
-    if (iid.equals(Components.interfaces.nsIModule) ||
-        iid.equals(Components.interfaces.nsISupports))
-      return this;
-
-    throw Components.results.NS_ERROR_NO_INTERFACE;
-  },
-
-  /* nsIModule */
-  getClassObject: function getClassObject(compMgr, cid, iid) {
-    if (cid.equals(BROWSER_CID))
-      return nsBrowserContentHandler.QueryInterface(iid);
-
-    throw Components.results.NS_ERROR_FACTORY_NOT_REGISTERED;
-  },
-    
-  registerSelf: function registerSelf(compMgr, fileSpec, location, type) {
-    var compReg = compMgr.QueryInterface(nsIComponentRegistrar);
-
-    compReg.registerFactoryLocation(BROWSER_CID,
-                                    "nsBrowserContentHandler",
-                                    BROWSER_CONTRACTID,
-                                    fileSpec,
-                                    location,
-                                    type);
-
-    function registerType(contentType) {
-      compReg.registerFactoryLocation(BROWSER_CID,
-				      "Browser Content Handler",
-				      CONTRACTID_PREFIX + contentType,
-				      fileSpec,
-				      location,
-				      type);
-    }
-
-    registerType("text/html");
-    registerType("application/vnd.mozilla.xul+xml");
-    registerType("image/svg+xml");
-    registerType("text/rdf");
-    registerType("text/xml");
-    registerType("application/xhtml+xml");
-    registerType("text/css");
-    registerType("text/plain");
-    registerType("image/gif");
-    registerType("image/jpeg");
-    registerType("image/jpg");
-    registerType("image/png");
-    registerType("image/bmp");
-    registerType("image/x-icon");
-    registerType("image/vnd.microsoft.icon");
-    registerType("application/http-index-format");
-
-    var catMan = Components.classes["@mozilla.org/categorymanager;1"]
-                           .getService(nsICategoryManager);
-
-    catMan.addCategoryEntry("command-line-handler", "x-default",
-                            BROWSER_CONTRACTID, true, true);
-    catMan.addCategoryEntry("command-line-validator",
-                            "b-default",
-                            BROWSER_CONTRACTID, true, true);
-  },
-    
-  unregisterSelf: function unregisterSelf(compMgr, location, type) {
-    var compReg = compMgr.QueryInterface(nsIComponentRegistrar);
-    compReg.unregisterFactoryLocation(BROWSER_CID, location);
-
-    var catMan = Components.classes["@mozilla.org/categorymanager;1"]
-                           .getService(nsICategoryManager);
-
-    catMan.deleteCategoryEntry("command-line-handler",
-                               "x-default", true);
-    catMan.deleteCategoryEntry("command-line-validator",
-                               "b-default", true);
-  },
-
-  canUnload: function canUnload(compMgr) {
-    return true;
-  }
-};
-
-// NSGetModule: Return the nsIModule object.
-function NSGetModule(compMgr, fileSpec) {
-  return Module;
+function NSGetFactory(cid) {
+  if (cid.number == BROWSER_CID)
+    return nsBrowserContentHandler;
+  throw Components.results.NS_ERROR_FACTORY_NOT_REGISTERED;
 }
--- a/suite/browser/nsTypeAheadFind.js
+++ b/suite/browser/nsTypeAheadFind.js
@@ -76,23 +76,17 @@ findTypeController.prototype = {
 }
 
 function typeAheadFind()
 {
 }
 
 typeAheadFind.prototype = {
   /* properties required for XPCOMUtils */
-  classDescription: "Suite Type Ahead Find",
   classID: Components.ID("{45c8f75b-a299-4178-a461-f63690389055}"),
-  contractID: "@mozilla.org/suite/typeaheadfind;1",
-  _xpcom_categories: [{
-    category: "app-startup",
-    service: true
-  }],
 
   /* members */
   mBadKeysSinceMatch: 0,
   mBundle: null,
   mCurrentWindow: null,
   mEventTarget: null,
   mFind: null,
   mFindService: null,
@@ -439,11 +433,9 @@ typeAheadFind.prototype = {
     this.showStatusString(aClear ? "" : "stopfind");
     if (aClear)
       this.mSearchString = "";
     if (aClear && this.mFind)
       this.mFind.collapseSelection();
   },
 };
 
-function NSGetModule() {
-  return XPCOMUtils.generateModule([typeAheadFind]);
-}
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([typeAheadFind]);