1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
/**
* (C) Copyright 2008 Jeremy Maitin-Shepard
* (C) Copyright 2011 John Foerch
*
* Use, modification, and distribution are subject to the terms specified in the
* COPYING file.
**/
// Register the Conkeror download_helper
const classID = Components.ID("{74FCB100-B972-11DC-95FF-0800200C9A66}");
const classDescription = "Unknown Content Type Dialog";
const contractID = "@mozilla.org/helperapplauncherdialog;1";
var module = {
/* This firstTime trick is used to delay the registration. This
* is needed to ensure it overrides the built-in component for the
* same contractID (the built-in nsHelperAppDlg.js being
* overridden uses this as well, and as a result we have to). */
/* http://dietrich.ganx4.com/blog/?p=221#comment-14 */
/* https://bugzilla.mozilla.org/show_bug.cgi?id=253125 */
/* https://bugzilla.mozilla.org/show_bug.cgi?id=253136 */
/* We can't use XPCOMUtils because that doesn't provide this delay
* trick. */
prevTimes: 0,
// registerSelf: Register this component.
registerSelf: function (compMgr, fileSpec, location, type) {
if (this.prevTimes < 2) {
this.prevTimes++;
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
}
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation( classID,
classDescription,
contractID,
fileSpec,
location,
type );
},
// getClassObject: Return this component's factory object.
getClassObject: function (compMgr, cid, iid) {
if (!cid.equals(classID)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
if (!iid.equals(Components.interfaces.nsIFactory)) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
}
return this.factory;
},
/* factory object */
factory: {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
/* Return an instance of the Conkeror-scope download_helper object. */
var conkeror = Components.classes["@conkeror.mozdev.org/application;1"].getService().wrappedJSObject;
return (new conkeror.download_helper()).QueryInterface(iid);
}
},
canUnload: function(compMgr) { return true; }
};
function NSGetFactory (cid) { // XULRunner 2.0
return module.factory;
}
function NSGetModule(compMgr, fileSpec) {
return module;
}
|