Part of Bug 576900 - Update the nsComposerCmdLineHandler component to use the new manifests and data tables. r=IanN,Neil. Part of bustage fix for CLOSED TREE
authorJustin Wood <bugspam.Callek@gmail.com>
Sun, 11 Jul 2010 01:21:32 -0400
changeset 5962 6561dd9db78e118c7a98e986b2c3a612d60de905
parent 5961 6e9997100337d460b1f0b7b560123e9158dbfc36
child 5963 112ee0f39b5fc70a0d33049611db655aba57a693
push idunknown
push userunknown
push dateunknown
reviewersIanN, Neil
bugs576900
Part of Bug 576900 - Update the nsComposerCmdLineHandler component to use the new manifests and data tables. r=IanN,Neil. Part of bustage fix for CLOSED TREE
editor/ui/Makefile.in
editor/ui/nsComposerCmdLineHandler.js
editor/ui/nsComposerCmdLineHandler.manifest
suite/installer/package-manifest.in
--- a/editor/ui/Makefile.in
+++ b/editor/ui/Makefile.in
@@ -44,13 +44,13 @@ include $(DEPTH)/config/autoconf.mk
 
 DIRS           = \
                locales \
                $(NULL)
 
 ifndef MOZ_STANDALONE_COMPOSER
 PREF_JS_EXPORTS = $(srcdir)/composer.js
 ifdef MOZ_SUITE
-EXTRA_COMPONENTS = nsComposerCmdLineHandler.js
+EXTRA_COMPONENTS = nsComposerCmdLineHandler.manifest nsComposerCmdLineHandler.js
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/editor/ui/nsComposerCmdLineHandler.js
+++ b/editor/ui/nsComposerCmdLineHandler.js
@@ -29,59 +29,30 @@
  * 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 ***** */
 
-const nsICmdLineHandler     = Components.interfaces.nsICmdLineHandler;
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
 const nsICommandLineHandler = Components.interfaces.nsICommandLineHandler;
-const nsIFactory            = Components.interfaces.nsIFactory;
-const nsISupports           = Components.interfaces.nsISupports;
-const nsIModule             = Components.interfaces.nsIModule;
-const nsIComponentRegistrar = Components.interfaces.nsIComponentRegistrar;
-const nsICategoryManager    = Components.interfaces.nsICategoryManager;
 const nsISupportsString     = Components.interfaces.nsISupportsString;
 const nsIWindowWatcher      = Components.interfaces.nsIWindowWatcher;
 
-const NS_ERROR_FAILURE        = Components.results.NS_ERROR_FAILURE;
-const NS_ERROR_NO_AGGREGATION = Components.results.NS_ERROR_NO_AGGREGATION;
-const NS_ERROR_NO_INTERFACE   = Components.results.NS_ERROR_NO_INTERFACE;
-
 function nsComposerCmdLineHandler() {}
 nsComposerCmdLineHandler.prototype = {
   get wrappedJSObject() {
     return this;
   },
 
   /* nsISupports */
-
-  QueryInterface: function(iid) {
-    if (iid.equals(nsISupports))
-      return this;
-
-    if (nsICmdLineHandler && iid.equals(nsICmdLineHandler))
-      return this;
-
-    if (nsICommandLineHandler && iid.equals(nsICommandLineHandler))
-      return this;
-
-    throw NS_ERROR_NO_INTERFACE;
-  },
-
-  /* nsICmdLineHandler */
-  commandLineArgument : "-edit",
-  prefNameForStartup : "general.startup.editor",
-  chromeUrlForTask : "chrome://editor/content/editor.xul",
-  helpText : "Start with editor.",
-  handlesArgs : true,
-  defaultArgs : "about:blank",
-  openWindowWithArgs : true,
+  QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler]),
 
   /* nsICommandLineHandler */
   handle : function handle(cmdLine) {
     var args = Components.classes["@mozilla.org/supports-string;1"]
                          .createInstance(nsISupportsString);
     try {
       var uristr = cmdLine.handleFlagWithParam("edit", false);
       if (uristr == null) {
@@ -105,111 +76,15 @@ nsComposerCmdLineHandler.prototype = {
 
     var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
                            .getService(nsIWindowWatcher);
     wwatch.openWindow(null, "chrome://editor/content", "_blank",
                       "chrome,dialog=no,all", args);
     cmdLine.preventDefault = true;
   },
 
-  helpInfo : "  -edit <url>        Open Composer.\n"
-};
-
-function nsComposerCmdLineHandlerFactory() {
-}
-
-nsComposerCmdLineHandlerFactory.prototype = {
-  /* nsISupports */
+  helpInfo : "  -edit <url>        Open Composer.\n",
 
-  QueryInterface: function(iid) {
-    if (!iid.equals(nsIFactory) &&
-        !iid.equals(nsISupports)) {
-          throw Components.results.NS_ERROR_NO_INTERFACE;
-    }
-    return this;
-  },
-
-  /* nsIFactory */
-  createInstance: function(outer, iid) {
-    if (outer != null) {
-      throw NS_ERROR_NO_AGGREGATION;
-    }
-
-    return new nsComposerCmdLineHandler().QueryInterface(iid);
-  },
-
-  lockFactory: function(lock) {
-  }
+  /* XPCOMUtils */
+  classID: Components.ID("{f7d8db95-ab5d-4393-a796-9112fe758cfa}")
 };
 
-const nsComposerCmdLineHandler_CID =
-  Components.ID("{f7d8db95-ab5d-4393-a796-9112fe758cfa}");
-
-const ContractIDPrefix =
-  "@mozilla.org/commandlinehandler/general-startup;1?type=";
-
-var thisModule = {
-  /* nsISupports */
-
-  QueryInterface: function(iid) {
-    if (!iid.equals(nsIModule) &&
-        !iid.equals(nsISupports)) {
-          throw Components.results.NS_ERROR_NO_INTERFACE;
-    }
-    return this;
-  },
-
-  /* nsIModule */
-
-  getClassObject: function (compMgr, cid, iid) {
-    if (!cid.equals(nsComposerCmdLineHandler_CID)) {
-      throw NS_ERROR_FAILURE;
-    }
-
-    if (!iid.equals(nsIFactory)) {
-      throw NS_ERROR_NO_INTERFACE;
-    }
-
-    return new nsComposerCmdLineHandlerFactory();
-  },
-
-  registerSelf: function (compMgr, fileSpec, location, type) {
-    var compReg = compMgr.QueryInterface(nsIComponentRegistrar);
-    compReg.registerFactoryLocation(nsComposerCmdLineHandler_CID,
-                                    "nsComposerCmdLineHandler",
-                                    ContractIDPrefix + "edit",
-                                    fileSpec, location, type);
-    compReg.registerFactoryLocation(nsComposerCmdLineHandler_CID,
-                                    "nsComposerCmdLineHandler",
-                                    ContractIDPrefix + "editor",
-                                    fileSpec, location, type);
-
-    var catMan = Components.classes["@mozilla.org/categorymanager;1"].getService(nsICategoryManager);
-    catMan.addCategoryEntry("command-line-argument-handlers",
-                            "nsComposerCmdLineHandler",
-                            ContractIDPrefix + "edit",
-                            true, true);
-    catMan.addCategoryEntry("command-line-handler",
-                            "m-edit",
-                            ContractIDPrefix + "edit",
-                            true, true);
-  },
-
-  unregisterSelf: function (compMgr, location, type) {
-    var compReg = compMgr.QueryInterface(nsIComponentRegistrar);
-    compReg.unregisterFactoryLocation(nsComposerCmdLineHandler_CID,
-                                      location);
-
-    var catMan = Components.classes["@mozilla.org/categorymanager;1"].getService(nsICategoryManager);
-    catMan.deleteCategoryEntry("command-line-argument-handlers",
-                               "nsComposerCmdLineHandler", true);
-    catMan.deleteCategoryEntry("command-line-handler",
-                               "m-edit", true);
-  },    
-
-  canUnload: function (compMgr) {
-    return true;
-  }
-};
-
-function NSGetModule(compMgr, fileSpec) {
-  return thisModule;
-}
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsComposerCmdLineHandler]);
new file mode 100644
--- /dev/null
+++ b/editor/ui/nsComposerCmdLineHandler.manifest
@@ -0,0 +1,3 @@
+component {f7d8db95-ab5d-4393-a796-9112fe758cfa} nsComposerCmdLineHandler.js
+contract @mozilla.org/commandlinehandler/general-startup;1?type=editor {f7d8db95-ab5d-4393-a796-9112fe758cfa}
+category command-line-handler m-edit @mozilla.org/commandlinehandler/general-startup;1?type=editor
--- a/suite/installer/package-manifest.in
+++ b/suite/installer/package-manifest.in
@@ -465,16 +465,17 @@
 @BINPATH@/components/nsAboutFeeds.js
 @BINPATH@/components/nsAboutRights.js
 @BINPATH@/components/nsAboutSessionRestore.js
 @BINPATH@/components/nsBadCertHandler.js
 @BINPATH@/components/nsBadCertHandler.manifest
 @BINPATH@/components/nsBlocklistService.js
 @BINPATH@/components/nsBrowserContentHandler.js
 @BINPATH@/components/nsComposerCmdLineHandler.js
+@BINPATH@/components/nsComposerCmdLineHandler.manifest
 @BINPATH@/components/nsContentDispatchChooser.js
 @BINPATH@/components/nsContentDispatchChooser.manifest
 @BINPATH@/components/nsContentPrefService.js
 @BINPATH@/components/nsContentPrefService.manifest
 @BINPATH@/components/nsDefaultCLH.js
 @BINPATH@/components/nsDefaultCLH.manifest
 #ifdef MOZ_GTK2
 @BINPATH@/components/nsFilePicker.js