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

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

Issue 2912893002: MD Bookmarks: Support policies for disabling bookmark editing (Closed)
Patch Set: Add lotsa tests 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/toolbar.js
diff --git a/chrome/browser/resources/md_bookmarks/toolbar.js b/chrome/browser/resources/md_bookmarks/toolbar.js
index 2ec046977b9e4238e7cad7c2f9401010c80f8b7f..621394b8a527297219d80830d39e4e812fcd7b40 100644
--- a/chrome/browser/resources/md_bookmarks/toolbar.js
+++ b/chrome/browser/resources/md_bookmarks/toolbar.js
@@ -23,7 +23,7 @@ Polymer({
showSelectionOverlay: {
type: Boolean,
- computed: 'shouldShowSelectionOverlay_(selectedCount_)',
+ computed: 'shouldShowSelectionOverlay_(selectedItems_, canEdit_)',
readOnly: true,
reflectToAttribute: true,
},
@@ -34,16 +34,35 @@ Polymer({
reflectToAttribute: true,
},
+ /** @private {!Set<string>} */
+ selectedItems_: Number,
calamity 2017/06/09 06:47:31 Number != Set
tsergeant 2017/06/13 03:13:10 very true
+
+ /** @private */
+ canEdit_: Boolean,
+
+ /** @private */
+ selectedFolder_: String,
+
/** @private */
- selectedCount_: Number,
+ childrenUnmodifiable_: {
+ type: Boolean,
+ computed:
+ 'computeChildrenUnmodifiable_(selectedFolder_, searchTerm_, canEdit_)'
+ }
},
attached: function() {
this.watch('searchTerm_', function(state) {
return state.search.term;
});
- this.watch('selectedCount_', function(state) {
- return state.selection.items.size;
+ this.watch('selectedItems_', function(state) {
+ return state.selection.items;
+ });
+ this.watch('canEdit_', function(state) {
+ return state.prefs.canEdit;
+ });
+ this.watch('selectedFolder_', function(state) {
+ return state.selectedFolder;
});
this.updateFromStore();
},
@@ -143,8 +162,10 @@ Polymer({
* @return {boolean}
* @private
*/
- hasSearchTerm_: function() {
- return !!this.searchTerm_;
+ computeChildrenUnmodifiable_: function() {
+ return !!this.searchTerm_ ||
+ bookmarks.util.areChildrenUnmodifiable(
+ this.getState(), this.selectedFolder_);
},
/**
@@ -152,7 +173,12 @@ Polymer({
* @private
*/
shouldShowSelectionOverlay_: function() {
- return this.selectedCount_ > 1;
+ return this.selectedItems_.size > 1 && this.canEdit_;
+ },
+
+ canDeleteSelection_: function() {
+ return bookmarks.CommandManager.getInstance().canExecute(
+ Command.DELETE, this.selectedItems_);
},
/**
@@ -160,6 +186,6 @@ Polymer({
* @private
*/
getItemsSelectedString_: function() {
- return loadTimeData.getStringF('itemsSelected', this.selectedCount_);
+ return loadTimeData.getStringF('itemsSelected', this.selectedItems_.size);
},
});

Powered by Google App Engine
This is Rietveld 408576698