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

Unified Diff: chrome/browser/resources/md_bookmarks/util.js

Issue 2912893002: MD Bookmarks: Support policies for disabling bookmark editing (Closed)
Patch Set: canEdit -> globalCanEdit Created 3 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
Index: chrome/browser/resources/md_bookmarks/util.js
diff --git a/chrome/browser/resources/md_bookmarks/util.js b/chrome/browser/resources/md_bookmarks/util.js
index 2a9de6a1ab7041c2a8fba9e3fe326c3f60ccdc0b..4b581e49c1bb115a0959b1b2bd762b2003fbbf2d 100644
--- a/chrome/browser/resources/md_bookmarks/util.js
+++ b/chrome/browser/resources/md_bookmarks/util.js
@@ -71,6 +71,7 @@ cr.define('bookmarks.util', function() {
selectedFolder: '0',
closedFolders: new Set(),
prefs: {
+ canEdit: true,
incognitoAvailability: IncognitoAvailability.ENABLED,
},
search: {
@@ -93,6 +94,33 @@ cr.define('bookmarks.util', function() {
return !!state.search.term && !state.search.inProgress;
}
+ /**
+ * Returns true if the node with ID |itemId| is modifiable, allowing
+ * the node to be renamed, moved or deleted. Note that if a node is
+ * uneditable, it may still have editable children (for example, the top-level
+ * folders).
+ * @param {BookmarksPageState} state
+ * @param {string} itemId
+ * @return {boolean}
+ */
+ function canEditNode(state, itemId) {
+ return itemId != ROOT_NODE_ID &&
+ state.nodes[itemId].parentId != ROOT_NODE_ID &&
+ !state.nodes[itemId].unmodifiable && state.prefs.canEdit;
+ }
+
+ /**
+ * Returns true if it is possible to modify the children list of the node with
+ * ID |itemId|. This includes rearranging the children or adding new ones.
+ * @param {BookmarksPageState} state
+ * @param {string} itemId
+ * @return {boolean}
+ */
+ function canReorderChildren(state, itemId) {
+ return itemId != ROOT_NODE_ID && !state.nodes[itemId].unmodifiable &&
+ state.prefs.canEdit;
+ }
+
/**
* @param {string} id
* @param {NodeMap} nodes
@@ -166,6 +194,8 @@ cr.define('bookmarks.util', function() {
}
return {
+ canEditNode: canEditNode,
+ canReorderChildren: canReorderChildren,
createEmptyState: createEmptyState,
getDescendants: getDescendants,
getDisplayedList: getDisplayedList,
« no previous file with comments | « chrome/browser/resources/md_bookmarks/types.js ('k') | chrome/browser/ui/webui/md_bookmarks/bookmarks_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698