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.js62
1 files changed, 43 insertions, 19 deletions
diff --git a/application/palemoon/base/content/nsContextMenu.js b/application/palemoon/base/content/nsContextMenu.js
index 8e6bc96c2..830c20998 100644
--- a/application/palemoon/base/content/nsContextMenu.js
+++ b/application/palemoon/base/content/nsContextMenu.js
@@ -4,6 +4,8 @@
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
+var gContextMenuContentData = null;
+
function nsContextMenu(aXulMenu, aIsShift) {
this.shouldDisplay = true;
this.initMenu(aXulMenu, aIsShift);
@@ -39,6 +41,7 @@ nsContextMenu.prototype = {
},
hiding: function CM_hiding() {
+ gContextMenuContentData = null;
InlineSpellCheckerUI.clearSuggestionsFromMenu();
InlineSpellCheckerUI.clearDictionaryListFromMenu();
InlineSpellCheckerUI.uninit();
@@ -265,7 +268,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 +425,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));
},
@@ -901,11 +909,15 @@ nsContextMenu.prototype = {
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
let doc = this.target.ownerDocument;
openUILink(viewURL, e, { disallowInheritPrincipal: true,
- referrerURI: doc.documentURIObject });
+ referrerURI: doc.documentURIObject,
+ forceAllowDataURI: true });
}
},
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 +935,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 +1120,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 +1163,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 +1195,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 +1212,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";
@@ -1373,9 +1398,8 @@ nsContextMenu.prototype = {
isDisabledForEvents: function(aNode) {
let ownerDoc = aNode.ownerDocument;
- return
- ownerDoc.defaultView &&
- ownerDoc.defaultView
+ return ownerDoc.defaultView &&
+ ownerDoc.defaultView
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.isNodeDisabledForEvents(aNode);