Commit 4b580bc3 authored by yoshiki@chromium.org's avatar yoshiki@chromium.org

[Files.app] Refinement events of suggest app dialog

Major changes.
- Add animation on laading
- Add a spinner on loading
- Handle failure of widget loading
- Refine the internal states of SuggestAppDialog

BUG=240152
TEST=manual
R=hirono@chromium.org

Review URL: https://codereview.chromium.org/23717007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220553 0039d316-1c4b-4281-b951-d872f2087c98
parent e86e2bed
...@@ -1860,6 +1860,11 @@ menuitem#thumbnail-view[lead]:not([disabled]) { ...@@ -1860,6 +1860,11 @@ menuitem#thumbnail-view[lead]:not([disabled]) {
#suggest-app-dialog #webview-container { #suggest-app-dialog #webview-container {
border-bottom: solid 2px #bbb; border-bottom: solid 2px #bbb;
border-top: solid 2px #bbb; border-top: solid 2px #bbb;
transition: height 200ms ease;
}
#suggest-app-dialog #webview-container:not(.loaded) webview {
visibility: hidden;
} }
#suggest-app-dialog .cr-dialog-buttons, #suggest-app-dialog .cr-dialog-buttons,
......
...@@ -35,6 +35,19 @@ CWSContainerClient.prototype = { ...@@ -35,6 +35,19 @@ CWSContainerClient.prototype = {
__proto__: cr.EventTarget.prototype __proto__: cr.EventTarget.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 * Handles messages from the widget
* @param {Event} event Message event. * @param {Event} event Message event.
...@@ -47,7 +60,10 @@ CWSContainerClient.prototype.onMessage_ = function(event) { ...@@ -47,7 +60,10 @@ CWSContainerClient.prototype.onMessage_ = function(event) {
var data = event.data; var data = event.data;
switch (data['message']) { switch (data['message']) {
case 'widget_loaded': case 'widget_loaded':
// Do nothing. Waits for user action and next message. this.onWidgetLoaded_();
break;
case 'widget_load_failed':
this.onWidgetLoadFailed_();
break; break;
case 'before_install': case 'before_install':
this.sendInstallRequest_(data['item_id']); this.sendInstallRequest_(data['item_id']);
...@@ -69,13 +85,29 @@ CWSContainerClient.prototype.onLoadStop_ = function(event) { ...@@ -69,13 +85,29 @@ 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>. * Called when receiving the 'loadabort' event from <webview>.
* @param {Event} event Message event. * @param {Event} event Message event.
* @private * @private
*/ */
CWSContainerClient.prototype.onLoadAbort_ = function(event) { CWSContainerClient.prototype.onLoadAbort_ = function(event) {
this.sendWebviewLoadAbort_(); this.sendWidgetLoadFailed_();
}; };
/** /**
...@@ -92,11 +124,11 @@ CWSContainerClient.prototype.onInstallCompleted = function(result, itemId) { ...@@ -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 * @private
*/ */
CWSContainerClient.prototype.sendWebviewLoadAbort_ = function() { CWSContainerClient.prototype.sendWidgetLoadFailed_ = function() {
this.dispatchEvent(new cr.Event('webview-load-abort')); cr.dispatchSimpleEvent(this, CWSContainerClient.Events.LOAD_FAILED);
}; };
/** /**
...@@ -106,7 +138,7 @@ CWSContainerClient.prototype.sendWebviewLoadAbort_ = function() { ...@@ -106,7 +138,7 @@ CWSContainerClient.prototype.sendWebviewLoadAbort_ = function() {
* @private * @private
*/ */
CWSContainerClient.prototype.sendInstallRequest_ = function(itemId) { CWSContainerClient.prototype.sendInstallRequest_ = function(itemId) {
var event = new cr.Event('install-request'); var event = new cr.Event(CWSContainerClient.Events.REQUEST_INSTALL);
event.itemId = itemId; event.itemId = itemId;
this.dispatchEvent(event); this.dispatchEvent(event);
}; };
......
...@@ -2355,9 +2355,9 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -2355,9 +2355,9 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
tasks.init(urls, mimeTypes); tasks.init(urls, mimeTypes);
tasks.executeDefault(); tasks.executeDefault();
}.bind(this), }.bind(this),
// Failure callback.
function() {},
// Cancelled callback. // Cancelled callback.
function() {},
// Failure callback.
showAlert); showAlert);
}.bind(this)); }.bind(this));
} }
...@@ -2397,11 +2397,17 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -2397,11 +2397,17 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
var mime = props[0].contentMimeType; var mime = props[0].contentMimeType;
this.suggestAppsDialog.show( this.suggestAppsDialog.show(
extension, mime, extension, mime,
function(installed) { function(result) {
if (installed) switch (result) {
onSuccess(); case SuggestAppsDialog.Result.INSTALL_SUCCESSFUL:
else onSuccess();
onCancelled(); break;
case SuggestAppsDialog.Result.FAILED:
onFailure();
break;
default:
onCancelled();
}
}); });
}.bind(this)); }.bind(this));
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment