| Index: chrome/browser/resources/file_manager/js/cws_container_client.js
|
| diff --git a/chrome/browser/resources/file_manager/js/cws_container_client.js b/chrome/browser/resources/file_manager/js/cws_container_client.js
|
| index 9e7718f4d5a188c632f825a706f402b637ab9639..45f086610df831bfe7ac98121fd7c6643fbd201c 100644
|
| --- a/chrome/browser/resources/file_manager/js/cws_container_client.js
|
| +++ b/chrome/browser/resources/file_manager/js/cws_container_client.js
|
| @@ -36,6 +36,19 @@ CWSContainerClient.prototype = {
|
| };
|
|
|
| /**
|
| + * Events CWSContainerClient fires
|
| + *
|
| + * @enum {string}
|
| + * @const
|
| + */
|
| +CWSContainerClient.Events = {
|
| + LOADED: 'CWSContainerClient.Events.LOADED',
|
| + LOAD_FAILED: 'CWSContainerClient.Events.LOAD_FAILED',
|
| + REQUEST_INSTALL: 'CWSContainerClient.Events.REQUEST_INSTALL'
|
| +};
|
| +Object.freeze(CWSContainerClient.Events);
|
| +
|
| +/**
|
| * Handles messages from the widget
|
| * @param {Event} event Message event.
|
| * @private
|
| @@ -47,7 +60,10 @@ CWSContainerClient.prototype.onMessage_ = function(event) {
|
| var data = event.data;
|
| switch (data['message']) {
|
| case 'widget_loaded':
|
| - // Do nothing. Waits for user action and next message.
|
| + this.onWidgetLoaded_();
|
| + break;
|
| + case 'widget_load_failed':
|
| + this.onWidgetLoadFailed_();
|
| break;
|
| case 'before_install':
|
| this.sendInstallRequest_(data['item_id']);
|
| @@ -70,12 +86,28 @@ CWSContainerClient.prototype.onLoadStop_ = function(event) {
|
| };
|
|
|
| /**
|
| + * Called when the widget is loaded successfully.
|
| + * @private
|
| + */
|
| +CWSContainerClient.prototype.onWidgetLoaded_ = function() {
|
| + cr.dispatchSimpleEvent(this, CWSContainerClient.Events.LOADED);
|
| +};
|
| +
|
| +/**
|
| + * Called when the widget is failed to load.
|
| + * @private
|
| + */
|
| +CWSContainerClient.prototype.onWidgetLoadFailed_ = function() {
|
| + this.sendWidgetLoadFailed_();
|
| +};
|
| +
|
| +/**
|
| * Called when receiving the 'loadabort' event from <webview>.
|
| * @param {Event} event Message event.
|
| * @private
|
| */
|
| CWSContainerClient.prototype.onLoadAbort_ = function(event) {
|
| - this.sendWebviewLoadAbort_();
|
| + this.sendWidgetLoadFailed_();
|
| };
|
|
|
| /**
|
| @@ -92,11 +124,11 @@ CWSContainerClient.prototype.onInstallCompleted = function(result, itemId) {
|
| };
|
|
|
| /**
|
| - * Send the abort event to the suggest-app dialog.
|
| + * Send the fail message to the suggest-app dialog.
|
| * @private
|
| */
|
| -CWSContainerClient.prototype.sendWebviewLoadAbort_ = function() {
|
| - this.dispatchEvent(new cr.Event('webview-load-abort'));
|
| +CWSContainerClient.prototype.sendWidgetLoadFailed_ = function() {
|
| + cr.dispatchSimpleEvent(this, CWSContainerClient.Events.LOAD_FAILED);
|
| };
|
|
|
| /**
|
| @@ -106,7 +138,7 @@ CWSContainerClient.prototype.sendWebviewLoadAbort_ = function() {
|
| * @private
|
| */
|
| CWSContainerClient.prototype.sendInstallRequest_ = function(itemId) {
|
| - var event = new cr.Event('install-request');
|
| + var event = new cr.Event(CWSContainerClient.Events.REQUEST_INSTALL);
|
| event.itemId = itemId;
|
| this.dispatchEvent(event);
|
| };
|
|
|