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

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

Issue 12680004: Remove chrome/ code to handle App Notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert sync pref changes 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 bindings for the app API.
6 6
7 var appNatives = requireNative('app'); 7 var appNatives = requireNative('app');
8 8
9 // This becomes chrome.app 9 // This becomes chrome.app
10 var 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 runningState: appNatives.GetRunningState 15 runningState: appNatives.GetRunningState
16 }; 16 };
17 17
18 // Tricky; "getIsInstalled" is actually exposed as the getter "isInstalled", 18 // Tricky; "getIsInstalled" is actually exposed as the getter "isInstalled",
19 // but we don't have a way to express this in the schema JSON (nor is it 19 // but we don't have a way to express this in the schema JSON (nor is it
20 // worth it for this one special case). 20 // worth it for this one special case).
21 // 21 //
22 // So, define it manually, and let the getIsInstalled function act as its 22 // So, define it manually, and let the getIsInstalled function act as its
23 // documentation. 23 // documentation.
24 app.__defineGetter__('isInstalled', appNatives.GetIsInstalled); 24 app.__defineGetter__('isInstalled', appNatives.GetIsInstalled);
25 25
26 // Called by app_bindings.cc. 26 // Called by app_bindings.cc.
27 // This becomes chromeHidden.app 27 // This becomes chromeHidden.app
28 var chromeHiddenApp = { 28 var chromeHiddenApp = {
29 onGetAppNotifyChannelResponse: function(channelId, error, callbackId) {
30 if (callbackId) {
31 callbacks[callbackId](channelId, error);
32 delete callbacks[callbackId];
33 }
34 },
35
36 onInstallStateResponse: function(state, callbackId) { 29 onInstallStateResponse: function(state, callbackId) {
37 if (callbackId) { 30 if (callbackId) {
38 callbacks[callbackId](state); 31 callbacks[callbackId](state);
39 delete callbacks[callbackId]; 32 delete callbacks[callbackId];
40 } 33 }
41 } 34 }
42 }; 35 };
43 36
44 // appNotification stuff.
45 //
46 // TODO(kalman): move this stuff to its own custom bindings. 37 // TODO(kalman): move this stuff to its own custom bindings.
47 // 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?
49 var callbacks = {}; 38 var callbacks = {};
50 var nextCallbackId = 1; 39 var nextCallbackId = 1;
51 40
52 // This becomes chrome.appNotifications.
53 var appNotifications = {
54 getChannel: function getChannel(clientId, callback) {
55 var callbackId = 0;
56 if (callback) {
57 callbackId = nextCallbackId++;
58 callbacks[callbackId] = callback;
59 }
60 appNatives.GetAppNotifyChannel(clientId, callbackId);
61 }
62 };
63
64 app.installState = function getInstallState(callback) { 41 app.installState = function getInstallState(callback) {
65 var callbackId = nextCallbackId++; 42 var callbackId = nextCallbackId++;
66 callbacks[callbackId] = callback; 43 callbacks[callbackId] = callback;
67 appNatives.GetInstallState(callbackId); 44 appNatives.GetInstallState(callbackId);
68 }; 45 };
69 46
70 // These must match the names in InstallAppBindings() in 47 // These must match the names in InstallAppBindings() in
71 // chrome/renderer/extensions/dispatcher.cc. 48 // chrome/renderer/extensions/dispatcher.cc.
72 exports.chromeApp = app; 49 exports.chromeApp = app;
73 exports.chromeAppNotifications = appNotifications;
74 exports.chromeHiddenApp = chromeHiddenApp; 50 exports.chromeHiddenApp = chromeHiddenApp;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698