| 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 var chrome = chrome || {}; | |
| 6 (function() { | 5 (function() { |
| 7 native function GetChromeHidden(); | 6 var webstoreNatives = requireNative('webstore'); |
| 8 native function Install(preferredStoreUrl, onSuccess, onFailure); | 7 var Install = webstoreNatives.Install; |
| 9 | 8 |
| 10 var chromeHidden = GetChromeHidden(); | 9 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 11 var pendingInstalls = {}; | 10 var pendingInstalls = {}; |
| 12 chrome.webstore = new function() { | 11 chrome.webstore = new function() { |
| 13 this.install = function( | 12 this.install = function( |
| 14 preferredStoreLinkUrl, successCallback, failureCallback) { | 13 preferredStoreLinkUrl, successCallback, failureCallback) { |
| 15 var installId = Install( | 14 var installId = Install( |
| 16 preferredStoreLinkUrl, successCallback, failureCallback); | 15 preferredStoreLinkUrl, successCallback, failureCallback); |
| 17 if (installId !== undefined) { | 16 if (installId !== undefined) { |
| 18 pendingInstalls[installId] = { | 17 pendingInstalls[installId] = { |
| 19 successCallback: successCallback, | 18 successCallback: successCallback, |
| 20 failureCallback: failureCallback | 19 failureCallback: failureCallback |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 if (success && pendingInstall.successCallback) { | 34 if (success && pendingInstall.successCallback) { |
| 36 pendingInstall.successCallback(); | 35 pendingInstall.successCallback(); |
| 37 } else if (!success && pendingInstall.failureCallback) { | 36 } else if (!success && pendingInstall.failureCallback) { |
| 38 pendingInstall.failureCallback(error); | 37 pendingInstall.failureCallback(error); |
| 39 } | 38 } |
| 40 } finally { | 39 } finally { |
| 41 delete pendingInstall[installId]; | 40 delete pendingInstall[installId]; |
| 42 } | 41 } |
| 43 } | 42 } |
| 44 })(); | 43 })(); |
| OLD | NEW |