Skip to content
Permalink
Browse files
Bug 18886: Hide pocket menu items when Pocket is disabled
If the user toggles the value of "browser.pocket.enabled", then menu
items (and pocket button) will be affected only after browser restart.
  • Loading branch information
arthuredelstein committed May 16, 2016
1 parent 7ffe323 commit c3fc62020f4b12aaa633d5760ea77999a97c5f11
Showing with 16 additions and 4 deletions.
  1. +8 −1 browser/base/content/browser-places.js
  2. +3 −1 browser/base/content/nsContextMenu.js
  3. +5 −2 browser/modules/ReaderParent.jsm
@@ -1553,7 +1553,14 @@ var BookmarkingUI = {
},

updatePocketItemVisibility: function BUI_updatePocketItemVisibility(prefix) {
let hidden = !CustomizableUI.getPlacementOfWidget("pocket-button");
// When the pocket button has been placed on the navigation bar or
// on the hamburger menu, then Pocket can be considered "active" and
// we should show the pocket menu item in various places.
// If, on the other hand, the pocket button is not present because
// the user has moved it out of the nav bar, or the browser started
// up with "browser.pocket.enabled" set to false, then we
// should not show the pocket menu items.
let hidden = document.getElementById("pocket-button") == null;
document.getElementById(prefix + "pocket").hidden = hidden;
document.getElementById(prefix + "pocketSeparator").hidden = hidden;
},
@@ -225,7 +225,9 @@ nsContextMenu.prototype = {
this.isContentSelected || this.onImage ||
this.onCanvas || this.onVideo || this.onAudio);
let targetURI = (this.onSaveableLink || this.onPlainTextLink) ? this.linkURI : this.browser.currentURI;
let canPocket = CustomizableUI.getPlacementOfWidget("pocket-button") &&
// Pocket is only "active" if the pocket button is present on the
// navigation bar or hamburger menu.
let canPocket = (document.getElementById("pocket-button") !== null) &&
window.pktApi && window.pktApi.isUserLoggedIn();
canPocket = canPocket && (targetURI.schemeIs("http") || targetURI.schemeIs("https") ||
(targetURI.schemeIs("about") && ReaderMode.getOriginalUrl(targetURI.spec)));
@@ -79,8 +79,11 @@ var ReaderParent = {
break;

case "Reader:PocketEnabledGet": {
let pocketPlacement = CustomizableUI.getPlacementOfWidget("pocket-button");
let isPocketEnabled = pocketPlacement && pocketPlacement.area;
// Only when the pocket button is present on the navigation bar or
// the hamburger menu, should Pocket be considered "active".
let doc = message.target.ownerDocument;
let isPocketEnabled = (doc !== null) &&
(doc.getElementById("pocket-button") !== null);
message.target.messageManager.sendAsyncMessage("Reader:PocketEnabledData", { enabled: !!isPocketEnabled});
break;
}

0 comments on commit c3fc620

Please sign in to comment.