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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android compilation Created 7 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 binding for the app API.
6 6
7 var appNatives = requireNative('app'); 7 var appNatives = requireNative('app');
8 var chrome = requireNative('chrome').GetChrome();
9 var GetAvailability = requireNative('v8_context').GetAvailability;
8 10
9 // This becomes chrome.app 11 // This becomes chrome.app
10 var app = { 12 var app = {
11 getIsInstalled: appNatives.GetIsInstalled, 13 getIsInstalled: appNatives.GetIsInstalled,
12 install: appNatives.Install, 14 install: appNatives.Install,
13 getDetails: appNatives.GetDetails, 15 getDetails: appNatives.GetDetails,
14 getDetailsForFrame: appNatives.GetDetailsForFrame, 16 getDetailsForFrame: appNatives.GetDetailsForFrame,
15 runningState: appNatives.GetRunningState 17 runningState: appNatives.GetRunningState
16 }; 18 };
17 19
(...skipping 18 matching lines...) Expand all
36 onInstallStateResponse: function(state, callbackId) { 38 onInstallStateResponse: function(state, callbackId) {
37 if (callbackId) { 39 if (callbackId) {
38 callbacks[callbackId](state); 40 callbacks[callbackId](state);
39 delete callbacks[callbackId]; 41 delete callbacks[callbackId];
40 } 42 }
41 } 43 }
42 }; 44 };
43 45
44 // appNotification stuff. 46 // appNotification stuff.
45 // 47 //
46 // TODO(kalman): move this stuff to its own custom bindings. 48 // TODO(kalman): move this stuff to its own custom binding.
47 // It will be bit tricky since I'll need to look into why there are 49 // It will be bit tricky since I'll need to look into why there are
48 // permissions defined for app notifications, yet this always sets it up? 50 // permissions defined for app notifications, yet this always sets it up?
49 var callbacks = {}; 51 var callbacks = {};
50 var nextCallbackId = 1; 52 var nextCallbackId = 1;
51 53
52 // This becomes chrome.appNotifications. 54 // This becomes chrome.appNotifications.
53 var appNotifications = { 55 var appNotifications = {
54 getChannel: function getChannel(clientId, callback) { 56 getChannel: function getChannel(clientId, callback) {
55 var callbackId = 0; 57 var callbackId = 0;
56 if (callback) { 58 if (callback) {
57 callbackId = nextCallbackId++; 59 callbackId = nextCallbackId++;
58 callbacks[callbackId] = callback; 60 callbacks[callbackId] = callback;
59 } 61 }
60 appNatives.GetAppNotifyChannel(clientId, callbackId); 62 appNatives.GetAppNotifyChannel(clientId, callbackId);
61 } 63 }
62 }; 64 };
63 65
64 app.installState = function getInstallState(callback) { 66 app.installState = function getInstallState(callback) {
65 var callbackId = nextCallbackId++; 67 var callbackId = nextCallbackId++;
66 callbacks[callbackId] = callback; 68 callbacks[callbackId] = callback;
67 appNatives.GetInstallState(callbackId); 69 appNatives.GetInstallState(callbackId);
68 }; 70 };
69 71
70 // These must match the names in InstallAppBindings() in 72 // These must match the names in InstallAppbinding() in
71 // chrome/renderer/extensions/dispatcher.cc. 73 // chrome/renderer/extensions/dispatcher.cc.
72 exports.chromeApp = app; 74 var availability = GetAvailability('app');
73 exports.chromeAppNotifications = appNotifications; 75 if (availability.is_available) {
74 exports.chromeHiddenApp = chromeHiddenApp; 76 exports.chromeApp = app;
77 exports.chromeAppNotifications = appNotifications;
78 exports.chromeHiddenApp = chromeHiddenApp;
79 }
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/apitest.js ('k') | chrome/renderer/resources/extensions/app_runtime_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698