| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Manage the installation of apps. | 8 * Manage the installation of apps. |
| 9 * | 9 * |
| 10 * @param {string} itemId Item id to be installed. | 10 * @param {string} itemId Item id to be installed. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 * Error message for user cancellation. This must be match with the constant | 37 * Error message for user cancellation. This must be match with the constant |
| 38 * 'kUserCancelledError' in C/B/extensions/webstore_standalone_installer.cc. | 38 * 'kUserCancelledError' in C/B/extensions/webstore_standalone_installer.cc. |
| 39 * @type {string} | 39 * @type {string} |
| 40 * @const | 40 * @const |
| 41 * @private | 41 * @private |
| 42 */ | 42 */ |
| 43 AppInstaller.USER_CANCELLED_ERROR_STR_ = 'User cancelled install'; | 43 AppInstaller.USER_CANCELLED_ERROR_STR_ = 'User cancelled install'; |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Start an installation. | 46 * Start an installation. |
| 47 * @param {function(boolean, string)} callback Called when the installation is | 47 * @param {function(AppInstaller.Result, string)} callback Called when the |
| 48 * finished. | 48 * installation is finished. |
| 49 */ | 49 */ |
| 50 AppInstaller.prototype.install = function(callback) { | 50 AppInstaller.prototype.install = function(callback) { |
| 51 this.callback_ = callback; | 51 this.callback_ = callback; |
| 52 chrome.fileManagerPrivate.installWebstoreItem( | 52 chrome.fileManagerPrivate.installWebstoreItem( |
| 53 this.itemId_, | 53 this.itemId_, |
| 54 false, // Shows installation prompt. | 54 false, // Shows installation prompt. |
| 55 function() { | 55 function() { |
| 56 this.onInstallCompleted_(chrome.runtime.lastError); | 56 this.onInstallCompleted_(chrome.runtime.lastError); |
| 57 }.bind(this)); | 57 }.bind(this)); |
| 58 }; | 58 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 70 if (error) { | 70 if (error) { |
| 71 installerResult = | 71 installerResult = |
| 72 error.message == AppInstaller.USER_CANCELLED_ERROR_STR_ ? | 72 error.message == AppInstaller.USER_CANCELLED_ERROR_STR_ ? |
| 73 AppInstaller.Result.CANCELLED : | 73 AppInstaller.Result.CANCELLED : |
| 74 AppInstaller.Result.ERROR; | 74 AppInstaller.Result.ERROR; |
| 75 errorMessage = error.message; | 75 errorMessage = error.message; |
| 76 } | 76 } |
| 77 this.callback_(installerResult, errorMessage); | 77 this.callback_(installerResult, errorMessage); |
| 78 this.callback_ = null; | 78 this.callback_ = null; |
| 79 }; | 79 }; |
| OLD | NEW |