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

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 years, 8 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: ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js b/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
index 5873cdab6a6fe8a57e327df3049f07e9eef561b5..ef98f0c5c41aade17bb43bdc986c46b2cd01fcbb 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
@@ -131,7 +131,10 @@ SuggestAppsDialog.prototype.showInternal_ =
this.text_.hidden = true;
this.dialogText_ = '';
- this.onDialogClosed_ = onDialogClosed;
+ if (!this.widget_.isInInitialState()) {
+ onDialogClosed(SuggestAppsDialog.Result.CANCELLED, null);
+ return;
+ }
var dialogShown = false;
@@ -145,6 +148,9 @@ SuggestAppsDialog.prototype.showInternal_ =
/** @return {!Promise.<CWSWidgetContainer.ResolveReason>} */
function() {
dialogShown = true;
+ // This is not set before so it doesn't polute state if the previous
+ // dialog hasn't finished hiding.
+ this.onDialogClosed_ = onDialogClosed;
return this.widget_.start(options, webStoreUrl);
}.bind(this))
.then(
@@ -157,12 +163,20 @@ SuggestAppsDialog.prototype.showInternal_ =
/** @param {string} error */
function(error) {
console.error('Failed to start CWS widget: ' + error);
- this.result_ = SuggestAppsDialog.Result.FAILED;
- if (dialogShown) {
- this.hide();
- } else {
- this.onHide_();
+
+ // If the widget dialog was not shown, consider the widget
+ // canceled.
+ if (!dialogShown) {
+ // Reset any widget state set in |this.widget_.ready()|. The
+ // returned value is ignored because it doesn't influence the
+ // value reported by dialog.
+ this.widget_.finalizeAndGetResult();
+ onDialogClosed(SuggestAppsDialog.Result.CANCELLED, null);
+ return;
}
+
+ this.result_ = SuggestAppsDialog.Result.FAILED;
+ this.hide();
}.bind(this));
};

Powered by Google App Engine
This is Rietveld 408576698