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

Side by Side Diff: components/chrome_apps/webstore_widget/cws_widget/cws_widget_container.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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * CWSWidgetContainer contains a Chrome Web Store widget that displays list of 6 * CWSWidgetContainer contains a Chrome Web Store widget that displays list of
7 * apps that satisfy certain constraints (e.g. fileHandler apps that can handle 7 * apps that satisfy certain constraints (e.g. fileHandler apps that can handle
8 * files with specific file extension or MIME type) and enables the user to 8 * files with specific file extension or MIME type) and enables the user to
9 * install apps directly from it. 9 * install apps directly from it.
10 * CWSWidgetContainer implements client side of the widget, which handles 10 * CWSWidgetContainer implements client side of the widget, which handles
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 * handle showing the Chrome Web Store webview. 362 * handle showing the Chrome Web Store webview.
363 * @return {Promise} Resolved when the container is ready to be used. 363 * @return {Promise} Resolved when the container is ready to be used.
364 */ 364 */
365 CWSWidgetContainer.prototype.ready = function() { 365 CWSWidgetContainer.prototype.ready = function() {
366 return new Promise(function(resolve, reject) { 366 return new Promise(function(resolve, reject) {
367 if (this.state_ !== CWSWidgetContainer.State.UNINITIALIZED) { 367 if (this.state_ !== CWSWidgetContainer.State.UNINITIALIZED) {
368 reject('Invalid state.'); 368 reject('Invalid state.');
369 return; 369 return;
370 } 370 }
371 371
372 this.spinnerLayerController_.setVisible(true);
373
372 this.metricsRecorder_.recordShowDialog(); 374 this.metricsRecorder_.recordShowDialog();
373 this.metricsRecorder_.startLoad(); 375 this.metricsRecorder_.startLoad();
374 376
375 this.state_ = CWSWidgetContainer.State.GETTING_ACCESS_TOKEN; 377 this.state_ = CWSWidgetContainer.State.GETTING_ACCESS_TOKEN;
376 378
377 this.tokenGetter_.then(function(accessToken) { 379 this.tokenGetter_.then(function(accessToken) {
378 this.state_ = CWSWidgetContainer.State.ACCESS_TOKEN_READY; 380 this.state_ = CWSWidgetContainer.State.ACCESS_TOKEN_READY;
379 this.accessToken_ = accessToken; 381 this.accessToken_ = accessToken;
380 resolve(); 382 resolve();
381 }.bind(this), function(error) { 383 }.bind(this), function(error) {
384 this.spinnerLayerController_.setVisible(false);
382 this.state_ = CWSWidgetContainer.State.UNINITIALIZED; 385 this.state_ = CWSWidgetContainer.State.UNINITIALIZED;
383 reject('Failed to get Web Store access token: ' + error); 386 reject('Failed to get Web Store access token: ' + error);
384 }.bind(this)); 387 }.bind(this));
385 }.bind(this)); 388 }.bind(this));
386 }; 389 };
387 390
388 /** 391 /**
389 * Initializes and starts loading the Chrome Web Store widget webview. 392 * Initializes and starts loading the Chrome Web Store widget webview.
390 * Must not be called before {@code this.ready()} is resolved. 393 * Must not be called before {@code this.ready()} is resolved.
391 * 394 *
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 function(visible) { 819 function(visible) {
817 if (this.visible_ === visible) 820 if (this.visible_ === visible)
818 return; 821 return;
819 822
820 if (this.clearTransition_) 823 if (this.clearTransition_)
821 this.clearTransition_(); 824 this.clearTransition_();
822 825
823 this.visible_ = visible; 826 this.visible_ = visible;
824 827
825 // Spinner should be shown during transition. 828 // Spinner should be shown during transition.
826 if (!this.spinnerLayer_.classList.contains('cws-widget-show-spinner')) 829 this.spinnerLayer_.classList.toggle('cws-widget-show-spinner', true);
827 this.spinnerLayer_.classList.add('cws-widget-show-spinner');
828 830
829 if (this.visible_) { 831 if (this.visible_) {
830 this.spinnerLayer_.focus(); 832 this.spinnerLayer_.focus();
831 } else if (this.focusOnHide_) { 833 } else if (this.focusOnHide_) {
832 this.focusOnHide_.focus(); 834 this.focusOnHide_.focus();
833 } 835 }
834 836
835 if (!this.visible_) 837 if (!this.visible_)
836 this.spinnerLayer_.classList.add('cws-widget-hiding-spinner'); 838 this.spinnerLayer_.classList.add('cws-widget-hiding-spinner');
837 839
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 this.metricsImpl_.recordUserAction('SuggestApps.ShowDialog'); 935 this.metricsImpl_.recordUserAction('SuggestApps.ShowDialog');
934 }; 936 };
935 937
936 CWSWidgetContainer.MetricsRecorder.prototype.startLoad = function() { 938 CWSWidgetContainer.MetricsRecorder.prototype.startLoad = function() {
937 this.metricsImpl_.startInterval('SuggestApps.LoadTime'); 939 this.metricsImpl_.startInterval('SuggestApps.LoadTime');
938 }; 940 };
939 941
940 CWSWidgetContainer.MetricsRecorder.prototype.finishLoad = function() { 942 CWSWidgetContainer.MetricsRecorder.prototype.finishLoad = function() {
941 this.metricsImpl_.recordInterval('SuggestApps.LoadTime'); 943 this.metricsImpl_.recordInterval('SuggestApps.LoadTime');
942 }; 944 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698