Revision control

Copy as Markdown

Other Tools

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const SCRIPT = Ci.nsIAboutModule.ALLOW_SCRIPT;
const UNTRUSTED = Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
const HIDE = Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT;
const INDEXEDDB = Ci.nsIAboutModule.ENABLE_INDEXED_DB;
function About() { }
About.prototype = {
Flags: SCRIPT,
blockedFlags: SCRIPT | UNTRUSTED | HIDE,
certerrorFlags: SCRIPT | UNTRUSTED | HIDE,
dataFlags: SCRIPT,
feedsFlags: SCRIPT | UNTRUSTED | HIDE,
lifeFlags: SCRIPT | UNTRUSTED | HIDE,
newserrorFlags: SCRIPT | HIDE,
privatebrowsingFlags: SCRIPT,
rightsFlags: SCRIPT | UNTRUSTED,
sessionrestoreFlags: SCRIPT | HIDE,
// synctabsFlags: SCRIPT,
classID: Components.ID("{d54f2c89-8fd6-4eeb-a7a4-51d4dcdf460f}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
getModule: function(aURI) {
return aURI.pathQueryRef.replace(/-|\W.*$/g, "").toLowerCase();
},
getURIFlags: function(aURI) {
return this[this.getModule(aURI) + "Flags"];
},
newChannel: function(aURI, aLoadInfo) {
let module = this.getModule(aURI);
let newURI = Services.io.newURI(this[module + "URI"]);
// We want a happy family which is always providing a loadInfo object.
if (!aLoadInfo) {
// Write out an error so that we have a stack and can fix the caller.
Cu.reportError('aLoadInfo was not provided in nsAbout.newChannel!');
}
let channel = aLoadInfo ?
Services.io.newChannelFromURIWithLoadInfo(newURI, aLoadInfo) :
Services.io.newChannelFromURI(newURI, null,
Services.scriptSecurityManager.getSystemPrincipal(),
null,
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
Ci.nsIContentPolicy.TYPE_OTHER);
channel.originalURI = aURI;
if (this[module + "Flags"] & UNTRUSTED) {
let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
channel.owner = principal;
}
return channel;
},
};
var NSGetFactory = XPCOMUtils.generateNSGetFactory([About]);