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