mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-21 22:57:31 +09:00
Make JS callers of ios.newChannel call ios.newChannel2 in browser/
This commit is contained in:
parent
e37a6016b9
commit
53f6a692d3
2 changed files with 44 additions and 28 deletions
|
|
@ -1116,10 +1116,17 @@ nsContextMenu.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up a channel to do the saving
|
// setting up a new channel for 'right click - save link as ...'
|
||||||
var ioService = Cc["@mozilla.org/network/io-service;1"].
|
// ideally we should use:
|
||||||
getService(Ci.nsIIOService);
|
// * doc - as the loadingNode, and/or
|
||||||
var channel = ioService.newChannelFromURI(makeURI(linkURL));
|
// * this.principal - as the loadingPrincipal
|
||||||
|
// for now lets use systemPrincipal to bypass mixedContentBlocker
|
||||||
|
// checks after redirects, see bug: 1136055
|
||||||
|
var channel = NetUtil.newChannel({
|
||||||
|
uri: makeURI(linkURL),
|
||||||
|
loadUsingSystemPrincipal: true
|
||||||
|
});
|
||||||
|
|
||||||
if (linkDownload)
|
if (linkDownload)
|
||||||
channel.contentDispositionFilename = linkDownload;
|
channel.contentDispositionFilename = linkDownload;
|
||||||
if (channel instanceof Ci.nsIPrivateBrowsingChannel) {
|
if (channel instanceof Ci.nsIPrivateBrowsingChannel) {
|
||||||
|
|
@ -1152,7 +1159,7 @@ nsContextMenu.prototype = {
|
||||||
timer.TYPE_ONE_SHOT);
|
timer.TYPE_ONE_SHOT);
|
||||||
|
|
||||||
// kick off the channel with our proxy object as the listener
|
// kick off the channel with our proxy object as the listener
|
||||||
channel.asyncOpen(new saveAsListener(), null);
|
channel.asyncOpen2(new saveAsListener());
|
||||||
},
|
},
|
||||||
|
|
||||||
// Save URL of clicked-on link.
|
// Save URL of clicked-on link.
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,6 @@ const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//// Various utility properties
|
//// Various utility properties
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "ioSvc",
|
|
||||||
"@mozilla.org/network/io-service;1",
|
|
||||||
"nsIIOService");
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "imgTools",
|
XPCOMUtils.defineLazyServiceGetter(this, "imgTools",
|
||||||
"@mozilla.org/image/tools;1",
|
"@mozilla.org/image/tools;1",
|
||||||
"imgITools");
|
"imgITools");
|
||||||
|
|
@ -73,8 +70,13 @@ XPCOMUtils.defineLazyServiceGetter(this, "faviconSvc",
|
||||||
"nsIFaviconService");
|
"nsIFaviconService");
|
||||||
|
|
||||||
// nsIURI -> imgIContainer
|
// nsIURI -> imgIContainer
|
||||||
function _imageFromURI(uri, privateMode, callback) {
|
function _imageFromURI(doc, uri, privateMode, callback) {
|
||||||
let channel = ioSvc.newChannelFromURI(uri);
|
let channel = NetUtil.newChannel({
|
||||||
|
uri: uri,
|
||||||
|
loadUsingSystemPrincipal: true,
|
||||||
|
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
channel.QueryInterface(Ci.nsIPrivateBrowsingChannel);
|
channel.QueryInterface(Ci.nsIPrivateBrowsingChannel);
|
||||||
channel.setPrivate(privateMode);
|
channel.setPrivate(privateMode);
|
||||||
|
|
@ -93,17 +95,17 @@ function _imageFromURI(uri, privateMode, callback) {
|
||||||
// favicon).
|
// favicon).
|
||||||
let defaultURI = faviconSvc.defaultFavicon;
|
let defaultURI = faviconSvc.defaultFavicon;
|
||||||
if (!defaultURI.equals(uri))
|
if (!defaultURI.equals(uri))
|
||||||
_imageFromURI(defaultURI, callback);
|
_imageFromURI(doc, defaultURI, privateMode, callback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// string? -> imgIContainer
|
// string? -> imgIContainer
|
||||||
function getFaviconAsImage(iconurl, privateMode, callback) {
|
function getFaviconAsImage(doc, iconurl, privateMode, callback) {
|
||||||
if (iconurl)
|
if (iconurl)
|
||||||
_imageFromURI(NetUtil.newURI(iconurl), privateMode, callback);
|
_imageFromURI(doc, NetUtil.newURI(iconurl), privateMode, callback);
|
||||||
else
|
else
|
||||||
_imageFromURI(faviconSvc.defaultFavicon, privateMode, callback);
|
_imageFromURI(doc, faviconSvc.defaultFavicon, privateMode, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Snaps the given rectangle to be pixel-aligned at the given scale
|
// Snaps the given rectangle to be pixel-aligned at the given scale
|
||||||
|
|
@ -460,7 +462,11 @@ TabWindow.prototype = {
|
||||||
preview.visible = AeroPeek.enabled;
|
preview.visible = AeroPeek.enabled;
|
||||||
preview.active = this.tabbrowser.selectedTab == controller.tab;
|
preview.active = this.tabbrowser.selectedTab == controller.tab;
|
||||||
// Grab the default favicon
|
// Grab the default favicon
|
||||||
getFaviconAsImage(null, PrivateBrowsingUtils.isWindowPrivate(this.win), function (img) {
|
getFaviconAsImage(
|
||||||
|
controller.linkedBrowser.contentWindow.document,
|
||||||
|
null,
|
||||||
|
PrivateBrowsingUtils.isWindowPrivate(this.win),
|
||||||
|
function (img) {
|
||||||
// It is possible that we've already gotten the real favicon, so make sure
|
// It is possible that we've already gotten the real favicon, so make sure
|
||||||
// we have not set one before setting this default one.
|
// we have not set one before setting this default one.
|
||||||
if (!preview.icon)
|
if (!preview.icon)
|
||||||
|
|
@ -552,7 +558,10 @@ TabWindow.prototype = {
|
||||||
//// Browser progress listener
|
//// Browser progress listener
|
||||||
onLinkIconAvailable: function (aBrowser, aIconURL) {
|
onLinkIconAvailable: function (aBrowser, aIconURL) {
|
||||||
let self = this;
|
let self = this;
|
||||||
getFaviconAsImage(aIconURL, PrivateBrowsingUtils.isWindowPrivate(this.win), function (img) {
|
getFaviconAsImage(
|
||||||
|
aBrowser.contentWindow.document,
|
||||||
|
aIconURL,PrivateBrowsingUtils.isWindowPrivate(this.win),
|
||||||
|
function (img) {
|
||||||
let index = self.tabbrowser.browsers.indexOf(aBrowser);
|
let index = self.tabbrowser.browsers.indexOf(aBrowser);
|
||||||
// Only add it if we've found the index. The tab could have closed!
|
// Only add it if we've found the index. The tab could have closed!
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue