summaryrefslogtreecommitdiffstats
path: root/application/palemoon/base/content/nsContextMenu.js
diff options
context:
space:
mode:
Diffstat (limited to 'application/palemoon/base/content/nsContextMenu.js')
-rw-r--r--application/palemoon/base/content/nsContextMenu.js51
1 files changed, 36 insertions, 15 deletions
diff --git a/application/palemoon/base/content/nsContextMenu.js b/application/palemoon/base/content/nsContextMenu.js
index 8e6bc96c2..017ab87cc 100644
--- a/application/palemoon/base/content/nsContextMenu.js
+++ b/application/palemoon/base/content/nsContextMenu.js
@@ -265,7 +265,7 @@ nsContextMenu.prototype = {
// Hide menu entries for images, show otherwise
if (this.inFrame) {
- if (mimeTypeIsTextBased(this.target.ownerDocument.contentType))
+ if (BrowserUtils.mimeTypeIsTextBased(this.target.ownerDocument.contentType))
this.isFrameImage.removeAttribute('hidden');
else
this.isFrameImage.setAttribute('hidden', 'true');
@@ -422,12 +422,17 @@ nsContextMenu.prototype = {
},
inspectNode: function CM_inspectNode() {
- let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+ let {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {});
let gBrowser = this.browser.ownerDocument.defaultView.gBrowser;
- let tt = devtools.TargetFactory.forTab(gBrowser.selectedTab);
- return gDevTools.showToolbox(tt, "inspector").then(function(toolbox) {
+ let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
+
+ return gDevTools.showToolbox(target, "inspector").then(function(toolbox) {
let inspector = toolbox.getCurrentPanel();
- inspector.selection.setNode(this.target, "browser-context-menu");
+
+ this.browser.messageManager.sendAsyncMessage("debug:inspect", {}, {node: this.target});
+ inspector.walker.findInspectingNode().then(nodeFront => {
+ inspector.selection.setNodeFront(nodeFront, "browser-context-menu");
+ });
}.bind(this));
},
@@ -906,6 +911,9 @@ nsContextMenu.prototype = {
},
saveVideoFrameAsImage: function () {
+ let referrerURI = document.documentURIObject;
+ let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(this.browser);
+
urlSecurityCheck(this.mediaURL, this.browser.contentPrincipal,
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
let name = "";
@@ -923,7 +931,9 @@ nsContextMenu.prototype = {
canvas.height = video.videoHeight;
var ctxDraw = canvas.getContext("2d");
ctxDraw.drawImage(video, 0, 0);
- saveImageURL(canvas.toDataURL("image/jpeg", ""), name, "SaveImageTitle", true, false, document.documentURIObject, this.target.ownerDocument);
+ saveImageURL(canvas.toDataURL("image/jpeg", ""), name, "SaveImageTitle",
+ true, false, referrerURI, null, null, null,
+ isPrivate);
},
fullScreenVideo: function () {
@@ -1106,10 +1116,17 @@ nsContextMenu.prototype = {
}
}
- // set up a channel to do the saving
- var ioService = Cc["@mozilla.org/network/io-service;1"].
- getService(Ci.nsIIOService);
- var channel = ioService.newChannelFromURI(makeURI(linkURL));
+ // setting up a new channel for 'right click - save link as ...'
+ // ideally we should use:
+ // * doc - as the loadingNode, and/or
+ // * 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)
channel.contentDispositionFilename = linkDownload;
if (channel instanceof Ci.nsIPrivateBrowsingChannel) {
@@ -1142,7 +1159,7 @@ nsContextMenu.prototype = {
timer.TYPE_ONE_SHOT);
// 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.
@@ -1174,6 +1191,8 @@ nsContextMenu.prototype = {
// Save URL of the clicked upon image, video, or audio.
saveMedia: function() {
var doc = this.target.ownerDocument;
+ let referrerURI = doc.documentURIObject;
+ let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(this.browser);
if (this.onCanvas) {
// Bypass cache, since it's a blob: URL.
var target = this.target;
@@ -1189,14 +1208,16 @@ nsContextMenu.prototype = {
resolve(win.URL.createObjectURL(blob));
})
}}).then(function (blobURL) {
- saveImageURL(blobURL, "canvas.png", "SaveImageTitle", true,
- false, doc.documentURIObject, doc);
+ saveImageURL(blobURL, "canvas.png", "SaveImageTitle",
+ true, false, referrerURI, null, null, null,
+ isPrivate);
}, Components.utils.reportError);
}
} else if (this.onImage) {
urlSecurityCheck(this.mediaURL, doc.nodePrincipal);
- saveImageURL(this.mediaURL, null, "SaveImageTitle", false,
- false, doc.documentURIObject, doc);
+ saveImageURL(this.mediaURL, null, "SaveImageTitle",
+ false, false, referrerURI, doc, null, null,
+ isPrivate);
} else if (this.onVideo || this.onAudio) {
urlSecurityCheck(this.mediaURL, doc.nodePrincipal);
var dialogTitle = this.onVideo ? "SaveVideoTitle" : "SaveAudioTitle";