Bug 1181437 - Disable AddBookmarkAs command on non-bookmarkable pages
MozReview-Commit-ID: K1GRFJ0Ikvf
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1408,29 +1408,34 @@ var BookmarkingUI = {
root.containerOpen = false;
aHeaderItem.parentNode.insertBefore(fragment, aHeaderItem.nextSibling);
},
/**
* Handles star styling based on page proxy state changes.
*/
onPageProxyStateChanged: function BUI_onPageProxyStateChanged(aState) {
+ let disabled = aState == "invalid";
+ if (disabled) {
+ this.broadcaster.setAttribute("disabled", "true");
+ } else {
+ this.broadcaster.removeAttribute("disabled");
+ }
+
if (!this._shouldUpdateStarState() || !this.star) {
return;
}
- if (aState == "invalid") {
+ if (disabled) {
this.star.setAttribute("disabled", "true");
- this.broadcaster.setAttribute("stardisabled", "true");
this.broadcaster.removeAttribute("starred");
this.broadcaster.setAttribute("buttontooltiptext", "");
}
else {
this.star.removeAttribute("disabled");
- this.broadcaster.removeAttribute("stardisabled");
this._updateStar();
}
},
_updateCustomizationState: function BUI__updateCustomizationState() {
let placement = CustomizableUI.getPlacementOfWidget(this.BOOKMARK_BUTTON_ID);
this._currentAreaType = placement && CustomizableUI.getAreaType(placement.area);
},
--- a/browser/base/content/browser-sets.inc
+++ b/browser/base/content/browser-sets.inc
@@ -52,17 +52,19 @@
<command id="cmd_findPrevious"
oncommand="gFindBar.onFindAgainCommand(true);"
observes="isImage"/>
#ifdef XP_MACOSX
<command id="cmd_findSelection" oncommand="gFindBar.onFindSelectionCommand();"/>
#endif
<!-- work-around bug 392512 -->
<command id="Browser:AddBookmarkAs"
- oncommand="PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksMenuFolderId);"/>
+ oncommand="PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksMenuFolderId);">
+ <observes element="bookmarkThisPageBroadcaster" attribute="disabled"/>
+ </command>
<!-- The command disabled state must be manually updated through
PlacesCommandHook.updateBookmarkAllTabsCommand() -->
<command id="Browser:BookmarkAllTabs"
oncommand="PlacesCommandHook.bookmarkCurrentPages();"/>
<command id="Browser:Home" oncommand="BrowserHome();"/>
<command id="Browser:Back" oncommand="BrowserBack();" disabled="true"/>
<command id="Browser:BackOrBackDuplicate" oncommand="BrowserBack(event);" disabled="true">
<observes element="Browser:Back" attribute="disabled"/>
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -286,17 +286,16 @@ nsContextMenu.prototype = {
initMiscItems: function CM_initMiscItems() {
// Use "Bookmark This Link" if on a link.
let bookmarkPage = document.getElementById("context-bookmarkpage");
this.showItem(bookmarkPage,
!(this.isContentSelected || this.onTextInput || this.onLink ||
this.onImage || this.onVideo || this.onAudio || this.onSocial ||
this.onCanvas));
bookmarkPage.setAttribute("tooltiptext", bookmarkPage.getAttribute("buttontooltiptext"));
- bookmarkPage.disabled = bookmarkPage.hasAttribute("stardisabled");
this.showItem("context-bookmarklink", (this.onLink && !this.onMailtoLink &&
!this.onSocial) || this.onPlainTextLink);
this.showItem("context-keywordfield",
this.onTextInput && this.onKeywordField);
this.showItem("frame", this.inFrame);
let showSearchSelect = (this.isTextSelected || this.onLink) && !this.onImage;