Commit 60485661 authored by Arthur Edelstein's avatar Arthur Edelstein Committed by Georg Koppen
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.
parent ab90aa02
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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;
  },
+3 −1
Original line number Diff line number Diff line
@@ -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)));
+5 −2
Original line number Diff line number Diff line
@@ -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;
      }