Bug 1138649 - Update remaining callsites to use newChannel2 in toolkit/components (r=gijs,billm)

This commit is contained in:
Christoph Kerschbaumer 2015-03-12 11:27:17 -07:00
parent 552564bf56
commit daaff1a374
5 changed files with 53 additions and 11 deletions

View File

@ -203,11 +203,14 @@ let ContentPolicyChild = {
// This is a shim channel whose only purpose is to return some string // This is a shim channel whose only purpose is to return some string
// data from an about: protocol handler. // data from an about: protocol handler.
function AboutProtocolChannel(uri, contractID) function AboutProtocolChannel(uri, contractID, loadInfo)
{ {
this.URI = uri; this.URI = uri;
this.originalURI = uri; this.originalURI = uri;
this._contractID = contractID; this._contractID = contractID;
this._loadingPrincipal = loadInfo.loadingPrincipal;
this._securityFlags = loadInfo.securityFlags;
this._contentPolicyType = loadInfo.contentPolicyType;
} }
AboutProtocolChannel.prototype = { AboutProtocolChannel.prototype = {
@ -227,7 +230,10 @@ AboutProtocolChannel.prototype = {
.getService(Ci.nsISyncMessageSender); .getService(Ci.nsISyncMessageSender);
let rval = cpmm.sendRpcMessage("Addons:AboutProtocol:OpenChannel", { let rval = cpmm.sendRpcMessage("Addons:AboutProtocol:OpenChannel", {
uri: this.URI.spec, uri: this.URI.spec,
contractID: this._contractID contractID: this._contractID,
loadingPrincipal: this._loadingPrincipal,
securityFlags: this._securityFlags,
contentPolicyType: this._contentPolicyType
}, { }, {
notificationCallbacks: this.notificationCallbacks, notificationCallbacks: this.notificationCallbacks,
loadGroupNotificationCallbacks: this.loadGroup ? this.loadGroup.notificationCallbacks : null, loadGroupNotificationCallbacks: this.loadGroup ? this.loadGroup.notificationCallbacks : null,
@ -327,8 +333,8 @@ AboutProtocolInstance.prototype = {
// available to CPOWs. Consequently, we return a shim channel that, // available to CPOWs. Consequently, we return a shim channel that,
// when opened, asks the parent to open the channel and read out all // when opened, asks the parent to open the channel and read out all
// the data. // the data.
newChannel: function(uri) { newChannel: function(uri, loadInfo) {
return new AboutProtocolChannel(uri, this._contractID); return new AboutProtocolChannel(uri, this._contractID, loadInfo);
}, },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory, Ci.nsIAboutModule]) QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory, Ci.nsIAboutModule])

View File

@ -248,9 +248,19 @@ let AboutProtocolParent = {
let uri = BrowserUtils.makeURI(msg.data.uri); let uri = BrowserUtils.makeURI(msg.data.uri);
let contractID = msg.data.contractID; let contractID = msg.data.contractID;
let module = Cc[contractID].getService(Ci.nsIAboutModule); let loadingPrincipal = msg.data.loadingPrincipal;
let securityFlags = msg.data.securityFlags;
let contentPolicyType = msg.data.contentPolicyType;
try { try {
let channel = module.newChannel(uri, null); let channel = NetUtil.newChannel2(uri,
null,
null,
null, // aLoadingNode
loadingPrincipal,
null, // aTriggeringPrincipal
securityFlags,
contentPolicyType);
// We're not allowed to set channel.notificationCallbacks to a // We're not allowed to set channel.notificationCallbacks to a
// CPOW, since the setter for notificationCallbacks is in C++, // CPOW, since the setter for notificationCallbacks is in C++,
// which can't tolerate CPOWs. Instead we just use a JS object // which can't tolerate CPOWs. Instead we just use a JS object

View File

@ -11,6 +11,8 @@
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var Cc = SpecialPowers.Cc; var Cc = SpecialPowers.Cc;
var Ci = SpecialPowers.Ci;
var systemPrincipal = SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal();
testNum = 1; testNum = 1;
@ -35,7 +37,14 @@
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var pps = Cc["@mozilla.org/network/protocol-proxy-service;1"].getService(); var pps = Cc["@mozilla.org/network/protocol-proxy-service;1"].getService();
var channel = ios.newChannel("http://example.com", null, null); var channel = ios.newChannel2("http://example.com",
null,
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
pps.asyncResolve(channel, 0, resolveCallback); pps.asyncResolve(channel, 0, resolveCallback);
} }

View File

@ -26,6 +26,7 @@ var tmplogin, login1, login2A, login2B, login2C, login2D, login2E, login3A, logi
var mozproxy, proxiedHost = "http://mochi.test:8888"; var mozproxy, proxiedHost = "http://mochi.test:8888";
var proxyChannel; var proxyChannel;
var testNum = 1; var testNum = 1;
var systemPrincipal = SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal();
function initLogins(pi) { function initLogins(pi) {
observerService = Cc["@mozilla.org/observer-service;1"]. observerService = Cc["@mozilla.org/observer-service;1"].
@ -163,8 +164,7 @@ var resolveCallback = SpecialPowers.wrapCallbackObject({
null, null,
null, null,
null, // aLoadingNode null, // aLoadingNode
SpecialPowers.Services. systemPrincipal,
scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL, Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER); Ci.nsIContentPolicy.TYPE_OTHER);
@ -179,7 +179,14 @@ function startup() {
var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"].getService(); var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"].getService();
var channel = ios.newChannel("http://example.com", null, null); var channel = ios.newChannel2("http://example.com",
null,
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
pps.asyncResolve(channel, 0, resolveCallback); pps.asyncResolve(channel, 0, resolveCallback);
} }

View File

@ -146,7 +146,17 @@
var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"] var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"]
.getService(); .getService();
var channel = ios.newChannel("http://example.com", null, null); var systemPrincipal = SpecialPowers.Services.scriptSecurityManager
.getSystemPrincipal();
var channel = ios.newChannel2("http://example.com",
null,
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
pps.asyncResolve(channel, 0, resolveCallback); pps.asyncResolve(channel, 0, resolveCallback);
} }