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

Unified Diff: components/chrome_apps/webstore_widget/cws_widget/cws_widget_container.js

Issue 1123373003: Launch webstore widget app when unsupported printer is plugged in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_cws_widget_scripts
Patch Set: bump app version 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
Index: components/chrome_apps/webstore_widget/cws_widget/cws_widget_container.js
diff --git a/components/chrome_apps/webstore_widget/cws_widget/cws_widget_container.js b/components/chrome_apps/webstore_widget/cws_widget/cws_widget_container.js
index 9a3af1697d271e8b662a1a2acc79c69c92f6fedf..7cffe7a7255273ac698c03542c1edcb315920ffe 100644
--- a/components/chrome_apps/webstore_widget/cws_widget/cws_widget_container.js
+++ b/components/chrome_apps/webstore_widget/cws_widget/cws_widget_container.js
@@ -47,10 +47,13 @@ var CWS_WIDGET_ORIGIN = 'https://clients5.google.com';
* @param {!HTMLElement} parentNode Node to be parent for this container.
* @param {!CWSWidgetContainer.PlatformDelegate} delegate Delegate for accessing
* Chrome platform APIs.
- * @param {!SuggestAppDialogState} state Static state of suggest app dialog.
+ * @param {!{
+ * overrideCwsContainerUrlForTest: (string|undefined),
+ * overrideCwsContainerOriginForTest: (string|undefined)
+ * }} params Overrides for container params.
* @constructor
*/
-function CWSWidgetContainer(document, parentNode, delegate, state) {
+function CWSWidgetContainer(document, parentNode, delegate, params) {
/** @private {!CWSWidgetContainer.PlatformDelegate} */
this.delegate_ = delegate;
@@ -108,7 +111,6 @@ function CWSWidgetContainer(document, parentNode, delegate, state) {
*/
this.webstoreButton_ = document.createElement('div');
this.webstoreButton_.hidden = true;
- this.webstoreButton_.classList.add('cws-widget-webstore-button');
this.webstoreButton_.setAttribute('role', 'button');
this.webstoreButton_.tabIndex = 0;
@@ -148,14 +150,14 @@ function CWSWidgetContainer(document, parentNode, delegate, state) {
* @const {string}
* @private
*/
- this.widgetUrl_ = state.overrideCwsContainerUrlForTest || CWS_WIDGET_URL;
+ this.widgetUrl_ = params.overrideCwsContainerUrlForTest || CWS_WIDGET_URL;
/**
* The Chrome Web Store widget origin.
* @const {string}
* @private
*/
- this.widgetOrigin_ = state.overrideCwsContainerOriginForTest ||
+ this.widgetOrigin_ = params.overrideCwsContainerOriginForTest ||
CWS_WIDGET_ORIGIN;
/**
@@ -389,10 +391,10 @@ CWSWidgetContainer.prototype.ready = function() {
*
* @param {!Object<string, *>} options Map of options for the dialog.
* @param {?string} webStoreUrl Url for more results. Null if not supported.
- * @return {Promise.<CWSWidgetContainer.ResolveReason>} Resolved when app
+ * @return {!Promise.<CWSWidgetContainer.ResolveReason>} Resolved when app
* installation is done, or the installation is cancelled.
*/
-CWSWidgetContainer.prototype.start = function(options, webStoreUrl) {
+CWSWidgetContainer.prototype.start = function(options, webStoreUrl) {
return new Promise(function(resolve, reject) {
if (this.state_ !== CWSWidgetContainer.State.ACCESS_TOKEN_READY) {
this.state_ = CWSWidgetContainer.State.INITIALIZE_FAILED_CLOSING;
@@ -413,7 +415,9 @@ CWSWidgetContainer.prototype.start = function(options, webStoreUrl) {
this.webStoreUrl_ = webStoreUrl;
this.options_ = options;
- this.webstoreButton_.hidden = (webStoreUrl === null);
+ this.webstoreButton_.hidden = !webStoreUrl;
+ this.webstoreButton_.classList.toggle('cws-widget-webstore-button',
+ !!webStoreUrl);
this.webview_ =
/** @type {!WebView} */(this.document_.createElement('webview'));
@@ -469,7 +473,7 @@ CWSWidgetContainer.prototype.start = function(options, webStoreUrl) {
CWSWidgetContainer.prototype.onWebstoreLinkActivated_ = function(e) {
if (!this.webStoreUrl_)
return;
- util.visitURL(this.webStoreUrl_);
+ window.open(this.webStoreUrl_);
this.state_ = CWSWidgetContainer.State.OPENING_WEBSTORE_CLOSING;
this.reportDone_();
};

Powered by Google App Engine
This is Rietveld 408576698