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

Unified Diff: components/chrome_apps/webstore_widget/app/main.js

Issue 1129083006: Show an error dialog if Chrome Web Store widget fails to load (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@launching_webstore_widget_app
Patch Set: . Created 5 years, 7 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
« no previous file with comments | « no previous file | components/chrome_apps/webstore_widget/cws_widget/cws_widget_container.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/chrome_apps/webstore_widget/app/main.js
diff --git a/components/chrome_apps/webstore_widget/app/main.js b/components/chrome_apps/webstore_widget/app/main.js
index 56b1569ff89bf0a221e16451c9dba342a62ff1f5..1c88b99d34847703f18e00e714fedf11b3323a03 100644
--- a/components/chrome_apps/webstore_widget/app/main.js
+++ b/components/chrome_apps/webstore_widget/app/main.js
@@ -40,7 +40,8 @@ var defaultStrings = {
'LINK_TO_WEBSTORE': '[LOCALIZE ME] Learn more...',
'INSTALLATION_FAILED_MESSAGE': '[LOCALIZE ME] Installation failed!',
'OK_BUTTON': '[LOCALIZE ME] OK',
- 'TITLE_PRINTER_PROVIDERS': '[LOCALIZE ME] Select app for your printer'
+ 'TITLE_PRINTER_PROVIDERS': '[LOCALIZE ME] Select app for your printer',
+ 'DEFAULT_ERROR_MESSAGE': '[LOCALIZE ME] Failure'
};
@@ -122,7 +123,7 @@ function createPlatformDelegate(strings) {
function initializeTopbarButtons() {
$('close-button').addEventListener('click', function(e) {
e.preventDefault();
- chrome.app.window.current().close();
+ close();
});
$('close-button').addEventListener('mousedown', function(e) {
@@ -139,6 +140,25 @@ function initializeTopbarButtons() {
});
}
+/**
+ * @param {!CWSWidgetContainer.Result} result The result reported by the widget.
+ */
+function showWidgetResult(result) {
+ // TODO(tbarzic): Add some UI to show on success.
+ if (result != CWSWidgetContainer.Result.FAILED) {
+ close();
+ return;
+ }
+
+ var dialog = new CWSWidgetContainerErrorDialog($('widget-container-root'));
+ dialog.show(getString('DEFAULT_ERROR_MESSAGE'), close, close);
+}
+
+/** Closes the current app window. */
+function close() {
yoshiki 2015/05/12 13:57:15 nit: this overrides window.close() in this scope.
tbarzic 2015/05/12 20:38:51 Done.
+ chrome.app.window.current().close();
+}
+
window.addEventListener('DOMContentLoaded', function() {
initializeTopbarButtons();
@@ -177,12 +197,15 @@ window.addEventListener('DOMContentLoaded', function() {
})
/** @param {!CWSWidgetContainer.ResolveReason} reason */
.then(function(reason) {
- chrome.app.window.current().close();
+ if (reason != CWSWidgetContainer.ResolveReason.DONE)
+ return;
+
+ var result = widgetContainer.finalizeAndGetResult();
+ showWidgetResult(result.result);
})
/** @param {*} error */
.catch(function(error) {
- // TODO(tbarzic): Add error UI.
- console.error(error);
+ showWidgetResult(CWSWidgetContainer.Result.FAILED);
});
});
});
« no previous file with comments | « no previous file | components/chrome_apps/webstore_widget/cws_widget/cws_widget_container.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698