Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: chrome/renderer/resources/extensions/webstore_custom_bindings.js

Issue 9838044: Make the chrome.webstore bindings load lazily. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698