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

Side by Side Diff: chrome/browser/resources/file_manager/js/app_installer.js

Issue 39123003: [Files.app] Split the JavaScript files into subdirectories: common, background, and foreground (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed test failure. Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 'use strict';
6
7 /**
8 * Manage the installation of apps.
9 *
10 * @param {string} itemId Item id to be installed.
11 * @constructor
12 * @extends {cr.EventType}
13 */
14 function AppInstaller(itemId) {
15 this.itemId_ = itemId;
16 this.callback_ = null;
17
18 Object.seal(this);
19 }
20
21 AppInstaller.prototype = {
22 };
23
24 /**
25 * Type of result.
26 *
27 * @enum {string}
28 * @const
29 */
30 AppInstaller.Result = {
31 SUCCESS: 'AppInstaller.success',
32 CANCELLED: 'AppInstaller.cancelled',
33 ERROR: 'AppInstaller.error'
34 };
35 Object.freeze(AppInstaller.Result);
36
37 /**
38 * Error message for user cancellation. This must be match with the constant
39 * 'kUserCancelledError' in C/B/extensions/webstore_standalone_installer.cc.
40 * @type {string}
41 * @const
42 * @private
43 */
44 AppInstaller.USER_CANCELLED_ERROR_STR_ = 'User cancelled install';
45
46 /**
47 * Start an installation.
48 * @param {function(boolean, string)} callback Called when the installation is
49 * finished.
50 */
51 AppInstaller.prototype.install = function(callback) {
52 this.callback_ = callback;
53 chrome.fileBrowserPrivate.installWebstoreItem(
54 this.itemId_,
55 function() {
56 this.onInstallCompleted_(chrome.runtime.lastError);
57 }.bind(this));
58 };
59
60 /**
61 * Called when the installation is completed.
62 *
63 * @param {{message: string}?} error Null if the installation is success,
64 * otherwise an object which contains error message.
65 * @private
66 */
67 AppInstaller.prototype.onInstallCompleted_ = function(error) {
68 var installerResult = AppInstaller.Result.SUCCESS;
69 var errorMessage = '';
70 if (error) {
71 installerResult =
72 error.message == AppInstaller.USER_CANCELLED_ERROR_STR_ ?
73 AppInstaller.Result.CANCELLED :
74 AppInstaller.Result.ERROR;
75 errorMessage = error.message;
76 }
77 this.callback_(installerResult, errorMessage);
78 this.callback_ = null;
79 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/js/action_choice_util.js ('k') | chrome/browser/resources/file_manager/js/async_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698