Bug 576900 Make suite XPCOM components use new manifests and data tables. Feed Shell Smile JS Components. r=Callek r=IanN a=Callek CLOSED TREE
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sat, 10 Jul 2010 18:41:56 +0800
changeset 5951 6192acf65e8d72ec9e404b86182d03a779ec514f
parent 5950 5c6ffe86e3a01dae0d45508a404040d427f1f7cf
child 5952 5e438936f3fa2073c26f617b401ee9b7460ac2ee
push idunknown
push userunknown
push dateunknown
reviewersCallek, IanN, Callek
bugs576900
Bug 576900 Make suite XPCOM components use new manifests and data tables. Feed Shell Smile JS Components. r=Callek r=IanN a=Callek CLOSED TREE
suite/feeds/src/FeedConverter.js
suite/feeds/src/FeedWriter.js
suite/feeds/src/Makefile.in
suite/feeds/src/SuiteFeeds.manifest
suite/feeds/src/WebContentConverter.js
suite/feeds/src/nsAboutFeeds.js
suite/shell/src/Makefile.in
suite/shell/src/nsSetDefault.js
suite/shell/src/nsSetDefault.manifest
suite/smile/src/Makefile.in
suite/smile/src/smileApplication.js
suite/smile/src/smileApplication.manifest
--- a/suite/feeds/src/FeedConverter.js
+++ b/suite/feeds/src/FeedConverter.js
@@ -164,18 +164,17 @@ FeedConverter.prototype = {
    * See nsISupports.idl
    */
   QueryInterface: XPCOMUtils.generateQI(
     [Components.interfaces.nsIFeedResultListener,
      Components.interfaces.nsIStreamConverter,
      Components.interfaces.nsIStreamListener,
      Components.interfaces.nsIRequestObserver,
      Components.interfaces.nsISupports]),
-  classDescription: "Feed Stream Converter",
-  classID: Components.ID("{88592F45-3866-4c8e-9D8A-AB58B290FCF7}"),
+  classID: Components.ID("{88592f45-3866-4c8e-9d8a-ab58b290fcf7}"),
   implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
 
   /**
    * See nsIStreamConverter.idl
    */
   convert: function convert(sourceStream, sourceType, destinationType,
                                context) {
     throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
@@ -357,51 +356,16 @@ FeedConverter.prototype = {
   onStopRequest: function onStopRequest(request, context, status) {
     if (this._processor)
       this._processor.onStopRequest(request, context, status);
   }
 
 };
 
 /**
- * Helper to register multiple components sharing the same prototype
- * using XPCOMUtils.
- */
-function build_component(component, ctor, properties) {
-  component.prototype = new ctor();
-  for (let name in properties) {
-    component.prototype[name] = properties[name];
-  }
-}
-
-function FeedConverter_feed() {
-}
-
-build_component(FeedConverter_feed, FeedConverter,
-                {contractID: "@mozilla.org/streamconv;1?from="
-                             + TYPE_MAYBE_FEED + "&to="
-                             + TYPE_ANY});
-
-function FeedConverter_audio_feed() {
-}
-
-build_component(FeedConverter_audio_feed, FeedConverter,
-                {contractID: "@mozilla.org/streamconv;1?from="
-                             + TYPE_MAYBE_AUDIO_FEED + "&to="
-                             + TYPE_ANY});
-
-function FeedConverter_video_feed() {
-}
-
-build_component(FeedConverter_video_feed, FeedConverter,
-                {contractID: "@mozilla.org/streamconv;1?from="
-                             + TYPE_MAYBE_VIDEO_FEED + "&to="
-                             + TYPE_ANY});
-
-/**
  * Keeps parsed FeedResults around for use elsewhere in the UI after the stream
  * converter completes.
  */
 function FeedResultService() {
   this._ioSvc = Components.classes["@mozilla.org/network/io-service;1"]
                           .getService(Components.interfaces.nsIIOService);
 }
 
@@ -524,33 +488,33 @@ FeedResultService.prototype = {
     // and trim the list
     resultList.splice(resultList.length - deletions, deletions);
     if (resultList.length == 0)
       delete this._results[uri.spec];
   },
 
   QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIFeedResultService,
                                          Components.interfaces.nsISupports]),
-  classID: Components.ID("{E5B05E9D-F037-48e4-B9A4-B99476582927}"),
-  classDescription: "Feed Result Service",
-  contractID: "@mozilla.org/browser/feeds/result-service;1",
+  classID: Components.ID("{e5b05e9d-f037-48e4-b9a4-b99476582927}"),
   implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT
 };
 
 /**
  * A protocol handler that attempts to deal with the variant forms of feed:
  * URIs that are actually either http or https.
  */
-function _FeedProtocolHandler() {
+function GenericProtocolHandler(scheme, classID) {
   this._ioSvc = Components.classes["@mozilla.org/network/io-service;1"]
                           .getService(Components.interfaces.nsIIOService);
   this._http = this._ioSvc.getProtocolHandler("http");
+  this.scheme = scheme;
+  this.classID = classID;
 }
 
-_FeedProtocolHandler.prototype = {
+GenericProtocolHandler.prototype = {
   get protocolFlags() {
     return this._http.protocolFlags;
   },
 
   get defaultPort() {
     return this._http.defaultPort;
   },
 
@@ -604,32 +568,23 @@ function _FeedProtocolHandler() {
   QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIProtocolHandler,
                                          Components.interfaces.nsISupports]),
   implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT
 };
 
 function FeedProtocolHandler() {
 }
 
-build_component(FeedProtocolHandler, _FeedProtocolHandler,
-                {classID: Components.ID("{A95D7F48-11BE-4324-8872-D23BD79FE78B}"),
-                 classDescription: "Feed Protocol Handler",
-                 contractID: "@mozilla.org/network/protocol;1?name=feed",
-                 scheme: "feed"
-                });
+FeedProtocolHandler.prototype = new GenericProtocolHandler("feed",
+    Components.ID("{a95d7f48-11be-4324-8872-d23bd79fe78b}"));
 
 function PodcastProtocolHandler() {
 }
 
-build_component(PodcastProtocolHandler, _FeedProtocolHandler,
-                {classID: Components.ID("{F0FF0FE4-1713-4d34-9323-3F5DEB6A6A60}"),
-                 classDescription: "Podcast Protocol Handler",
-                 contractID: "@mozilla.org/network/protocol;1?name=pcast",
-                 scheme: "pcast"
-                });
+PodcastProtocolHandler.prototype = new GenericProtocolHandler("pcast",
+    Components.ID("{f0ff0fe4-1713-4D34-9323-3f5deb6a6a60}"));
 
-var components = [FeedProtocolHandler, PodcastProtocolHandler, FeedResultService,
-                  FeedConverter_feed, FeedConverter_audio_feed,
-                  FeedConverter_video_feed];
+var components = [FeedConverter,
+                  FeedResultService,
+                  FeedProtocolHandler,
+                  PodcastProtocolHandler];
 
-function NSGetModule(cm, file) {
-  return XPCOMUtils.generateModule(components);
-}
+var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
--- a/suite/feeds/src/FeedWriter.js
+++ b/suite/feeds/src/FeedWriter.js
@@ -1415,26 +1415,20 @@ FeedWriter.prototype = {
     var interfaces = [Components.interfaces.nsIFeedWriter,
                        Components.interfaces.nsIClassInfo,
                        Components.interfaces.nsISupports];
     countRef.value = interfaces.length;
     return interfaces;
   },
 
   getHelperForLanguage: function getHelperForLanguage(language) null,
-  contractID: "@mozilla.org/browser/feeds/result-writer;1",
-  classDescription: "Feed Writer",
   classID: Components.ID("{49bb6593-3aff-4eb3-a068-2712c28bd58e}"),
   implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
   flags: Components.interfaces.nsIClassInfo.DOM_OBJECT,
-  _xpcom_categories: [{ category: "JavaScript global constructor",
-                        entry: "BrowserFeedWriter"}],
   QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIFeedWriter,
                                           Components.interfaces.nsIClassInfo,
                                           Components.interfaces.nsIDOMEventListener,
                                           Components.interfaces.nsINavHistoryObserver,
                                           Components.interfaces.nsIObserver])
 
 };
 
-function NSGetModule(cm, file) {
-  return XPCOMUtils.generateModule([FeedWriter]);
-}
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([FeedWriter]);
--- a/suite/feeds/src/Makefile.in
+++ b/suite/feeds/src/Makefile.in
@@ -47,21 +47,24 @@ META_COMPONENT  = suite
 FORCE_STATIC_LIB = 1
 FORCE_USE_PIC = 1
 
 DEFINES += \
 	-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
 	-DMOZ_APP_DISPLAYNAME=$(MOZ_APP_DISPLAYNAME) \
 	$(NULL)
 
-EXTRA_PP_COMPONENTS = \
+EXTRA_COMPONENTS = \
+	SuiteFeeds.manifest \
 	FeedConverter.js \
-	FeedWriter.js \
 	WebContentConverter.js \
 	nsAboutFeeds.js \
 	$(NULL)
 
+EXTRA_PP_COMPONENTS = \
+	FeedWriter.js \
+	$(NULL)
 
 CPPSRCS = \
 	nsFeedSniffer.cpp \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/suite/feeds/src/SuiteFeeds.manifest
@@ -0,0 +1,18 @@
+component {88592f45-3866-4c8e-9d8a-ab58b290fcf7} FeedConverter.js
+contract @mozilla.org/streamconv;1?from=application/vnd.mozilla.maybe.feed&to=*/* {88592f45-3866-4c8e-9d8a-ab58b290fcf7}
+contract @mozilla.org/streamconv;1?from=application/vnd.mozilla.maybe.video.feed&to=*/* {88592f45-3866-4c8e-9d8a-ab58b290fcf7}
+contract @mozilla.org/streamconv;1?from=application/vnd.mozilla.maybe.audio.feed&to=*/* {88592f45-3866-4c8e-9d8a-ab58b290fcf7}
+component {e5b05e9d-f037-48e4-b9a4-b99476582927} FeedConverter.js
+contract @mozilla.org/browser/feeds/result-service;1 {e5b05e9d-f037-48e4-b9a4-b99476582927}
+component {a95d7f48-11be-4324-8872-d23bd79fe78b} FeedConverter.js
+contract @mozilla.org/network/protocol;1?name=feed {a95d7f48-11be-4324-8872-d23bd79fe78b}
+component {f0ff0fe4-1713-4D34-9323-3f5deb6a6a60} FeedConverter.js
+contract @mozilla.org/network/protocol;1?name=pcast {f0ff0fe4-1713-4D34-9323-3f5deb6a6a60}
+component {49bb6593-3aff-4eb3-a068-2712c28bd58e} FeedWriter.js
+contract @mozilla.org/browser/feeds/result-writer;1 {49bb6593-3aff-4eb3-a068-2712c28bd58e}
+category JavaScript-global-constructor BrowserFeedWriter @mozilla.org/browser/feeds/result-writer;1
+component {792a7e82-06a0-437c-af63-b2d12e808acc} WebContentConverter.js
+contract @mozilla.org/embeddor.implemented/web-content-handler-registrar;1 {792a7e82-06a0-437c-af63-b2d12e808acc}
+category app-startup WebContentConverter service,@mozilla.org/embeddor.implemented/web-content-handler-registrar;1
+component {f3487aac-65a0-4101-88a4-f7450c231351} nsAboutFeeds.js
+contract @mozilla.org/network/protocol/about;1?what=feeds {f3487aac-65a0-4101-88a4-f7450c231351}
--- a/suite/feeds/src/WebContentConverter.js
+++ b/suite/feeds/src/WebContentConverter.js
@@ -38,17 +38,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/debug.js");
 
 const WCCR_CONTRACTID = "@mozilla.org/embeddor.implemented/web-content-handler-registrar;1";
 const WCCR_CLASSID = Components.ID("{792a7e82-06a0-437c-af63-b2d12e808acc}");
-const WCCR_CLASSNAME = "Web Content Handler Registrar";
 
 const WCC_CLASSID = Components.ID("{db7ebf28-cc40-415f-8a51-1b111851df1e}");
 const WCC_CLASSNAME = "Web Service Handler";
 
 const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
 const TYPE_ANY = "*/*";
 
 const PREF_CONTENTHANDLERS_AUTO = "browser.contentHandlers.auto.";
@@ -860,34 +859,25 @@ WebContentConverterRegistrar.prototype =
     countRef.value = interfaces.length;
     return interfaces;
   },
 
  getHelperForLanguage: function getHelperForLanguage(language) {
     return null;
   },
 
-  contractID: WCCR_CONTRACTID,
-  classDescription: WCCR_CLASSNAME,
   classID: WCCR_CLASSID,
   implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
   flags: Components.interfaces.nsIClassInfo.DOM_OBJECT,
 
   /**
    * See nsISupports
    */
   QueryInterface: XPCOMUtils.generateQI(
     [Components.interfaces.nsIWebContentConverterService,
      Components.interfaces.nsIWebContentHandlerRegistrar,
      Components.interfaces.nsIObserver,
      Components.interfaces.nsIClassInfo,
      Components.interfaces.nsIFactory,
-     Components.interfaces.nsISupports]),
-
-  _xpcom_categories: [{
-    category: "app-startup",
-    service: true
-  }]
+     Components.interfaces.nsISupports])
 };
 
-function NSGetModule(cm, file) {
-  return XPCOMUtils.generateModule([WebContentConverterRegistrar]);
-}
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([WebContentConverterRegistrar]);
--- a/suite/feeds/src/nsAboutFeeds.js
+++ b/suite/feeds/src/nsAboutFeeds.js
@@ -31,28 +31,24 @@
  * 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 ABOUTFEEDS_URI = "chrome://communicator/content/feeds/subscribe.xhtml";
-const ABOUTFEEDS_CONTRACTID = "@mozilla.org/network/protocol/about;1?what=feeds";
-const ABOUTFEEDS_CLASSNAME = "About Feeds Page";
 const ABOUTFEEDS_CLASSID = Components.ID("{f3487aac-65a0-4101-88a4-f7450c231351}");
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function AboutFeeds() {
 }
 
 AboutFeeds.prototype = {
-  classDescription: ABOUTFEEDS_CLASSNAME,
-  contractID: ABOUTFEEDS_CONTRACTID,
   classID: ABOUTFEEDS_CLASSID,
   implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
   QueryInterface: XPCOMUtils.generateQI(
     [Components.interfaces.nsIAboutModule,
     Components.interfaces.nsISupports]),
 
   newChannel: function(aURI) {
     var ios = Components.classes["@mozilla.org/network/io-service;1"]
@@ -70,11 +66,9 @@ AboutFeeds.prototype = {
 
   getURIFlags: function() {
     return Components.interfaces.nsIAboutModule.ALLOW_SCRIPT |
            Components.interfaces.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
   },
 
 };
 
-function NSGetModule(cm, file) {
-  return XPCOMUtils.generateModule([AboutFeeds]);
-}
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutFeeds]);
--- a/suite/shell/src/Makefile.in
+++ b/suite/shell/src/Makefile.in
@@ -8,17 +8,17 @@ include $(DEPTH)/config/autoconf.mk
 MODULE = shellservice
 FORCE_STATIC_LIB=1
 
 
 ifeq ($(OS_ARCH),WINNT)
 CPPSRCS = nsWindowsShellService.cpp
 OS_LIBS         += $(call EXPAND_LIBNAME,ole32 version uuid shell32)
 
-EXTRA_COMPONENTS = nsSetDefault.js
+EXTRA_COMPONENTS = nsSetDefault.manifest nsSetDefault.js
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT), cocoa)
 CPPSRCS = nsMacShellService.cpp
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
 CPPSRCS = nsGNOMEShellService.cpp
 endif
 endif
--- a/suite/shell/src/nsSetDefault.js
+++ b/suite/shell/src/nsSetDefault.js
@@ -70,27 +70,19 @@ nsSetDefault.prototype = {
     }
     else if (aCmdline.handleFlag("setDefaultFeed", false)) {
       var shell = Components.classes["@mozilla.org/suite/shell-service;1"]
                             .getService(nsIShellService);
       shell.setDefaultClient(true, true, nsIShellService.RSS);
     }
   },
 
-  helpInfo: "  -setDefaultBrowser   Set this app as the default browser client.\n" +
-            "  -setDefaultMail      Set this app as the default mail client.\n" +
-            "  -setDefaultNews      Set this app as the default newsreader.\n" +
-            "  -setDefaultFeed      Set this app as the default feedreader.\n",
+  helpInfo: "  -setDefaultBrowser Set this app as the default browser client.\n" +
+            "  -setDefaultMail    Set this app as the default mail client.\n" +
+            "  -setDefaultNews    Set this app as the default newsreader.\n" +
+            "  -setDefaultFeed    Set this app as the default feedreader.\n",
 
-  classDescription: "Set Default Suite Cmdline Handler",
-  contractID: "@mozilla.org/suite/default-browser-clh;1",
-  classID: Components.ID("{A3D5B950-690A-491F-A881-2C2CDCD241CB}"),
-  QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler]),
-   _xpcom_categories: [{
-     category: "command-line-handler",
-     entry: "m-setdefault"
-   }]
+  classID: Components.ID("{a3d5b950-690a-491f-a881-2c2cdcd241cb}"),
+  QueryInterface: XPCOMUtils.generateQI([nsICommandLineHandler])
 }
 
-function NSGetModule(compMgr, fileSpec) {
-  return XPCOMUtils.generateModule([nsSetDefault]);
-}
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsSetDefault]);
 
new file mode 100644
--- /dev/null
+++ b/suite/shell/src/nsSetDefault.manifest
@@ -0,0 +1,3 @@
+component {a3d5b950-690a-491f-a881-2c2cdcd241cb} nsSetDefault.js
+contract @mozilla.org/suite/default-browser-clh;1 {a3d5b950-690a-491f-a881-2c2cdcd241cb}
+category command-line-handler m-setdefault @mozilla.org/suite/default-browser-clh;1
--- a/suite/smile/src/Makefile.in
+++ b/suite/smile/src/Makefile.in
@@ -39,11 +39,13 @@ DEPTH     = ../../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = smile
 
+EXTRA_COMPONENTS = smileApplication.manifest
+
 EXTRA_PP_COMPONENTS = smileApplication.js
 
 include $(topsrcdir)/config/rules.mk
--- a/suite/smile/src/smileApplication.js
+++ b/suite/smile/src/smileApplication.js
@@ -314,19 +314,17 @@ function Application() {
   this.initToolkitHelpers();
   this._bookmarks = null;
 }
 
 //=================================================
 // Application implementation
 Application.prototype = {
   // for nsIClassInfo + XPCOMUtils
-  classDescription: "Application",
-  classID:          Components.ID("c9ba8f65-c936-4ac6-a859-8936832b0c12"),
-  contractID:       "@mozilla.org/smile/application;1",
+  classID:          Components.ID("{c9ba8f65-c936-4ac6-a859-8936832b0c12}"),
 
   // redefine the default factory for XPCOMUtils
   _xpcom_factory: ApplicationFactory,
 
   // for nsISupports
   QueryInterface : XPCOMUtils.generateQI(
                      [Components.interfaces.smileIApplication,
                       Components.interfaces.extIApplication,
@@ -372,16 +370,13 @@ Application.prototype = {
     return win;
   },
 
   get activeWindow() {
     return new Window(Utilities.windowMediator.getMostRecentWindow("navigator:browser"));
   }
 };
 
+#include ../../../mozilla/toolkit/components/exthelper/extApplication.js
+
 //module initialization
-function NSGetModule(aCompMgr, aFileSpec) {
-  // set the proto, defined in extApplication.js
-  Application.prototype.__proto__ = extApplication.prototype;
-  return XPCOMUtils.generateModule([Application]);
-}
-
-#include ../../../mozilla/toolkit/components/exthelper/extApplication.js
+Application.prototype.__proto__ = extApplication.prototype;
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([Application]);
new file mode 100644
--- /dev/null
+++ b/suite/smile/src/smileApplication.manifest
@@ -0,0 +1,3 @@
+component {c9ba8f65-c936-4ac6-a859-8936832b0c12} smileApplication.js
+contract @mozilla.org/smile/application;1 {c9ba8f65-c936-4ac6-a859-8936832b0c12}
+category JavaScript-global-privileged-property Application @mozilla.org/smile/application;1