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

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

Issue 9460002: Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // Custom bindings for the app API.
6
7 (function() {
8
9 native function GetChromeHidden();
10 native function GetIsInstalled();
11 native function Install();
12 native function GetDetails();
13 native function GetDetailsForFrame();
14 native function GetAppNotifyChannel();
15
16 var chromeHidden = GetChromeHidden();
17
18 chromeHidden.registerCustomHook('app', function(bindingsAPI) {
19 var apiFunctions = bindingsAPI.apiFunctions;
20
21 // Note: everything in chrome.app is synchronous.
22 apiFunctions.setHandleRequest('app.getIsInstalled', GetIsInstalled);
23 apiFunctions.setHandleRequest('app.install', Install);
24 apiFunctions.setHandleRequest('app.getDetails', GetDetails);
25 apiFunctions.setHandleRequest('app.getDetailsForFrame', GetDetailsForFrame);
26
27 // Tricky; "getIsInstalled" is actually exposed as the getter "isInstalled",
28 // but we don't have a way to express this in the schema JSON (nor is it
29 // worth it for this one special case).
30 //
31 // So, define it manually, and let the getIsInstalled function act as its
32 // documentation.
33 chrome.app.__defineGetter__('isInstalled', GetIsInstalled);
34
35 // Called by app_bindings.cc.
36 chromeHidden.app = {
37 onGetAppNotifyChannelResponse: function(channelId, error, callbackId) {
38 if (callbackId) {
39 callbacks[callbackId](channelId, error);
40 delete callbacks[callbackId];
41 }
42 }
43 };
44
45 // appNotification stuff.
46 //
47 // TODO(kalman): move this stuff to its own custom bindings.
48 // It will be bit tricky since I'll need to look into why there are
49 // permissions defined for app notifications, yet this always sets it up?
50 var callbacks = {};
51 var nextCallbackId = 1;
52
53 chrome.appNotifications = new function() {
54 this.getChannel = function(clientId, callback) {
55 var callbackId = 0;
56 if (callback) {
57 callbackId = nextCallbackId++;
58 callbacks[callbackId] = callback;
59 }
60 GetAppNotifyChannel(clientId, callbackId);
61 };
62 }();
63 });
64
65 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698