Bug 1115572 - Add newChannel2 (that takes loadinfo as an argument) to suite protocol handlers r=Neil

This commit is contained in:
Philip Chee 2015-01-03 04:26:04 +08:00
Родитель 2aaf3b6157
Коммит cc0a25f7a9
3 изменённых файлов: 17 добавлений и 6 удалений

Просмотреть файл

@ -44,9 +44,16 @@ About.prototype = {
return this[this.getModule(aURI) + "Flags"];
},
newChannel: function(aURI, aLoadInfo) {
newChannel: function(aURI) {
return this.newChannel2(aURI, null);
},
newChannel2: function(aURI, aLoadInfo) {
var module = this.getModule(aURI);
var channel = Services.io.newChannel(this[module + "URI"], null, null);
var newURI = Services.io.newURI(this[module + "URI"], null, null);
var channel = aLoadInfo ?
Services.io.newChannelFromURIWithLoadInfo(newURI, aLoadInfo) :
Services.io.newChannelFromURI(newURI);
channel.originalURI = aURI;
if (this[module + "Flags"] & UNTRUSTED)
channel.owner = null;

Просмотреть файл

@ -46,10 +46,12 @@ GopherProtocol.prototype = {
},
newChannel2: function GP_newChannel2(inputURI, loadinfo) {
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var newURI = ios.newURI("chrome://communicator/content/gopherAddon.xhtml", null, null);
// Create a chrome channel, and de-chrome it, to our information page.
var chan = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.newChannel("chrome://communicator/content/gopherAddon.xhtml", null, null);
var chan = loadinfo ? ios.newChannelFromURIWithLoadInfo(newURI, loadinfo) :
ios.newChannelFromURI(newURI);
chan.originalURI = inputURI;
chan.owner = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager)

Просмотреть файл

@ -515,7 +515,9 @@ GenericProtocolHandler.prototype = {
newChannel2: function newChannel(aUri, aLoadinfo) {
var uri = aUri.QueryInterface(Components.interfaces.nsINestedURI).innerURI;
var channel = Services.io.newChannelFromURI(uri);
var channel = aLoadinfo ?
Services.io.newChannelFromURIWithLoadInfo(uri, aLoadinfo) :
Services.io.newChannelFromURI(uri);
if (channel instanceof Components.interfaces.nsIHttpChannel)
// Set this so we know this is supposed to be a feed
channel.setRequestHeader("X-Moz-Is-Feed", "1", false);