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

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

Issue 2945513002: MD Bookmarks: Add a confirmation dialog before opening many tabs (Closed)
Patch Set: Review comments 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 1fc42a70c685d5be5d35f6ac6765b6021f29f75a..2dd685d4e088cea6a94c55cb080e97046731eb6e 100644
--- a/chrome/browser/resources/md_bookmarks/command_manager.js
+++ b/chrome/browser/resources/md_bookmarks/command_manager.js
@@ -48,6 +48,9 @@ cr.define('bookmarks', function() {
globalCanEdit_: Boolean,
},
+ /** @private {?Function} */
+ confirmOpenCallback_: null,
+
attached: function() {
assert(CommandManager.instance_ == null);
CommandManager.instance_ = this;
@@ -337,6 +340,8 @@ cr.define('bookmarks', function() {
},
/**
+ * Open the given |urls| in response to a |command|. May show a confirmation
+ * dialog before opening large numbers of URLs.
* @param {!Array<string>} urls
* @param {Command} command
* @private
@@ -350,16 +355,29 @@ cr.define('bookmarks', function() {
if (urls.length == 0)
return;
- var incognito = command == Command.OPEN_INCOGNITO;
- if (command == Command.OPEN_NEW_WINDOW || incognito) {
- chrome.windows.create({url: urls, incognito: incognito});
- } else {
- if (command == Command.OPEN)
- chrome.tabs.create({url: urls.shift(), active: true});
- urls.forEach(function(url) {
- chrome.tabs.create({url: url, active: false});
- });
+ var openUrlsCallback = function() {
+ var incognito = command == Command.OPEN_INCOGNITO;
+ if (command == Command.OPEN_NEW_WINDOW || incognito) {
+ chrome.windows.create({url: urls, incognito: incognito});
+ } else {
+ if (command == Command.OPEN)
+ chrome.tabs.create({url: urls.shift(), active: true});
+ urls.forEach(function(url) {
+ chrome.tabs.create({url: url, active: false});
+ });
+ }
+ };
+
+ if (urls.length <= OPEN_CONFIRMATION_LIMIT) {
+ openUrlsCallback();
+ return;
}
+
+ this.confirmOpenCallback_ = openUrlsCallback;
+ var dialog = this.$.openDialog.get();
+ dialog.querySelector('.body').textContent =
+ loadTimeData.getStringF('openDialogBody', urls.length);
+ dialog.showModal();
},
/**
@@ -463,6 +481,17 @@ cr.define('bookmarks', function() {
this.closeCommandMenu();
},
+ /** @private */
+ onOpenCancelTap_: function() {
+ this.$.openDialog.get().cancel();
+ },
+
+ /** @private */
+ onOpenConfirmTap_: function() {
+ this.confirmOpenCallback_();
+ this.$.openDialog.get().close();
+ },
+
/**
* @param {Command} command
* @return {string}
« no previous file with comments | « chrome/browser/resources/md_bookmarks/command_manager.html ('k') | chrome/browser/resources/md_bookmarks/constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698