diff --git a/mozilla/toolkit/components/contentprefs/src/nsContentPrefService.js b/mozilla/toolkit/components/contentprefs/src/nsContentPrefService.js index 28f851828af..52f3749ab80 100755 --- a/mozilla/toolkit/components/contentprefs/src/nsContentPrefService.js +++ b/mozilla/toolkit/components/contentprefs/src/nsContentPrefService.js @@ -39,22 +39,9 @@ const Cc = Components.classes; const Cr = Components.results; const Cu = Components.utils; -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - -function ContentPrefService() { - this._init(); -} +function ContentPrefService() {} ContentPrefService.prototype = { - //**************************************************************************// - // XPCOM Plumbing - - classDescription: "Content Pref Service", - classID: Components.ID("{e6a3f533-4ffa-4615-8eb4-d4e72d883fa7}"), - contractID: "@mozilla.org/content-pref/service;1", - QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPrefService]), - - //**************************************************************************// // Convenience Getters @@ -106,6 +93,18 @@ ContentPrefService.prototype = { }, + //**************************************************************************// + // nsISupports + + _interfaces: [Ci.nsIContentPrefService, Ci.nsISupports], + + QueryInterface: function ContentPrefService_QueryInterface(aIID) { + if (!this._interfaces.some( function(v) { return aIID.equals(v) } )) + throw Cr.NS_ERROR_NO_INTERFACE; + return this; + }, + + //**************************************************************************// // nsIObserver @@ -849,13 +848,17 @@ ContentPrefService.prototype = { function HostnameGrouper() {} HostnameGrouper.prototype = { + //**************************************************************************// - // XPCOM Plumbing - - classDescription: "Hostname Grouper", - classID: Components.ID("{8df290ae-dcaa-4c11-98a5-2429a4dc97bb}"), - contractID: "@mozilla.org/content-pref/hostname-grouper;1", - QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentURIGrouper]), + // nsISupports + + _interfaces: [Ci.nsIContentURIGrouper, Ci.nsISupports], + + QueryInterface: function HostnameGrouper_QueryInterface(aIID) { + if (!this._interfaces.some( function(v) { return aIID.equals(v) } )) + throw Components.results.NS_ERROR_NO_INTERFACE; + return this; + }, //**************************************************************************// @@ -901,10 +904,70 @@ HostnameGrouper.prototype = { }; -//****************************************************************************// -// XPCOM Plumbing +var gModule = { + registerSelf: function(aComponentManager, aFileSpec, aLocation, aType) { + aComponentManager = aComponentManager.QueryInterface(Ci.nsIComponentRegistrar); + + for (var key in this._objects) { + var obj = this._objects[key]; + aComponentManager.registerFactoryLocation(obj.CID, + obj.className, + obj.contractID, + aFileSpec, + aLocation, + aType); + } + }, + + unregisterSelf: function(aComponentManager, aFileSpec, aLocation) {}, -var components = [ContentPrefService, HostnameGrouper]; -function NSGetModule(compMgr, fileSpec) { - return XPCOMUtils.generateModule(components); + getClassObject: function(aComponentManager, aCID, aIID) { + if (!aIID.equals(Components.interfaces.nsIFactory)) + throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + + for (var key in this._objects) { + if (aCID.equals(this._objects[key].CID)) + return this._objects[key].factory; + } + + throw Components.results.NS_ERROR_NO_INTERFACE; + }, + + _objects: { + service: { + CID : Components.ID("{e6a3f533-4ffa-4615-8eb4-d4e72d883fa7}"), + contractID : "@mozilla.org/content-pref/service;1", + className : "Content Pref Service", + factory : ContentPrefServiceFactory = { + createInstance: function(aOuter, aIID) { + if (aOuter != null) + throw Components.results.NS_ERROR_NO_AGGREGATION; + var service = new ContentPrefService(); + service._init(); + return service.QueryInterface(aIID); + } + } + }, + grouper: { + CID : Components.ID("{8df290ae-dcaa-4c11-98a5-2429a4dc97bb}"), + contractID : "@mozilla.org/content-pref/hostname-grouper;1", + className : "Hostname Grouper", + factory : HostnameGrouperFactory = { + createInstance: function(aOuter, aIID) { + if (aOuter != null) + throw Components.results.NS_ERROR_NO_AGGREGATION; + var grouper = new HostnameGrouper(); + return grouper.QueryInterface(aIID); + } + } + } + }, + + canUnload: function(aComponentManager) { + return true; + } +}; + +function NSGetModule(aComponentManager, aFileSpec) { + return gModule; }