Bug 1295237 - Add 'Mobile Bookmarks' root to the bookmark menus if we have it. r=markh

MozReview-Commit-ID: 3ybnskOID1O

--HG--
extra : rebase_source : 3faec9e53939626dc89c039706aaa2f003571d18
This commit is contained in:
Thom Chiovoloni 2017-01-17 13:15:49 -05:00
parent cf27f94bbc
commit c197835bcf
6 changed files with 55 additions and 1 deletions

View File

@ -452,6 +452,19 @@
onpopupshowing="if (!this.parentNode._placesView)
new PlacesMenu(event, 'place:folder=UNFILED_BOOKMARKS');"/>
</menu>
<menu id="menu_mobileBookmarks"
class="menu-iconic bookmark-item"
label="&mobileBookmarksCmd.label;"
hidden="true"
container="true">
<menupopup id="mobileBookmarksFolderPopup"
#ifndef XP_MACOSX
placespopup="true"
#endif
context="placesContext"
onpopupshowing="if (!this.parentNode._placesView)
new PlacesMenu(event, 'place:folder=MOBILE_BOOKMARKS');"/>
</menu>
<menuseparator id="bookmarksMenuItemsSeparator"/>
<!-- Bookmarks menu items -->
</menupopup>

View File

@ -1342,6 +1342,7 @@ var BookmarkingUI = {
return;
}
this._initMobileBookmarks(document.getElementById("BMB_mobileBookmarks"));
this._initRecentBookmarks(document.getElementById("BMB_recentBookmarks"),
"subviewbutton");
@ -1380,6 +1381,28 @@ var BookmarkingUI = {
RECENTLY_BOOKMARKED_PREF: "browser.bookmarks.showRecentlyBookmarked",
// Set by sync after syncing bookmarks successfully once.
MOBILE_BOOKMARKS_PREF: "browser.bookmarks.showMobileBookmarks",
_shouldShowMobileBookmarks() {
try {
return Services.prefs.getBoolPref(this.MOBILE_BOOKMARKS_PREF);
} catch (e) {}
// No pref set (or invalid pref set), look for a mobile bookmarks left pane query.
const organizerQueryAnno = "PlacesOrganizer/OrganizerQuery";
const mobileBookmarksAnno = "MobileBookmarks";
let shouldShow = PlacesUtils.annotations.getItemsWithAnnotation(organizerQueryAnno, {}).filter(
id => PlacesUtils.annotations.getItemAnnotation(id, organizerQueryAnno) == mobileBookmarksAnno
).length > 0;
// Sync will change this pref if/when it adds a mobile bookmarks query.
Services.prefs.setBoolPref(this.MOBILE_BOOKMARKS_PREF, shouldShow);
return shouldShow;
},
_initMobileBookmarks(mobileMenuItem) {
mobileMenuItem.hidden = !this._shouldShowMobileBookmarks();
},
_initRecentBookmarks(aHeaderItem, aExtraCSSClass) {
this._populateRecentBookmarks(aHeaderItem, aExtraCSSClass);
@ -1710,6 +1733,7 @@ var BookmarkingUI = {
this._updateBookmarkPageMenuItem();
PlacesCommandHook.updateBookmarkAllTabsCommand();
this._initMobileBookmarks(document.getElementById("menu_mobileBookmarks"));
this._initRecentBookmarks(document.getElementById("menu_recentBookmarks"));
},

View File

@ -883,6 +883,19 @@
new PlacesMenu(event, 'place:folder=UNFILED_BOOKMARKS',
PlacesUIUtils.getViewForNode(this.parentNode.parentNode).options);"/>
</menu>
<menu id="BMB_mobileBookmarks"
class="menu-iconic bookmark-item subviewbutton"
label="&bookmarksMenuButton.mobile.label;"
hidden="true"
container="true">
<menupopup id="BMB_mobileBookmarksPopup"
placespopup="true"
context="placesContext"
onpopupshowing="if (!this.parentNode._placesView)
new PlacesMenu(event, 'place:folder=MOBILE_BOOKMARKS',
PlacesUIUtils.getViewForNode(this.parentNode.parentNode).options);"/>
</menu>
<menuseparator/>
<!-- Bookmarks menu items will go here -->
<menuitem id="BMB_bookmarksShowAll"

View File

@ -184,6 +184,7 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY showAllBookmarks2.label "Show All Bookmarks">
<!ENTITY recentBookmarks.label "Recently Bookmarked">
<!ENTITY otherBookmarksCmd.label "Other Bookmarks">
<!ENTITY mobileBookmarksCmd.label "Mobile Bookmarks">
<!ENTITY bookmarksToolbarChevron.tooltip "Show more bookmarks">
<!ENTITY showRecentlyBookmarked.label "Show Recently Bookmarked">
<!ENTITY showRecentlyBookmarked.accesskey "h">
@ -245,6 +246,7 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY bookmarksMenuButton.label "Bookmarks">
<!ENTITY bookmarksMenuButton.other.label "Other Bookmarks">
<!ENTITY bookmarksMenuButton.mobile.label "Mobile Bookmarks">
<!ENTITY viewBookmarksSidebar2.label "View Bookmarks Sidebar">
<!ENTITY viewBookmarksToolbar.label "View Bookmarks Toolbar">

View File

@ -1195,7 +1195,8 @@ menuitem.panel-subview-footer@menuStateActive@,
#BMB_bookmarksPopup menupopup[placespopup=true][singleitempopup=true] > hbox > .popup-internal-box > .arrowscrollbox-scrollbox > .scrollbox-innerbox,
/* These popups never have a footer */
#BMB_bookmarksToolbarPopup > hbox > .popup-internal-box > .arrowscrollbox-scrollbox > .scrollbox-innerbox,
#BMB_unsortedBookmarksPopup > hbox > .popup-internal-box > .arrowscrollbox-scrollbox > .scrollbox-innerbox {
#BMB_unsortedBookmarksPopup > hbox > .popup-internal-box > .arrowscrollbox-scrollbox > .scrollbox-innerbox,
#BMB_mobileBookmarksPopup > hbox > .popup-internal-box > .arrowscrollbox-scrollbox > .scrollbox-innerbox {
/* And so they need some bottom padding: */
padding-bottom: 4px;
}

View File

@ -1029,6 +1029,7 @@ BookmarksTracker.prototype = {
},
_ensureMobileQuery: function _ensureMobileQuery() {
Services.prefs.setBoolPref("browser.bookmarks.showMobileBookmarks", true);
let find = val =>
PlacesUtils.annotations.getItemsWithAnnotation(ORGANIZERQUERY_ANNO, {}).filter(
id => PlacesUtils.annotations.getItemAnnotation(id, ORGANIZERQUERY_ANNO) == val