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

Unified Diff: chrome/browser/resources/file_manager/js/cws_container_client.js

Issue 23717007: [Files.app] Refinement events of suggest app dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comment Created 7 years, 4 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: 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);
};
« no previous file with comments | « chrome/browser/resources/file_manager/css/file_manager.css ('k') | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698