Bug 682808 - Improve the way nsIClassInfo is handled in components (Port bug 658632 to SeaMonkey). r=Neil a=IanN
authorJustin Wood <Callek@gmail.com>
Sun, 18 Sep 2011 17:44:05 -0400
changeset 8841 bc61f0aededfc644399a276733f60cdb6a64323b
parent 8840 af0063799d09d6122858efff753d337b224eb221
child 8842 b59fbda1674f14ba3c88e6a3e9e24240b5a44987
push idunknown
push userunknown
push dateunknown
reviewersNeil, IanN
bugs682808, 658632
Bug 682808 - Improve the way nsIClassInfo is handled in components (Port bug 658632 to SeaMonkey). r=Neil a=IanN
suite/common/src/nsSidebar.js
suite/feeds/src/FeedWriter.js
suite/feeds/src/WebContentConverter.js
--- a/suite/common/src/nsSidebar.js
+++ b/suite/common/src/nsSidebar.js
@@ -50,27 +50,27 @@
  * (Though ANSI C++ provides exceptions, they are verboten in Mozilla code
  * for portability reasons -- and even when you're building completely
  * platform-specific code, you can't throw across an XPCOM method boundary.)
  */
 
 const DEBUG = false; /* set to false to suppress debug messages */
 const PANELS_RDF_FILE  = "UPnls"; /* directory services property to find panels.rdf */
 
+const SIDEBAR_CONTRACTID   = "@mozilla.org/sidebar;1";
 const SIDEBAR_CID      = Components.ID("{22117140-9c6e-11d3-aaf1-00805f8a4905}");
 const CONTAINER_CONTRACTID = "@mozilla.org/rdf/container;1";
 const NETSEARCH_CONTRACTID = "@mozilla.org/rdf/datasource;1?name=internetsearch"
 const nsISupports      = Components.interfaces.nsISupports;
 const nsISidebar       = Components.interfaces.nsISidebar;
 const nsISidebarExternal = Components.interfaces.nsISidebarExternal;
 const nsIRDFContainer  = Components.interfaces.nsIRDFContainer;
 const nsIProperties    = Components.interfaces.nsIProperties;
 const nsIFileURL       = Components.interfaces.nsIFileURL;
 const nsIRDFRemoteDataSource = Components.interfaces.nsIRDFRemoteDataSource;
-const nsIClassInfo = Components.interfaces.nsIClassInfo;
 
 // File extension for Sherlock search plugin description files
 const SHERLOCK_FILE_EXT_REGEXP = /\.src$/i;
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function nsSidebar()
@@ -328,34 +328,25 @@ function (aDescriptionURL)
 // http://msdn.microsoft.com/en-us/library/aa342526%28VS.85%29.aspx .
 // XXX Implement this!
 nsSidebar.prototype.IsSearchProviderInstalled =
 function (aSearchURL)
 {
   return 0;
 }
 
-// property of nsIClassInfo
-nsSidebar.prototype.flags = nsIClassInfo.DOM_OBJECT;
-
-// property of nsIClassInfo
-nsSidebar.prototype.classDescription = "Sidebar";
-
-// method of nsIClassInfo
-nsSidebar.prototype.getInterfaces = function(count) {
-    var interfaceList = [nsISidebar, nsISidebarExternal, nsIClassInfo];
-    count.value = interfaceList.length;
-    return interfaceList;
-}
-
-// method of nsIClassInfo
-nsSidebar.prototype.getHelperForLanguage = function(count) {return null;}
+nsSidebar.prototype.classInfo = XPCOMUtils.generateCI({
+    classID: SIDEBAR_CID,
+    contractID: SIDEBAR_CONTRACTID,
+    classDescription: "Sidebar",
+    interfaces: [nsISidebar, nsISidebarExternal],
+    flags: nsIClassInfo.DOM_OBJECT});
 
 nsSidebar.prototype.QueryInterface =
-    XPCOMUtils.generateQI([nsISidebar, nsISidebarExternal, nsIClassInfo]);
+    XPCOMUtils.generateQI([nsISidebar, nsISidebarExternal]);
 
 nsSidebar.prototype.classID = SIDEBAR_CID;
 
 var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsSidebar]);
 
 /* static functions */
 if (DEBUG)
     debug = function (s) { dump("-*- sidebar component: " + s + "\n"); }
--- a/suite/feeds/src/FeedWriter.js
+++ b/suite/feeds/src/FeedWriter.js
@@ -38,16 +38,19 @@
  * 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 FEEDWRITER_CID = Components.ID("{49bb6593-3aff-4eb3-a068-2712c28bd58e}");
+const FEEDWRITER_CONTRACTID = "@mozilla.org/browser/feeds/result-writer;1";
+
 const XML_NS = "http://www.w3.org/XML/1998/namespace";
 const HTML_NS = "http://www.w3.org/1999/xhtml";
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
 const TYPE_MAYBE_AUDIO_FEED = "application/vnd.mozilla.maybe.audio.feed";
 const TYPE_MAYBE_VIDEO_FEED = "application/vnd.mozilla.maybe.video.feed";
 const STRING_BUNDLE_URI = "chrome://communicator/locale/feeds/subscribe.properties";
 const SUBSCRIBE_PAGE_URI = "chrome://communicator/content/feeds/subscribe.xhtml";
@@ -1374,30 +1377,21 @@ FeedWriter.prototype = {
           var codeStr = "menuItem.setAttribute('image', dataURL);";
           Components.utils.evalInSandbox(codeStr, self._contentSandbox);
           self._contentSandbox.menuItem = null;
           self._contentSandbox.dataURL = null;
         }
       });
   },
 
-  // nsIClassInfo
-  getInterfaces: function getInterfaces(countRef) {
-    var interfaces = [Components.interfaces.nsIFeedWriter,
-                       Components.interfaces.nsIClassInfo,
-                       Components.interfaces.nsISupports];
-    countRef.value = interfaces.length;
-    return interfaces;
-  },
-
-  getHelperForLanguage: function getHelperForLanguage(language) null,
-  classID: Components.ID("{49bb6593-3aff-4eb3-a068-2712c28bd58e}"),
-  implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
-  flags: Components.interfaces.nsIClassInfo.DOM_OBJECT,
+  classID: FEEDWRITER_CID,
+  classInfo: XPCOMUtils.generateCI({classID: FEEDWRITER_CID,
+                                    contractID: FEEDWRITER_CONTRACTID,
+                                    interfaces: [Components.interfaces.nsIFeedWriter],
+                                    flags: Components.interfaces.nsIClassInfo.DOM_OBJECT})
   QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIFeedWriter,
-                                          Components.interfaces.nsIClassInfo,
                                           Components.interfaces.nsIDOMEventListener,
                                           Components.interfaces.nsINavHistoryObserver,
                                           Components.interfaces.nsIObserver])
 
 };
 
 var NSGetFactory = XPCOMUtils.generateNSGetFactory([FeedWriter]);
--- a/suite/feeds/src/WebContentConverter.js
+++ b/suite/feeds/src/WebContentConverter.js
@@ -841,43 +841,29 @@ WebContentConverterRegistrar.prototype =
    * See nsIFactory
    */
   createInstance: function createInstance(outer, iid) {
     if (outer != null)
       throw Components.results.NS_ERROR_NO_AGGREGATION;
     return this.QueryInterface(iid);
   },
 
-  /**
-   * See nsIClassInfo
-   */
-  getInterfaces: function getInterfaces(countRef) {
-    var interfaces = [Components.interfaces.nsIWebContentConverterService,
-                      Components.interfaces.nsIWebContentHandlerRegistrar,
-                      Components.interfaces.nsIObserver,
-                      Components.interfaces.nsIClassInfo,
-                      Components.interfaces.nsIFactory,
-                      Components.interfaces.nsISupports];
-    countRef.value = interfaces.length;
-    return interfaces;
-  },
-
- getHelperForLanguage: function getHelperForLanguage(language) {
-    return null;
-  },
-
   classID: WCCR_CLASSID,
-  implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
-  flags: Components.interfaces.nsIClassInfo.DOM_OBJECT,
+  classInfo: XPCOMUtils.generateCI({
+	  classID: WCCR_CLASSID,
+	  contractID: WCCR_CONTRACTID,
+      interfaces: [Components.interfaces.nsIWebContentConverterService,
+                   Components.interfaces.nsIWebContentHandlerRegistrar,
+                   Components.interfaces.nsIObserver,
+                   Components.interfaces.nsIFactory],
+      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])
+     Components.interfaces.nsIFactory])
 };
 
 var NSGetFactory = XPCOMUtils.generateNSGetFactory([WebContentConverterRegistrar]);