summaryrefslogtreecommitdiffstats
path: root/browser/base/content/nsContextMenu.js
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-05-25 20:45:48 +0000
committerGitHub <noreply@github.com>2018-05-25 20:45:48 +0000
commit72bab89cf6c77c9ee95a977c306e6ce317b84835 (patch)
treeca3fcaa2a72700b85221b2fe75bb7d46d5d424ce /browser/base/content/nsContextMenu.js
parentd5459982f0d1bab08b751dc140c4cbe047032617 (diff)
downloadUXP-72bab89cf6c77c9ee95a977c306e6ce317b84835.tar
UXP-72bab89cf6c77c9ee95a977c306e6ce317b84835.tar.gz
UXP-72bab89cf6c77c9ee95a977c306e6ce317b84835.tar.lz
UXP-72bab89cf6c77c9ee95a977c306e6ce317b84835.tar.xz
UXP-72bab89cf6c77c9ee95a977c306e6ce317b84835.zip
Revert "Remove the Social API"
Diffstat (limited to 'browser/base/content/nsContextMenu.js')
-rw-r--r--browser/base/content/nsContextMenu.js47
1 files changed, 39 insertions, 8 deletions
diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js
index 097caf367..955184f64 100644
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -174,15 +174,15 @@ nsContextMenu.prototype = {
initNavigationItems: function CM_initNavigationItems() {
var shouldShow = !(this.isContentSelected || this.onLink || this.onImage ||
this.onCanvas || this.onVideo || this.onAudio ||
- this.onTextInput);
+ this.onTextInput || this.onSocial);
this.showItem("context-navigation", shouldShow);
this.showItem("context-sep-navigation", shouldShow);
let stopped = XULBrowserWindow.stopCommand.getAttribute("disabled") == "true";
let stopReloadItem = "";
- if (shouldShow) {
- stopReloadItem = (stopped) ? "reload" : "stop";
+ if (shouldShow || this.onSocial) {
+ stopReloadItem = (stopped || this.onSocial) ? "reload" : "stop";
}
this.showItem("context-reload", stopReloadItem == "reload");
@@ -249,7 +249,7 @@ nsContextMenu.prototype = {
this.onImage || this.onCanvas ||
this.onVideo || this.onAudio ||
this.onLink || this.onTextInput);
- var showInspect = gPrefService.getBoolPref("devtools.inspector.enabled");
+ var showInspect = !this.onSocial && gPrefService.getBoolPref("devtools.inspector.enabled");
this.showItem("context-viewsource", shouldShow);
this.showItem("context-viewinfo", shouldShow);
this.showItem("inspect-separator", showInspect);
@@ -306,11 +306,12 @@ nsContextMenu.prototype = {
let bookmarkPage = document.getElementById("context-bookmarkpage");
this.showItem(bookmarkPage,
!(this.isContentSelected || this.onTextInput || this.onLink ||
- this.onImage || this.onVideo || this.onAudio || this.onCanvas));
+ this.onImage || this.onVideo || this.onAudio || this.onSocial ||
+ this.onCanvas));
bookmarkPage.setAttribute("tooltiptext", bookmarkPage.getAttribute("buttontooltiptext"));
- this.showItem("context-bookmarklink", (this.onLink && !this.onMailtoLink) ||
- this.onPlainTextLink);
+ this.showItem("context-bookmarklink", (this.onLink && !this.onMailtoLink &&
+ !this.onSocial) || this.onPlainTextLink);
this.showItem("context-keywordfield",
this.onTextInput && this.onKeywordField);
this.showItem("frame", this.inFrame);
@@ -348,6 +349,19 @@ nsContextMenu.prototype = {
this.onTextInput && !this.onNumeric && top.gBidiUI);
this.showItem("context-bidi-page-direction-toggle",
!this.onTextInput && top.gBidiUI);
+
+ // SocialShare
+ let shareButton = SocialShare.shareButton;
+ let shareEnabled = shareButton && !shareButton.disabled && !this.onSocial;
+ let pageShare = shareEnabled && !(this.isContentSelected ||
+ this.onTextInput || this.onLink || this.onImage ||
+ this.onVideo || this.onAudio || this.onCanvas);
+ this.showItem("context-sharepage", pageShare);
+ this.showItem("context-shareselect", shareEnabled && this.isContentSelected);
+ this.showItem("context-sharelink", shareEnabled && (this.onLink || this.onPlainTextLink) && !this.onMailtoLink);
+ this.showItem("context-shareimage", shareEnabled && this.onImage);
+ this.showItem("context-sharevideo", shareEnabled && this.onVideo);
+ this.setItemAttr("context-sharevideo", "disabled", !this.mediaURL || this.mediaURL.startsWith("blob:"));
},
initSpellingItems: function() {
@@ -667,6 +681,7 @@ nsContextMenu.prototype = {
.getInterface(Ci.nsIDOMWindowUtils)
.outerWindowID;
}
+ this.onSocial = !!this.browser.getAttribute("origin");
// Check if we are in a synthetic document (stand alone image, video, etc.).
this.inSyntheticDoc = ownerDoc.mozSyntheticDocument;
@@ -1711,6 +1726,22 @@ nsContextMenu.prototype = {
mm.sendAsyncMessage("ContextMenu:BookmarkFrame", null, { target: this.target });
},
+ shareLink: function CM_shareLink() {
+ SocialShare.sharePage(null, { url: this.linkURI.spec }, this.target);
+ },
+
+ shareImage: function CM_shareImage() {
+ SocialShare.sharePage(null, { url: this.imageURL, previews: [ this.mediaURL ] }, this.target);
+ },
+
+ shareVideo: function CM_shareVideo() {
+ SocialShare.sharePage(null, { url: this.mediaURL, source: this.mediaURL }, this.target);
+ },
+
+ shareSelect: function CM_shareSelect() {
+ SocialShare.sharePage(null, { url: this.browser.currentURI.spec, text: this.textSelected }, this.target);
+ },
+
savePageAs: function CM_savePageAs() {
saveBrowser(this.browser);
},
@@ -1825,7 +1856,7 @@ nsContextMenu.prototype = {
_getTelemetryPageContextInfo: function() {
let rv = [];
for (let k of ["isContentSelected", "onLink", "onImage", "onCanvas", "onVideo", "onAudio",
- "onTextInput"]) {
+ "onTextInput", "onSocial"]) {
if (this[k]) {
rv.push(k.replace(/^(?:is|on)(.)/, (match, firstLetter) => firstLetter.toLowerCase()));
}