| Index: chrome/browser/resources/md_bookmarks/store.js
|
| diff --git a/chrome/browser/resources/md_bookmarks/store.js b/chrome/browser/resources/md_bookmarks/store.js
|
| index 79e52fe9a9f68c6763da63ec6ee004d997f5a67f..4ab4c17dcbf5caa07a854ca98c5abec048311a01 100644
|
| --- a/chrome/browser/resources/md_bookmarks/store.js
|
| +++ b/chrome/browser/resources/md_bookmarks/store.js
|
| @@ -45,6 +45,9 @@ var BookmarksStore = Polymer({
|
|
|
| /** @type {Set<string>} */
|
| searchResultSet_: Object,
|
| +
|
| + /** @type {Set<string>} */
|
| + selectedItemSet_: Object,
|
| },
|
|
|
| /** @private {Object} */
|
| @@ -54,6 +57,7 @@ var BookmarksStore = Polymer({
|
| attached: function() {
|
| this.documentListeners_ = {
|
| 'folder-open-changed': this.onFolderOpenChanged_.bind(this),
|
| + 'remove-item': this.onItemRemoved_.bind(this),
|
| 'search-term-changed': this.onSearchTermChanged_.bind(this),
|
| 'select-item': this.onItemSelected_.bind(this),
|
| 'selected-folder-changed': this.onSelectedFolderChanged_.bind(this),
|
| @@ -92,6 +96,7 @@ var BookmarksStore = Polymer({
|
| this.rootNode = rootNode;
|
| this.idToNodeMap_ = {};
|
| this.rootNode.path = 'rootNode';
|
| + this.selectedItemSet_ = new Set();
|
| BookmarksStore.generatePaths(rootNode, 0);
|
| BookmarksStore.initNodes(this.rootNode, this.idToNodeMap_);
|
|
|
| @@ -187,6 +192,8 @@ var BookmarksStore = Polymer({
|
| if (!this.displayedList)
|
| return;
|
|
|
| + this.selectedItemSet_.clear();
|
| +
|
| for (var i = 0; i < this.displayedList.length; i++) {
|
| if (!this.displayedList[i].isSelectedItem)
|
| continue;
|
| @@ -252,6 +259,7 @@ var BookmarksStore = Polymer({
|
| }
|
| for (var i = startIndex; i <= endIndex; i++) {
|
| this.set('displayedList.#' + i + '.isSelectedItem', true);
|
| + this.selectedItemSet_.add(this.displayedList[i]);
|
| }
|
| },
|
|
|
| @@ -263,6 +271,23 @@ var BookmarksStore = Polymer({
|
| selectItem_: function(item) {
|
| this.anchorIndex_ = this.getIndexInList_(item);
|
| this.set('displayedList.#' + this.anchorIndex_ + '.isSelectedItem', true);
|
| + this.selectedItemSet_.add(this.displayedList[this.anchorIndex_]);
|
| + },
|
| +
|
| + /**
|
| + * @param {BookmarkTreeNode} item
|
| + * @private
|
| + */
|
| + removeSingleItem_: function(item) {
|
| + if (item.url) {
|
| + chrome.bookmarks.remove(item.id, function() {
|
| + // TODO(jiaxi): Add toast later.
|
| + }.bind(this));
|
| + } else {
|
| + chrome.bookmarks.removeTree(item.id, function() {
|
| + // TODO(jiaxi): Add toast later.
|
| + }.bind(this));
|
| + }
|
| },
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
| @@ -402,6 +427,20 @@ var BookmarksStore = Polymer({
|
| else
|
| this.selectItem_(e.detail.item);
|
| },
|
| +
|
| + /**
|
| + * @param {CustomEvent} e
|
| + * @private
|
| + */
|
| + onItemRemoved_: function(e) {
|
| + var item = /** BookmarkTreeNode */ (e.detail);
|
| + if (this.selectedItemSet_.size == 1 || !item.isSelectedItem) {
|
| + this.removeSingleItem_(item);
|
| + } else {
|
| + for (let item of this.selectedItemSet_)
|
| + this.removeSingleItem_(item);
|
| + }
|
| + },
|
| });
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|