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

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

Issue 9653022: Revert 125811 - 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, 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
(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 var appNatives = requireNative('app');
8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
9
10 chromeHidden.registerCustomHook('app', function(bindingsAPI) {
11 var apiFunctions = bindingsAPI.apiFunctions;
12
13 // Note: everything in chrome.app is synchronous.
14 apiFunctions.setHandleRequest('getIsInstalled', appNatives.GetIsInstalled);
15 apiFunctions.setHandleRequest('install', appNatives.Install);
16 apiFunctions.setHandleRequest('getDetails', appNatives.GetDetails);
17 apiFunctions.setHandleRequest('getDetailsForFrame',
18 appNatives.GetDetailsForFrame);
19
20 // Tricky; "getIsInstalled" is actually exposed as the getter "isInstalled",
21 // but we don't have a way to express this in the schema JSON (nor is it
22 // worth it for this one special case).
23 //
24 // So, define it manually, and let the getIsInstalled function act as its
25 // documentation.
26 chrome.app.__defineGetter__('isInstalled', appNatives.GetIsInstalled);
27
28 // Called by app_bindings.cc.
29 chromeHidden.app = {
30 onGetAppNotifyChannelResponse: function(channelId, error, callbackId) {
31 if (callbackId) {
32 callbacks[callbackId](channelId, error);
33 delete callbacks[callbackId];
34 }
35 }
36 };
37
38 // appNotification stuff.
39 //
40 // TODO(kalman): move this stuff to its own custom bindings.
41 // It will be bit tricky since I'll need to look into why there are
42 // permissions defined for app notifications, yet this always sets it up?
43 var callbacks = {};
44 var nextCallbackId = 1;
45
46 chrome.appNotifications = new function() {
47 this.getChannel = function(clientId, callback) {
48 var callbackId = 0;
49 if (callback) {
50 callbackId = nextCallbackId++;
51 callbacks[callbackId] = callback;
52 }
53 appNatives.GetAppNotifyChannel(clientId, callbackId);
54 };
55 }();
56 });
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/app.js ('k') | chrome/renderer/resources/extensions/setup_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698