Bug 1232901 - Use channel.asyncOpen2 within dom/browser-element/BrowserElementParent.js (r=sicking,aus)

This commit is contained in:
Christoph Kerschbaumer 2016-02-10 13:58:08 -08:00
parent 8a445d8fdb
commit 54fea4cb15

View File

@ -15,6 +15,7 @@ var Cr = Components.results;
*/
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/BrowserElementPromptService.jsm");
@ -1001,36 +1002,17 @@ BrowserElementParent.prototype = {
Ci.nsIRequestObserver])
};
// If we have a URI we'll use it to get the triggering principal to use,
// if not available a null principal is acceptable.
let referrer = null;
let principal = null;
if (_options.referrer) {
// newURI can throw on malformed URIs.
try {
referrer = Services.io.newURI(_options.referrer, null, null);
}
catch(e) {
debug('Malformed referrer -- ' + e);
}
let referrer = Services.io.newURI(_options.referrer, null, null);
let principal =
Services.scriptSecurityManager.createCodebasePrincipal(
referrer, this._frameLoader.loadContext.originAttributes);
// This simply returns null if there is no principal available
// for the requested uri. This is an acceptable fallback when
// calling newChannelFromURI2.
principal =
Services.scriptSecurityManager.createCodebasePrincipal(
referrer, this._frameLoader.loadContext.originAttributes);
}
debug('Using principal? ' + !!principal);
let channel =
Services.io.newChannelFromURI2(url,
null, // No document.
principal, // Loading principal
principal, // Triggering principal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: url,
loadingPrincipal: principal,
securityFlags: SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER
});
// XXX We would set private browsing information prior to calling this.
channel.notificationCallbacks = interfaceRequestor;
@ -1055,7 +1037,7 @@ BrowserElementParent.prototype = {
}
// Set-up complete, let's get things started.
channel.asyncOpen(new DownloadListener(), null);
channel.asyncOpen2(new DownloadListener());
return req;
},