| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Custom binding for the webstore API. | 5 // Custom binding for the webstore API. |
| 6 | 6 |
| 7 var webstoreNatives = requireNative('webstore'); | 7 var webstoreNatives = requireNative('webstore'); |
| 8 var Event = require('event_bindings').Event; | 8 var Event = require('event_bindings').Event; |
| 9 | 9 |
| 10 function Installer() { | 10 function Installer() { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 onFailure); | 39 onFailure); |
| 40 if (installId !== undefined) { | 40 if (installId !== undefined) { |
| 41 this._pendingInstall = { | 41 this._pendingInstall = { |
| 42 installId: installId, | 42 installId: installId, |
| 43 onSuccess: onSuccess, | 43 onSuccess: onSuccess, |
| 44 onFailure: onFailure | 44 onFailure: onFailure |
| 45 }; | 45 }; |
| 46 } | 46 } |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 Installer.prototype.onInstallResponse = function(installId, success, error) { | 49 Installer.prototype.onInstallResponse = |
| 50 function(installId, success, error, resultCode) { |
| 50 var pendingInstall = this._pendingInstall; | 51 var pendingInstall = this._pendingInstall; |
| 51 if (!pendingInstall || pendingInstall.installId != installId) { | 52 if (!pendingInstall || pendingInstall.installId != installId) { |
| 52 // TODO(kalman): should this be an error? | 53 // TODO(kalman): should this be an error? |
| 53 return; | 54 return; |
| 54 } | 55 } |
| 55 | 56 |
| 56 try { | 57 try { |
| 57 if (success && pendingInstall.onSuccess) | 58 if (success && pendingInstall.onSuccess) |
| 58 pendingInstall.onSuccess(); | 59 pendingInstall.onSuccess(); |
| 59 else if (!success && pendingInstall.onFailure) | 60 else if (!success && pendingInstall.onFailure) |
| 60 pendingInstall.onFailure(error); | 61 pendingInstall.onFailure(error, resultCode); |
| 61 } catch (e) { | 62 } catch (e) { |
| 62 console.error('Exception in chrome.webstore.install response handler: ' + | 63 console.error('Exception in chrome.webstore.install response handler: ' + |
| 63 e.stack); | 64 e.stack); |
| 64 } finally { | 65 } finally { |
| 65 this._pendingInstall = null; | 66 this._pendingInstall = null; |
| 66 } | 67 } |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 Installer.prototype.onInstallStageChanged = function(installStage) { | 70 Installer.prototype.onInstallStageChanged = function(installStage) { |
| 70 this.onInstallStageChanged.dispatch(installStage); | 71 this.onInstallStageChanged.dispatch(installStage); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 86 | 87 |
| 87 exports.binding = chromeWebstore; | 88 exports.binding = chromeWebstore; |
| 88 | 89 |
| 89 // Called by webstore_bindings.cc. | 90 // Called by webstore_bindings.cc. |
| 90 exports.onInstallResponse = | 91 exports.onInstallResponse = |
| 91 Installer.prototype.onInstallResponse.bind(installer); | 92 Installer.prototype.onInstallResponse.bind(installer); |
| 92 exports.onInstallStageChanged = | 93 exports.onInstallStageChanged = |
| 93 Installer.prototype.onInstallStageChanged.bind(installer); | 94 Installer.prototype.onInstallStageChanged.bind(installer); |
| 94 exports.onDownloadProgress = | 95 exports.onDownloadProgress = |
| 95 Installer.prototype.onDownloadProgress.bind(installer); | 96 Installer.prototype.onDownloadProgress.bind(installer); |
| OLD | NEW |