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

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: Rebase 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 f4cb39424251d8b4e5fdc2bb4c34e14770f61957..c287abf3f4bf5d7c7506ca87bb61befcb3985a96 100644
--- a/chrome/browser/resources/md_bookmarks/command_manager.js
+++ b/chrome/browser/resources/md_bookmarks/command_manager.js
@@ -37,8 +37,14 @@ cr.define('bookmarks', function() {
/** @private */
globalCanEdit_: Boolean,
+
+ /** @private */
+ confirmOpenString_: String,
},
+ /** @private {?Function} */
+ confirmOpenCallback_: null,
+
attached: function() {
assert(CommandManager.instance_ == null);
CommandManager.instance_ = this;
@@ -315,6 +321,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
@@ -328,16 +336,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 callback = function() {
calamity 2017/06/22 05:15:33 nit: openUrls?
tsergeant 2017/06/22 07:47:31 Changed it to openUrlsCallback, since I didn't rea
+ 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) {
+ callback();
+ return;
}
+
+ this.confirmOpenString_ =
calamity 2017/06/22 05:15:33 Is this worth making a property? Can we just get t
tsergeant 2017/06/22 07:47:31 Done.
+ loadTimeData.getStringF('openDialogBody', urls.length);
+ this.confirmOpenCallback_ = callback;
+
+ this.$.openDialog.get().showModal();
},
/**
@@ -440,6 +461,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}

Powered by Google App Engine
This is Rietveld 408576698