[tbb-commits] [tor-browser/tor-browser-45.1.0esr-6.0-1] Bug 18886: Hide pocket menu items when Pocket is disabled

gk at torproject.org gk at torproject.org
Tue May 17 13:29:31 UTC 2016


commit 320de5db6d53f53aadfad785ce31826b3080e890
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date:   Fri May 13 21:42:18 2016 -0700

    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.
---
 browser/base/content/browser-places.js | 9 ++++++++-
 browser/base/content/nsContextMenu.js  | 4 +++-
 browser/modules/ReaderParent.jsm       | 7 +++++--
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js
index 7e3ddcc..45a3af6 100644
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -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;
   },
diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js
index 463809f..be42f80 100644
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -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)));
diff --git a/browser/modules/ReaderParent.jsm b/browser/modules/ReaderParent.jsm
index 0860989..4df8210 100644
--- a/browser/modules/ReaderParent.jsm
+++ b/browser/modules/ReaderParent.jsm
@@ -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;
       }



More information about the tbb-commits mailing list