Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2589)

Unified Diff: chrome/browser/resources/bookmark_manager/js/main.js

Issue 308003013: Make the Bookmark Manager aware of managed bookmarks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased on new BookmarkTreeNode.unmodifiable api change Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/bookmark_manager/js/main.js
diff --git a/chrome/browser/resources/bookmark_manager/js/main.js b/chrome/browser/resources/bookmark_manager/js/main.js
index f6f2eb32370d16bff44d2a61a19cf584273eae3c..d01fca221906f05f8299c542c69c4ed94c507bab 100644
--- a/chrome/browser/resources/bookmark_manager/js/main.js
+++ b/chrome/browser/resources/bookmark_manager/js/main.js
@@ -455,7 +455,8 @@ function handleCanExecuteForDocument(e) {
break;
case 'sort-command':
e.canExecute = !list.isSearch() &&
- list.dataModel && list.dataModel.length > 1;
+ list.dataModel && list.dataModel.length > 1 &&
+ !isUnmodifiable(tree.getBookmarkNodeById(list.parentId));
break;
case 'undo-command':
// The global undo command has no visible UI, so always enable it, and
@@ -485,7 +486,9 @@ function canExecuteShared(e, isSearch) {
case 'add-new-bookmark-command':
case 'new-folder-command':
- e.canExecute = !isSearch && canEdit;
+ var parentId = computeParentFolderForNewItem();
+ var unmodifiable = isUnmodifiable(tree.getBookmarkNodeById(parentId));
+ e.canExecute = !isSearch && canEdit && !unmodifiable;
break;
case 'open-in-new-tab-command':
@@ -551,7 +554,7 @@ function canExecuteForList(e) {
command.hidden = true;
} else {
var isFolder = bmm.isFolder(items[0]);
- e.canExecute = isFolder && canEdit;
+ e.canExecute = isFolder && canEdit && !hasUnmodifiable(items);
command.hidden = !isFolder;
}
break;
@@ -564,7 +567,7 @@ function canExecuteForList(e) {
command.hidden = false;
} else {
var isFolder = bmm.isFolder(items[0]);
- e.canExecute = !isFolder && canEdit;
+ e.canExecute = !isFolder && canEdit && !hasUnmodifiable(items);
command.hidden = isFolder;
}
break;
@@ -575,7 +578,8 @@ function canExecuteForList(e) {
case 'delete-command':
case 'cut-command':
- e.canExecute = canCopyItems() && canEdit;
+ e.canExecute = canCopyItems() && canEdit &&
+ !hasUnmodifiable(list.selectedItems);
break;
case 'copy-command':
@@ -620,7 +624,8 @@ function handleCanExecuteForTree(e) {
switch (commandId) {
case 'rename-folder-command':
command.hidden = false;
- e.canExecute = hasSelected() && !isTopLevelItem() && canEdit;
+ e.canExecute = hasSelected() && !isTopLevelItem() && canEdit &&
+ !hasUnmodifiable(tree.selectedFolders);
break;
case 'edit-command':
@@ -630,7 +635,8 @@ function handleCanExecuteForTree(e) {
case 'delete-command':
case 'cut-command':
- e.canExecute = hasSelected() && !isTopLevelItem() && canEdit;
+ e.canExecute = hasSelected() && !isTopLevelItem() && canEdit &&
+ !hasUnmodifiable(tree.selectedFolders);
break;
case 'copy-command':
@@ -790,6 +796,22 @@ function getSelectedBookmarkIds() {
}
/**
+ * @param {BookmarkTreeNode} node The node to test.
+ * @return {boolean} Whether the given node is unmodifiable.
+ */
+function isUnmodifiable(node) {
+ return node && node.unmodifiable;
Joao da Silva 2014/06/05 20:28:38 The "unmodifiable" property will be new in 37, see
+}
+
+/**
+ * @param {BookmarkList} A list of BookmarkNodes.
+ * @return {boolean} Whether any of the nodes is managed.
+ */
+function hasUnmodifiable(nodes) {
+ return nodes.some(isUnmodifiable);
+}
+
+/**
* Opens the selected bookmarks.
* @param {LinkKind} kind The kind of link we want to open.
* @param {HTMLElement} opt_eventTarget The target of the user initiated event.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698