Skip to content
Browse files

Temporary workaround/revert for component registration in Gecko 1.9.

  • Loading branch information...
1 parent 01006b6 commit dbb69bc67fca25a6a8a9e9e734bb443506d333e8 @bard bard committed
Showing with 59 additions and 7 deletions.
  1. +59 −7 components/MozRepl.js
View
66 components/MozRepl.js
@@ -39,11 +39,63 @@ MozRepl.prototype = {
};
loader.loadSubScript(SOURCE, MozRepl.prototype);
-/**
-* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
-* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
-*/
-if (XPCOMUtils.generateNSGetFactory)
+if (XPCOMUtils.generateNSGetFactory) /* Gecko 2 */
var NSGetFactory = XPCOMUtils.generateNSGetFactory([MozRepl]);
-else
- var NSGetModule = XPCOMUtils.generateNSGetModule([MozRepl]);
+else { /* Gecko 1.9.2 */
+ // The following line, contrary to what the documentation says,
+ // does not appear to work, so we use the old verbiage.
+ //
+ // var NSGetModule = XPCOMUtils.generateNSGetModule([MozRepl]);
+
+ var Factory = {
+ createInstance: function(aOuter, aIID) {
+ if(aOuter != null)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ var component = new MozRepl();
+
+ return component.QueryInterface(aIID);
+ }
+ };
+
+ var Module = {
+ _firstTime: true,
+
+ registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) {
+ if (this._firstTime) {
+ this._firstTime = false;
+ throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
+ };
+
+ aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
+ aCompMgr.registerFactoryLocation(
+ CLASS_ID, CLASS_NAME, CONTRACT_ID, aFileSpec, aLocation, aType);
+
+ var catMan = Cc['@mozilla.org/categorymanager;1'].
+ getService(Ci.nsICategoryManager);
+ catMan.addCategoryEntry('app-startup', 'MozRepl', 'service,' + CONTRACT_ID, true, true);
+ },
+
+ unregisterSelf: function(aCompMgr, aLocation, aType) {pp
+ aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
+ aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
+
+ var catMan = Cc['@mozilla.org/categorymanager;1'].
+ getService(Ci.nsICategoryManager);
+ catMan.deleteCategoryEntry('app-startup', 'service,' + CONTRACT_ID, true);
+ },
+
+ getClassObject: function(aCompMgr, aCID, aIID) {
+ if (!aIID.equals(Ci.nsIFactory))
+ throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+
+ if (aCID.equals(CLASS_ID))
+ return Factory;
+
+ throw Cr.NS_ERROR_NO_INTERFACE;
+ },
+
+ canUnload: function(aCompMgr) { return true; }
+ };
+
+ var NSGetModule = function(aCompMgr, aFileSpec) { return Module; }
+}

0 comments on commit dbb69bc

Please sign in to comment.
Something went wrong with that request. Please try again.