Bug 1155519 - Add "View Pocket Items" menuitem to the bookmarks menu, r=dolske.
authorFlorian Quèze <florian@queze.net>
Tue, 05 May 2015 12:24:11 +0200
changeset 260418 a1b09394f8c5
parent 260417 0a18ef5ab9b7
child 260419 3d9d572c9ec4
push id776
push userjwein@mozilla.com
push date2015-05-07 17:59 +0000
treeherdermozilla-release@53b766c68811 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs1155519
milestone38.0
Bug 1155519 - Add "View Pocket Items" menuitem to the bookmarks menu, r=dolske.
browser/base/content/browser-menubar.inc
browser/base/content/browser-places.js
browser/base/content/browser-pocket.dtd
browser/base/content/browser.xul
browser/components/customizableui/content/panelUI.inc.xul
browser/components/pocket/Pocket.jsm
browser/components/pocket/jar.mn
browser/components/pocket/panels/img/pocketmenuitem16.png
browser/components/pocket/panels/img/pocketmenuitem16@2x.png
browser/themes/linux/browser.css
browser/themes/osx/browser.css
browser/themes/windows/browser.css
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -393,16 +393,17 @@
 #ifndef XP_MACOSX
                placespopup="true"
 #endif
                context="placesContext"
                openInTabs="children"
                oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
                onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
                onpopupshowing="BookmarkingUI.onMainMenuPopupShowing(event);
+                               BookmarkingUI.updatePocketItemVisibility('menu_');
                                if (!this.parentNode._placesView)
                                  new PlacesMenu(event, 'place:folder=BOOKMARKS_MENU');"
                tooltip="bhTooltip" popupsinherittooltip="true">
       <menuitem id="bookmarksShowAll"
                 label="&showAllBookmarks2.label;"
                 command="Browser:ShowAllBookmarks"
                 key="manBookmarkKb"/>
       <menuseparator id="organizeBookmarksSeparator"/>
@@ -466,16 +467,19 @@
           <menuitem id="viewReadingListSidebar" class="subviewbutton"
                     oncommand="SidebarUI.toggle('readingListSidebar');"
                     label="&readingList.showSidebar.label;">
             <observes element="readingListSidebar" attribute="checked"/>
           </menuitem>
         </menupopup>
       </menu>
 #endif
+      <menuseparator id="menu_pocketSeparator"/>
+      <menuitem id="menu_pocket" label="&pocketMenuitem.label;"
+                oncommand="openUILink(Pocket.listURL, event);"/>
       <menuseparator id="bookmarksMenuItemsSeparator"/>
       <!-- Bookmarks menu items -->
       <menuseparator builder="end"
                      class="hide-if-empty-places-result"/>
       <menuitem id="menu_unsortedBookmarks"
                 label="&unsortedBookmarksCmd.label;"
                 oncommand="PlacesCommandHook.showPlacesOrganizer('UnfiledBookmarks');"/>
     </menupopup>
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1425,16 +1425,22 @@ let BookmarkingUI = {
     this.broadcaster.setAttribute("label", this.broadcaster.getAttribute(label));
   },
 
   onMainMenuPopupShowing: function BUI_onMainMenuPopupShowing(event) {
     this._updateBookmarkPageMenuItem();
     PlacesCommandHook.updateBookmarkAllTabsCommand();
   },
 
+  updatePocketItemVisibility: function BUI_updatePocketItemVisibility(prefix) {
+    let hidden = !CustomizableUI.getPlacementOfWidget("pocket-button");
+    document.getElementById(prefix + "pocket").hidden = hidden;
+    document.getElementById(prefix + "pocketSeparator").hidden = hidden;
+  },
+
   _showBookmarkedNotification: function BUI_showBookmarkedNotification() {
     function getCenteringTransformForRects(rectToPosition, referenceRect) {
       let topDiff = referenceRect.top - rectToPosition.top;
       let leftDiff = referenceRect.left - rectToPosition.left;
       let heightDiff = referenceRect.height - rectToPosition.height;
       let widthDiff = referenceRect.width - rectToPosition.width;
       return [(leftDiff + .5 * widthDiff) + "px", (topDiff + .5 * heightDiff) + "px"];
     }
@@ -1542,16 +1548,17 @@ let BookmarkingUI = {
       case "ViewHiding":
         this.onPanelMenuViewHiding(aEvent);
         break;
     }
   },
 
   onPanelMenuViewShowing: function BUI_onViewShowing(aEvent) {
     this._updateBookmarkPageMenuItem();
+    this.updatePocketItemVisibility("panelMenu_");
     // Update checked status of the toolbar toggle.
     let viewToolbar = document.getElementById("panelMenu_viewBookmarksToolbar");
     let personalToolbar = document.getElementById("PersonalToolbar");
     if (personalToolbar.collapsed)
       viewToolbar.removeAttribute("checked");
     else
       viewToolbar.setAttribute("checked", "true");
     // Get all statically placed buttons to supply them with keyboard shortcuts.
--- a/browser/base/content/browser-pocket.dtd
+++ b/browser/base/content/browser-pocket.dtd
@@ -2,8 +2,9 @@
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <!-- This is a temporary file and not meant for localization; later versions
    - of Firefox include these strings in browser.dtd -->
 
 <!ENTITY saveToPocketCmd.label     "Save Page to Pocket">
 <!ENTITY saveToPocketCmd.accesskey "k">
+<!ENTITY pocketMenuitem.label      "View Pocket List">
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -877,16 +877,17 @@
           <menupopup id="BMB_bookmarksPopup"
                      class="cui-widget-panel cui-widget-panelview cui-widget-panelWithFooter PanelUI-subView"
                      placespopup="true"
                      context="placesContext"
                      openInTabs="children"
                      oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
                      onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
                      onpopupshowing="BookmarkingUI.onPopupShowing(event);
+                                     BookmarkingUI.updatePocketItemVisibility('BMB_');
                                      BookmarkingUI.attachPlacesView(event, this);"
                      tooltip="bhTooltip" popupsinherittooltip="true">
             <menuitem id="BMB_viewBookmarksSidebar"
                       class="subviewbutton"
                       label="&viewBookmarksSidebar2.label;"
                       type="checkbox"
                       oncommand="SidebarUI.toggle('viewBookmarksSidebar');">
               <observes element="viewBookmarksSidebar" attribute="checked"/>
@@ -964,16 +965,21 @@
               <menupopup id="BMB_readingListPopup"
                          placespopup="true"
                          onpopupshowing="ReadingListUI.onReadingListPopupShowing(this);">
                 <menuitem id="BMB_viewReadingListSidebar" class="subviewbutton"
                           oncommand="SidebarUI.show('readingListSidebar');"
                           label="&readingList.showSidebar.label;"/>
               </menupopup>
             </menu>
+            <menuseparator id="BMB_pocketSeparator"/>
+            <menuitem id="BMB_pocket"
+                      class="menuitem-iconic bookmark-item subviewbutton"
+                      label="&pocketMenuitem.label;"
+                      oncommand="openUILink(Pocket.listURL, event);"/>
             <menuseparator/>
             <!-- Bookmarks menu items will go here -->
             <menuitem id="BMB_bookmarksShowAll"
                       class="subviewbutton panel-subview-footer"
                       label="&showAllBookmarks2.label;"
                       command="Browser:ShowAllBookmarks"
                       key="manBookmarkKb"/>
           </menupopup>
--- a/browser/components/customizableui/content/panelUI.inc.xul
+++ b/browser/components/customizableui/content/panelUI.inc.xul
@@ -132,16 +132,20 @@
         <toolbarbutton id="panelMenu_viewReadingListSidebar"
                        label="&readingList.showSidebar.label;"
                        class="subviewbutton"
                        key="key_readingListSidebar"
                        oncommand="SidebarUI.toggle('readingListSidebar'); PanelUI.hide();">
           <observes element="readingListSidebar" attribute="checked"/>
           <observes element="readingListSidebar" attribute="hidden"/>
         </toolbarbutton>
+        <toolbarseparator id="panelMenu_pocketSeparator"/>
+        <toolbarbutton id="panelMenu_pocket" label="&pocketMenuitem.label;"
+                       class="subviewbutton cui-withicon"
+                       oncommand="openUILink(Pocket.listURL, event);"/>
         <toolbarseparator class="small-separator"/>
         <toolbaritem id="panelMenu_bookmarksMenu"
                      orient="vertical"
                      smoothscroll="false"
                      onclick="if (event.button == 1) BookmarkingUI.onPanelMenuViewCommand(event, this._placesView);"
                      oncommand="BookmarkingUI.onPanelMenuViewCommand(event, this._placesView);"
                      flatList="true"
                      tooltip="bhTooltip">
--- a/browser/components/pocket/Pocket.jsm
+++ b/browser/components/pocket/Pocket.jsm
@@ -24,16 +24,18 @@ let Pocket = {
   get isLoggedIn() {
     return !!this._accessToken;
   },
 
   prefBranch: Services.prefs.getBranch("browser.pocket.settings."),
 
   get hostname() Services.prefs.getCharPref("browser.pocket.hostname"),
 
+  get listURL() { return "https://" + Pocket.hostname; },
+
   get _accessToken() {
     let sessionId, accessToken;
     let cookies = Services.cookies.getCookiesFromHost(this.hostname);
     while (cookies.hasMoreElements()) {
       let cookie = cookies.getNext().QueryInterface(Ci.nsICookie2);
       if (cookie.name == "ftv1")
         accessToken = cookie.value;
       else if (cookie.name == "fsv1")
--- a/browser/components/pocket/jar.mn
+++ b/browser/components/pocket/jar.mn
@@ -11,16 +11,18 @@ browser.jar:
   content/browser/pocket/panels/css/firasans.css        (panels/css/firasans.css)
   content/browser/pocket/panels/css/saved.css           (panels/css/saved.css)
   content/browser/pocket/panels/css/signup.css           (panels/css/signup.css)
   content/browser/pocket/panels/fonts/FiraSans-Regular.woff (panels/fonts/FiraSans-Regular.woff)
   content/browser/pocket/panels/img/pocketlogo@1x.png              (panels/img/pocketlogo@1x.png)
   content/browser/pocket/panels/img/pocketlogo@2x.png              (panels/img/pocketlogo@2x.png)
   content/browser/pocket/panels/img/pocketlogosolo@1x.png          (panels/img/pocketlogosolo@1x.png)
   content/browser/pocket/panels/img/pocketlogosolo@2x.png          (panels/img/pocketlogosolo@2x.png)
+  content/browser/pocket/panels/img/pocketmenuitem16.png           (panels/img/pocketmenuitem16.png)
+  content/browser/pocket/panels/img/pocketmenuitem16@2x.png        (panels/img/pocketmenuitem16@2x.png)
   content/browser/pocket/panels/img/pocketmultidevices@1x.png      (panels/img/pocketmultidevices@1x.png)
   content/browser/pocket/panels/img/pocketmultidevices@2x.png      (panels/img/pocketmultidevices@2x.png)
   content/browser/pocket/panels/img/signup_firefoxlogo@1x.png      (panels/img/signup_firefoxlogo@1x.png)
   content/browser/pocket/panels/img/signup_firefoxlogo@2x.png      (panels/img/signup_firefoxlogo@2x.png)
   content/browser/pocket/panels/img/signup_help@1x.png             (panels/img/signup_help@1x.png)
   content/browser/pocket/panels/img/signup_help@2x.png             (panels/img/signup_help@2x.png)
   content/browser/pocket/panels/img/tag_close@1x.png               (panels/img/tag_close@1x.png)
   content/browser/pocket/panels/img/tag_close@2x.png               (panels/img/tag_close@2x.png)
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48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<aXaWF)$(v;W
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -518,16 +518,22 @@ menuitem:not([type]):not(.menuitem-toolt
   list-style-image: url("chrome://browser/skin/places/unsortedBookmarks.png");
 }
 
 #menu_readingList,
 #BMB_readingList {
   list-style-image: url("chrome://browser/skin/readinglist/readinglist-icon.svg");
 }
 
+#panelMenu_pocket,
+#menu_pocket,
+#BMB_pocket {
+  list-style-image: url("chrome://browser/content/pocket/panels/img/pocketmenuitem16.png");
+}
+
 #menu_openDownloads {
   list-style-image: url("chrome://browser/skin/Toolbar-small.png");
   -moz-image-region: rect(0px 16px 16px 0px);
 }
 
 #menu_openAddons {
   list-style-image: url("chrome://mozapps/skin/extensions/extensionGeneric-16.png");
 }
--- a/browser/themes/osx/browser.css
+++ b/browser/themes/osx/browser.css
@@ -563,16 +563,34 @@ toolbarpaletteitem[place="palette"] > #p
   }
 }
 
 /* #menu_readingList, svg icons don't work in the mac native menubar */
 #BMB_readingList {
   list-style-image: url("chrome://browser/skin/readinglist/readinglist-icon.svg");
 }
 
+#panelMenu_pocket,
+#menu_pocket,
+#BMB_pocket {
+  list-style-image: url("chrome://browser/content/pocket/panels/img/pocketmenuitem16.png");
+}
+
+@media (min-resolution: 2dppx) {
+  #panelMenu_pocket,
+  #menu_pocket,
+  #BMB_pocket {
+    list-style-image: url("chrome://browser/content/pocket/panels/img/pocketmenuitem16@2x.png");
+  }
+
+  #panelMenu_pocket > .toolbarbutton-icon {
+    width: 16px;
+  }
+}
+
 /* ----- PRIMARY TOOLBAR BUTTONS ----- */
 
 toolbar .toolbarbutton-1:not([type="menu-button"]),
 .toolbarbutton-1 > .toolbarbutton-menubutton-button,
 .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
   -moz-box-orient: vertical;
   height: 24px;
   padding: 0;
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -2537,16 +2537,22 @@ notification[value="loop-sharing-notific
 }
 
 #menu_readingList,
 #BMB_readingList {
   list-style-image: url("chrome://browser/skin/readinglist/readinglist-icon.svg");
   -moz-image-region: auto;
 }
 
+#panelMenu_pocket,
+#menu_pocket,
+#BMB_pocket {
+  list-style-image: url("chrome://browser/content/pocket/panels/img/pocketmenuitem16.png");
+}
+
 /* ::::: Keyboard UI Panel ::::: */
 
 .KUI-panel {
   -moz-appearance: none;
   background: rgba(27%,27%,27%,.9) url(KUI-background.png) repeat-x;
   color: white;
   border-style: none;
   border-radius: 20px;