| Index: ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
|
| diff --git a/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js b/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
|
| index bd356a0ecaf67397b8f5410fd1428244c79114b4..2c7c38c50ee7a4f78c980b8c072ff69da8d60191 100644
|
| --- a/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
|
| +++ b/ui/file_manager/file_manager/foreground/js/ui/suggest_apps_dialog.js
|
| @@ -21,13 +21,12 @@
|
| var WEBVIEW_HEIGHT = 480;
|
|
|
| /**
|
| - * The URL of the widget showing suggested apps.
|
| + * The URL of the widget.
|
| * @type {string}
|
| * @const
|
| */
|
| var CWS_WIDGET_URL =
|
| 'https://clients5.google.com/webstore/wall/cros-widget-container';
|
| -
|
| /**
|
| * The origin of the widget.
|
| * @type {string}
|
| @@ -63,7 +62,6 @@
|
| this.frame_.appendChild(this.buttons_);
|
|
|
| this.webstoreButton_ = this.document_.createElement('div');
|
| - this.webstoreButton_.hidden = true;
|
| this.webstoreButton_.id = 'webstore-button';
|
| this.webstoreButton_.innerHTML = str('SUGGEST_DIALOG_LINK_TO_WEBSTORE');
|
| this.webstoreButton_.addEventListener(
|
| @@ -74,11 +72,13 @@
|
|
|
| this.webview_ = null;
|
| this.accessToken_ = null;
|
| - this.widgetUrl_ = state.overrideCwsContainerUrlForTest || CWS_WIDGET_URL;
|
| - this.widgetOrigin_ = state.overrideCwsContainerOriginForTest ||
|
| - CWS_WIDGET_ORIGIN;
|
| -
|
| - this.options_ = null;
|
| + this.widgetUrl_ =
|
| + state.overrideCwsContainerUrlForTest || CWS_WIDGET_URL;
|
| + this.widgetOrigin_ =
|
| + state.overrideCwsContainerOriginForTest || CWS_WIDGET_ORIGIN;
|
| +
|
| + this.extension_ = null;
|
| + this.mime_ = null;
|
| this.installingItemId_ = null;
|
| this.state_ = SuggestAppsDialog.State.UNINITIALIZED;
|
|
|
| @@ -176,7 +176,7 @@
|
| /**
|
| * Shows suggest-apps dialog by file extension and mime.
|
| *
|
| - * @param {string} extension Extension of the file with a trailing dot.
|
| + * @param {string} extension Extension of the file.
|
| * @param {string} mime Mime of the file.
|
| * @param {function(boolean)} onDialogClosed Called when the dialog is closed.
|
| * The argument is the result of installation: true if an app is installed,
|
| @@ -184,58 +184,32 @@
|
| */
|
| SuggestAppsDialog.prototype.showByExtensionAndMime =
|
| function(extension, mime, onDialogClosed) {
|
| - assert(extension && extension[0] === '.');
|
| - this.showInternal_(
|
| - {
|
| - file_extension: extension.substr(1),
|
| - mime_type: mime
|
| - },
|
| - str('SUGGEST_DIALOG_TITLE'),
|
| - FileTasks.createWebStoreLink(extension, mime),
|
| - onDialogClosed);
|
| -};
|
| -
|
| -/**
|
| - * Shows suggest-apps dialog for FSP API
|
| - * @param {function(boolean)} onDialogClosed Called when the dialog is closed.
|
| - * The argument is the result of installation: true if an app is installed,
|
| - * false otherwise.
|
| - */
|
| -SuggestAppsDialog.prototype.showProviders = function(onDialogClosed) {
|
| - this.showInternal_(
|
| - {
|
| - file_system_provider: true
|
| - },
|
| - str('SUGGEST_DIALOG_FOR_PROVIDERS_TITLE'),
|
| - null /* webStoreUrl */,
|
| - onDialogClosed);
|
| + this.text_.hidden = true;
|
| + this.dialogText_ = '';
|
| + this.showInternal_(null, extension, mime, onDialogClosed);
|
| };
|
|
|
| /**
|
| * Internal method to show a dialog. This should be called only from 'Suggest.
|
| * appDialog.showXxxx()' functions.
|
| *
|
| - * @param {!Object<string, *>} options Map of options for the dialog.
|
| - * @param {string} title Title of the dialog.
|
| - * @param {?string} webStoreUrl Url for more results. Null if not supported.
|
| + * @param {?string} filename Filename (without extension) of the file.
|
| + * @param {?string} extension Extension of the file.
|
| + * @param {?string} mime Mime of the file.
|
| * @param {function(boolean)} onDialogClosed Called when the dialog is closed.
|
| * The argument is the result of installation: true if an app is installed,
|
| * false otherwise.
|
| * @private
|
| */
|
| SuggestAppsDialog.prototype.showInternal_ =
|
| - function(options, title, webStoreUrl, onDialogClosed) {
|
| + function(filename, extension, mime, onDialogClosed) {
|
| if (this.state_ != SuggestAppsDialog.State.UNINITIALIZED) {
|
| console.error('Invalid state.');
|
| return;
|
| }
|
|
|
| - this.text_.hidden = true;
|
| - this.webstoreButton_.hidden = (webStoreUrl === null);
|
| - this.dialogText_ = '';
|
| -
|
| - this.webStoreUrl_ = webStoreUrl;
|
| - this.options_ = options;
|
| + this.extension_ = extension;
|
| + this.mimeType_ = mime;
|
| this.onDialogClosed_ = onDialogClosed;
|
| this.state_ = SuggestAppsDialog.State.INITIALIZING;
|
|
|
| @@ -250,6 +224,7 @@
|
| return;
|
| }
|
|
|
| + var title = str('SUGGEST_DIALOG_TITLE');
|
| var show = this.dialogText_ ?
|
| FileManagerDialogBase.prototype.showTitleAndTextDialog.call(
|
| this, title, this.dialogText_) :
|
| @@ -284,11 +259,9 @@
|
|
|
| this.webviewClient_ = new CWSContainerClient(
|
| this.webview_,
|
| - WEBVIEW_WIDTH,
|
| - WEBVIEW_HEIGHT,
|
| - this.widgetUrl_,
|
| - this.widgetOrigin_,
|
| - this.options_);
|
| + extension, mime, filename,
|
| + WEBVIEW_WIDTH, WEBVIEW_HEIGHT,
|
| + this.widgetUrl_, this.widgetOrigin_);
|
| this.webviewClient_.addEventListener(CWSContainerClient.Events.LOADED,
|
| this.onWidgetLoaded_.bind(this));
|
| this.webviewClient_.addEventListener(CWSContainerClient.Events.LOAD_FAILED,
|
| @@ -306,9 +279,9 @@
|
| * @private
|
| */
|
| SuggestAppsDialog.prototype.onWebstoreLinkClicked_ = function(e) {
|
| - if (!this.webStoreUrl_)
|
| - return;
|
| - util.visitURL(this.webStoreUrl_);
|
| + var webStoreUrl =
|
| + FileTasks.createWebStoreLink(this.extension_, this.mimeType_);
|
| + util.visitURL(webStoreUrl);
|
| this.state_ = SuggestAppsDialog.State.OPENING_WEBSTORE_CLOSING;
|
| this.hide();
|
| };
|
| @@ -454,8 +427,8 @@
|
|
|
| this.webviewContainer_.removeChild(this.webview_);
|
| this.webview_ = null;
|
| - this.webStoreUrl_ = null;
|
| - this.options_ = null;
|
| + this.extension_ = null;
|
| + this.mime_ = null;
|
|
|
| FileManagerDialogBase.prototype.hide.call(
|
| this,
|
|
|