Components.utils.import("resource://gre/modules/Services.jsm");
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cm = Components.manager;
Cm.QueryInterface(Ci.nsIComponentRegistrar);
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AddonManager.jsm");
const MY_URL = "resource://cclog-addon/";
Cm.QueryInterface(Ci.nsIComponentRegistrar);
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function AboutCC() {}
AboutCC.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
classDescription: "about:cc",
classID: Components.ID("{1b44f837-58e7-4f54-8542-413d13b6d61e}"),
contractID: "@mozilla.org/network/protocol/about;1?what=cc",
newChannel: function(uri)
{
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var html = 'data:text/html,
'
+ ''
+ ''
+ '';
try {
html += "" + uri.spec + "
";
} catch(ex) {
html += "" + ex + "
";
}
html += "";
html += "";
html += "";
var channel = ioService.newChannel(html, null, null);
var securityManager = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
var principal = securityManager.getSystemPrincipal();
channel.originalURI = uri;
channel.owner = principal;
return channel;
},
getURIFlags: function(uri)
{
return Ci.nsIAboutModule.ALLOW_SCRIPT;
}
}
const AboutCCFactory =
XPCOMUtils.generateNSGetFactory([AboutCC])(AboutCC.prototype.classID);
var global = this;
function startup(aData, aReason) {
let resource = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
let alias = Services.io.newFileURI(aData.installPath);
if (!aData.installPath.isDirectory())
alias = Services.io.newURI("jar:" + alias.spec + "!/", null, null);
resource.setSubstitution("cclog-addon", alias);
Cm.registerFactory(AboutCC.prototype.classID,
AboutCC.prototype.classDescription,
AboutCC.prototype.contractID,
AboutCCFactory);
}
function shutdown(aData, aReason) {
if (aReason == APP_SHUTDOWN) {
return;
}
let resource = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
resource.setSubstitution("cclog-addon", null);
Cm.unregisterFactory(AboutCC.prototype.classID,
AboutCCFactory);
}
function install(aData, aReason) { }
function uninstall(aData, aReason) { }