| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Start an installation. | 47 * Start an installation. |
| 48 * @param {function(boolean, string)} callback Called when the installation is | 48 * @param {function(boolean, string)} callback Called when the installation is |
| 49 * finished. | 49 * finished. |
| 50 */ | 50 */ |
| 51 AppInstaller.prototype.install = function(callback) { | 51 AppInstaller.prototype.install = function(callback) { |
| 52 this.callback_ = callback; | 52 this.callback_ = callback; |
| 53 chrome.fileBrowserPrivate.installWebstoreItem( | 53 chrome.fileBrowserPrivate.installWebstoreItem( |
| 54 this.itemId_, | 54 this.itemId_, |
| 55 false, // Shows installation prompt. |
| 55 function() { | 56 function() { |
| 56 this.onInstallCompleted_(chrome.runtime.lastError); | 57 this.onInstallCompleted_(chrome.runtime.lastError); |
| 57 }.bind(this)); | 58 }.bind(this)); |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 /** | 61 /** |
| 61 * Called when the installation is completed. | 62 * Called when the installation is completed. |
| 62 * | 63 * |
| 63 * @param {{message: string}?} error Null if the installation is success, | 64 * @param {{message: string}?} error Null if the installation is success, |
| 64 * otherwise an object which contains error message. | 65 * otherwise an object which contains error message. |
| 65 * @private | 66 * @private |
| 66 */ | 67 */ |
| 67 AppInstaller.prototype.onInstallCompleted_ = function(error) { | 68 AppInstaller.prototype.onInstallCompleted_ = function(error) { |
| 68 var installerResult = AppInstaller.Result.SUCCESS; | 69 var installerResult = AppInstaller.Result.SUCCESS; |
| 69 var errorMessage = ''; | 70 var errorMessage = ''; |
| 70 if (error) { | 71 if (error) { |
| 71 installerResult = | 72 installerResult = |
| 72 error.message == AppInstaller.USER_CANCELLED_ERROR_STR_ ? | 73 error.message == AppInstaller.USER_CANCELLED_ERROR_STR_ ? |
| 73 AppInstaller.Result.CANCELLED : | 74 AppInstaller.Result.CANCELLED : |
| 74 AppInstaller.Result.ERROR; | 75 AppInstaller.Result.ERROR; |
| 75 errorMessage = error.message; | 76 errorMessage = error.message; |
| 76 } | 77 } |
| 77 this.callback_(installerResult, errorMessage); | 78 this.callback_(installerResult, errorMessage); |
| 78 this.callback_ = null; | 79 this.callback_ = null; |
| 79 }; | 80 }; |
| OLD | NEW |