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

Unified Diff: ui/file_manager/file_manager/foreground/js/app_installer.js

Issue 1091943002: Use delegate object for chrome API calls in cws_widget_container (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 8 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
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/cws_container_client.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/app_installer.js
diff --git a/ui/file_manager/file_manager/foreground/js/app_installer.js b/ui/file_manager/file_manager/foreground/js/app_installer.js
index ead973b5b0533b9624e0217df6e527d7c0cc1ad3..2eb321665b49babed3611c959f8a05151aa50d26 100644
--- a/ui/file_manager/file_manager/foreground/js/app_installer.js
+++ b/ui/file_manager/file_manager/foreground/js/app_installer.js
@@ -6,10 +6,14 @@
* Manage the installation of apps.
*
* @param {string} itemId Item id to be installed.
+ * @param {!CWSWidgetContainer.PlatformDelegate} delegate Delegate for accessing
+ * Chrome platform APIs.
* @constructor
* @struct
*/
-function AppInstaller(itemId) {
+function AppInstaller(itemId, delegate) {
+ /** @private {!CWSWidgetContainer.PlatformDelegate} */
+ this.delegate_ = delegate;
this.itemId_ = itemId;
this.callback_ = null;
}
@@ -43,12 +47,9 @@ AppInstaller.USER_CANCELLED_ERROR_STR_ = 'User cancelled install';
*/
AppInstaller.prototype.install = function(callback) {
this.callback_ = callback;
- chrome.fileManagerPrivate.installWebstoreItem(
+ this.delegate_.installWebstoreItem(
this.itemId_,
- false, // Shows installation prompt.
- function() {
- this.onInstallCompleted_(chrome.runtime.lastError);
- }.bind(this));
+ this.onInstallCompleted_.bind(this));
};
/**
@@ -63,8 +64,8 @@ AppInstaller.prototype.cancel = function() {
/**
* Called when the installation is completed.
*
- * @param {!Object|undefined} error Undefined if the installation is success,
- * otherwise an object which contains error message.
+ * @param {?string} error Null if the installation is success,
+ * otherwise error message.
* @private
*/
AppInstaller.prototype.onInstallCompleted_ = function(error) {
@@ -72,14 +73,12 @@ AppInstaller.prototype.onInstallCompleted_ = function(error) {
return;
var installerResult = AppInstaller.Result.SUCCESS;
- var errorMessage = '';
- if (error) {
+ if (error !== null) {
installerResult =
- error.message == AppInstaller.USER_CANCELLED_ERROR_STR_ ?
+ error == AppInstaller.USER_CANCELLED_ERROR_STR_ ?
AppInstaller.Result.CANCELLED :
AppInstaller.Result.ERROR;
- errorMessage = error.message;
}
- this.callback_(installerResult, errorMessage);
+ this.callback_(installerResult, error || '');
this.callback_ = null;
};
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/cws_container_client.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698