| 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 bindings for the webstore API. | 5 // Custom bindings for the webstore API. |
| 6 | 6 |
| 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | |
| 8 var webstoreNatives = requireNative('webstore'); | 7 var webstoreNatives = requireNative('webstore'); |
| 9 | 8 |
| 10 function Installer() { | 9 function Installer() { |
| 11 this._pendingInstalls = {}; | 10 this._pendingInstalls = {}; |
| 12 } | 11 } |
| 13 | 12 |
| 14 Installer.prototype.install = function(url, onSuccess, onFailure) { | 13 Installer.prototype.install = function(url, onSuccess, onFailure) { |
| 15 var installId = webstoreNatives.Install(url, onSuccess, onFailure); | 14 var installId = webstoreNatives.Install(url, onSuccess, onFailure); |
| 16 if (installId !== undefined) { | 15 if (installId !== undefined) { |
| 17 if (installId in this._pendingInstalls) | 16 if (installId in this._pendingInstalls) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 pendingInstall.onSuccess(); | 34 pendingInstall.onSuccess(); |
| 36 else if (!success && pendingInstall.onFailure) | 35 else if (!success && pendingInstall.onFailure) |
| 37 pendingInstall.onFailure(error); | 36 pendingInstall.onFailure(error); |
| 38 } finally { | 37 } finally { |
| 39 delete this._pendingInstalls[installId]; | 38 delete this._pendingInstalls[installId]; |
| 40 } | 39 } |
| 41 }; | 40 }; |
| 42 | 41 |
| 43 var installer = new Installer(); | 42 var installer = new Installer(); |
| 44 | 43 |
| 45 chrome.webstore = { | 44 var chromeWebstore = { |
| 46 install: function install(url, onSuccess, onFailure) { | 45 install: function install(url, onSuccess, onFailure) { |
| 47 installer.install(url, onSuccess, onFailure); | 46 installer.install(url, onSuccess, onFailure); |
| 48 } | 47 } |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 // Called by webstore_bindings.cc. | 50 // Called by webstore_bindings.cc. |
| 52 chromeHidden.webstore = { | 51 var chromeHiddenWebstore = { |
| 53 onInstallResponse: function(installId, success, error) { | 52 onInstallResponse: function(installId, success, error) { |
| 54 installer.onInstallResponse(installId, success, error); | 53 installer.onInstallResponse(installId, success, error); |
| 55 } | 54 } |
| 56 }; | 55 }; |
| 56 |
| 57 exports.chromeWebstore = chromeWebstore; |
| 58 exports.chromeHiddenWebstore = chromeHiddenWebstore; |
| OLD | NEW |