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

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

Issue 2898303004: [MD Bookmarks] Add toasts. (Closed)
Patch Set: fix nits 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/command_manager.js
diff --git a/chrome/browser/resources/md_bookmarks/command_manager.js b/chrome/browser/resources/md_bookmarks/command_manager.js
index be258a32c7548144d7aca5cbc2fd02cb8618c576..8960d0a9b94056ae399aadab5c46c0e670e4f1a5 100644
--- a/chrome/browser/resources/md_bookmarks/command_manager.js
+++ b/chrome/browser/resources/md_bookmarks/command_manager.js
@@ -44,6 +44,12 @@ cr.define('bookmarks', function() {
this.boundOnOpenItemMenu_ = this.onOpenItemMenu_.bind(this);
document.addEventListener('open-item-menu', this.boundOnOpenItemMenu_);
+ /** @private {function()} */
+ this.boundOnCommandUndo_ = function() {
+ this.handle(Command.UNDO, new Set());
+ }.bind(this);
+ document.addEventListener('command-undo', this.boundOnCommandUndo_);
+
/** @private {function(!Event)} */
this.boundOnKeydown_ = this.onKeydown_.bind(this);
document.addEventListener('keydown', this.boundOnKeydown_);
@@ -66,6 +72,7 @@ cr.define('bookmarks', function() {
detached: function() {
CommandManager.instance_ = null;
document.removeEventListener('open-item-menu', this.boundOnOpenItemMenu_);
+ document.removeEventListener('command-undo', this.boundOnCommandUndo_);
document.removeEventListener('keydown', this.boundOnKeydown_);
},
@@ -179,17 +186,31 @@ cr.define('bookmarks', function() {
case Command.COPY:
var idList = Array.from(itemIds);
chrome.bookmarkManagerPrivate.copy(idList, function() {
- // TODO(jiaxi): Add toast later.
+ bookmarks.ToastManager.getInstance().show(
+ loadTimeData.getString('toastUrlCopied'), false);
});
break;
case Command.DELETE:
- chrome.bookmarkManagerPrivate.removeTrees(
- Array.from(this.minimizeDeletionSet_(itemIds)), function() {
- // TODO(jiaxi): Add toast later.
- });
+ var idList = Array.from(this.minimizeDeletionSet_(itemIds));
+ var labelPromise;
+ if (idList.length == 1) {
+ // TODO(calamity): fold this separate label into
+ // 'toastItemsDeleted'.
+ labelPromise = Promise.resolve(loadTimeData.getStringF(
+ 'toastItemDeleted', this.getState().nodes[idList[0]].title));
+ } else {
+ labelPromise = cr.sendWithPromise(
+ 'getPluralString', 'toastItemsDeleted', idList.length);
+ }
+ chrome.bookmarkManagerPrivate.removeTrees(idList, function() {
+ labelPromise.then(function(label) {
+ bookmarks.ToastManager.getInstance().show(label, true);
+ });
+ }.bind(this));
break;
case Command.UNDO:
chrome.bookmarkManagerPrivate.undo();
+ bookmarks.ToastManager.getInstance().hide();
break;
case Command.REDO:
chrome.bookmarkManagerPrivate.redo();
« no previous file with comments | « chrome/browser/resources/md_bookmarks/app.html ('k') | chrome/browser/resources/md_bookmarks/compiled_resources2.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698