Commit 2e301c0a authored by Kathleen Brade's avatar Kathleen Brade
Browse files

Bug 22459: Adapt our use of the nsIContentPolicy to e10s mode

Load our content policy module as a process script instead of as a component
so that our nsIContentPolicy filter runs in content processes.

Our http-on-examine-response code that blocks redirects to internal URLs
must continue to run in the chrome process only.
parent cb0b9fda
......@@ -166,10 +166,6 @@ contract @torproject.org/domain-isolator;1 {e33fd6d4-270f-475f-a96f-ff3140279f68
category profile-after-change CookieJarSelector @torproject.org/cookie-jar-selector;1
component {4c03be7d-492f-990e-f0da-f3689e564898} components/content-policy.js
contract @torproject.org/content-policy;1 {4c03be7d-492f-990e-f0da-f3689e564898}
category content-policy ContentPolicy @torproject.org/content-policy;1
category profile-after-change StartupObserver @torproject.org/startup-observer;1
category profile-after-change DomainIsolator @torproject.org/domain-isolator;1
category profile-after-change ExtAppBlockerService @torproject.org/torbutton-extAppBlockerService;1
......@@ -22,13 +22,22 @@ function ContentPolicy() {
function (enabled) {
that.uriFingerprinting = enabled;
});
// Register as an nsIContentPolicy filter.
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(this.classID, this.classDescription,
this.contractID, this);
let catMan = Cc["@mozilla.org/categorymanager;1"]
.getService(Ci.nsICategoryManager);
catMan.addCategoryEntry("content-policy", this.contractID, this.contractID,
false, true);
}
ContentPolicy.prototype = {
classDescription: "ContentPolicy",
classID: Components.ID("{4c03be7d-492f-990e-f0da-f3689e564898}"),
contractID: "@torproject.org/content-policy;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy]),
uriWhitelist: {
// Video playback.
......@@ -51,6 +60,19 @@ ContentPolicy.prototype = {
"chrome://global/skin/dirListing/dirListing.css": Ci.nsIContentPolicy.TYPE_STYLESHEET,
},
// nsISupports
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy, Ci.nsIFactory,
Ci.nsISupportsWeakReference]),
// nsIFactory
createInstance: function(outer, iid)
{
if (outer)
throw Cr.NS_ERROR_NO_AGGREGATION;
return this.QueryInterface(iid);
},
// nsIContentPolicy
shouldLoad: function(aContentType, aContentLocation, aRequestOrigin, aContext, aMimeTypeGuess, aExtra) {
// Accept if the user does not care, no content URI is available or scheme
......@@ -121,8 +143,10 @@ var requestObserver = {
},
};
// Firefox >= 4.0 (Old versions are extremely irrelevant).
var NSGetFactory = XPCOMUtils.generateNSGetFactory([ContentPolicy]);
// Create a content policy object; initialization is done in the contructor.
var cp = new ContentPolicy();
// Register the request observer to handle redirects.
requestObserver.start();
// In the chrome process, register the request observer to handle redirects.
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_DEFAULT) {
requestObserver.start();
}
......@@ -60,6 +60,13 @@ function StartupObserver() {
} catch(e) {
this.logger.log(4, "Early proxy change failed. Will try again at profile load. Error: "+e);
}
// Arrange for our nsIContentPolicy filter to be loaded in the
// default (chrome) process as well as in each content process.
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIProcessScriptLoader);
ppmm.loadProcessScript("resource://torbutton/components/content-policy.js",
true);
}
StartupObserver.prototype = {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment