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

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

Issue 9835039: Make app_custom_bindings.js lazily evaluated so it doesn't execute on every page load. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lazy load webstore bindings as well 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
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 app API. 5 // Custom bindings for the app API.
6 6
7 var appNatives = requireNative('app'); 7 var appNatives = requireNative('app');
8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
9 8
10 chrome.app = { 9 // This becomes chrome.app
10 var app = {
11 getIsInstalled: appNatives.GetIsInstalled, 11 getIsInstalled: appNatives.GetIsInstalled,
12 install: appNatives.Install, 12 install: appNatives.Install,
13 getDetails: appNatives.GetDetails, 13 getDetails: appNatives.GetDetails,
14 getDetailsForFrame: appNatives.GetDetailsForFrame 14 getDetailsForFrame: appNatives.GetDetailsForFrame
15 }; 15 };
16 16
17 // Tricky; "getIsInstalled" is actually exposed as the getter "isInstalled", 17 // Tricky; "getIsInstalled" is actually exposed as the getter "isInstalled",
18 // but we don't have a way to express this in the schema JSON (nor is it 18 // but we don't have a way to express this in the schema JSON (nor is it
19 // worth it for this one special case). 19 // worth it for this one special case).
20 // 20 //
21 // So, define it manually, and let the getIsInstalled function act as its 21 // So, define it manually, and let the getIsInstalled function act as its
22 // documentation. 22 // documentation.
23 chrome.app.__defineGetter__('isInstalled', appNatives.GetIsInstalled); 23 app.__defineGetter__('isInstalled', appNatives.GetIsInstalled);
24 24
25 // Called by app_bindings.cc. 25 // Called by app_bindings.cc.
26 chromeHidden.app = { 26 // This becomes chromeHidden.app
27 var chromeHiddenApp = {
27 onGetAppNotifyChannelResponse: function(channelId, error, callbackId) { 28 onGetAppNotifyChannelResponse: function(channelId, error, callbackId) {
28 if (callbackId) { 29 if (callbackId) {
29 callbacks[callbackId](channelId, error); 30 callbacks[callbackId](channelId, error);
30 delete callbacks[callbackId]; 31 delete callbacks[callbackId];
31 } 32 }
32 } 33 }
33 }; 34 };
34 35
35 // appNotification stuff. 36 // appNotification stuff.
36 // 37 //
37 // TODO(kalman): move this stuff to its own custom bindings. 38 // TODO(kalman): move this stuff to its own custom bindings.
38 // It will be bit tricky since I'll need to look into why there are 39 // It will be bit tricky since I'll need to look into why there are
39 // permissions defined for app notifications, yet this always sets it up? 40 // permissions defined for app notifications, yet this always sets it up?
40 var callbacks = {}; 41 var callbacks = {};
41 var nextCallbackId = 1; 42 var nextCallbackId = 1;
42 43
43 chrome.appNotifications = { 44 // This becomes chrome.appNotifications.
45 var appNotifications = {
44 getChannel: function getChannel(clientId, callback) { 46 getChannel: function getChannel(clientId, callback) {
45 var callbackId = 0; 47 var callbackId = 0;
46 if (callback) { 48 if (callback) {
47 callbackId = nextCallbackId++; 49 callbackId = nextCallbackId++;
48 callbacks[callbackId] = callback; 50 callbacks[callbackId] = callback;
49 } 51 }
50 appNatives.GetAppNotifyChannel(clientId, callbackId); 52 appNatives.GetAppNotifyChannel(clientId, callbackId);
51 } 53 }
52 }; 54 };
55
56 exports.chromeApp = app;
not at google - send to devlin 2012/03/25 22:42:58 could you add like "must match the names in extens
koz (OOO until 15th September) 2012/03/26 01:36:09 Done.
57 exports.chromeAppNotifications = appNotifications;
58 exports.chromeHiddenApp = chromeHiddenApp;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698