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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/app_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/app_custom_bindings.js b/chrome/renderer/resources/extensions/app_custom_bindings.js
new file mode 100644
index 0000000000000000000000000000000000000000..1e800dd70405624ab22f6126b3be7a570764166c
--- /dev/null
+++ b/chrome/renderer/resources/extensions/app_custom_bindings.js
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Custom bindings for the app API.
+
+(function() {
+
+native function GetChromeHidden();
+native function GetIsInstalled();
+native function Install();
+native function GetDetails();
+native function GetDetailsForFrame();
+native function GetAppNotifyChannel();
+
+var chromeHidden = GetChromeHidden();
+
+chromeHidden.registerCustomHook('app', function(bindingsAPI) {
+ var apiFunctions = bindingsAPI.apiFunctions;
+
+ // Note: everything in chrome.app is synchronous.
+ apiFunctions.setHandleRequest('app.getIsInstalled', GetIsInstalled);
+ apiFunctions.setHandleRequest('app.install', Install);
+ apiFunctions.setHandleRequest('app.getDetails', GetDetails);
+ apiFunctions.setHandleRequest('app.getDetailsForFrame', GetDetailsForFrame);
+
+ // Tricky; "getIsInstalled" is actually exposed as the getter "isInstalled",
+ // but we don't have a way to express this in the schema JSON (nor is it
+ // worth it for this one special case).
+ //
+ // So, define it manually, and let the getIsInstalled function act as its
+ // documentation.
+ chrome.app.__defineGetter__('isInstalled', GetIsInstalled);
+
+ // Called by app_bindings.cc.
+ chromeHidden.app = {
+ onGetAppNotifyChannelResponse: function(channelId, error, callbackId) {
+ if (callbackId) {
+ callbacks[callbackId](channelId, error);
+ delete callbacks[callbackId];
+ }
+ }
+ };
+
+ // appNotification stuff.
+ //
+ // TODO(kalman): move this stuff to its own custom bindings.
+ // It will be bit tricky since I'll need to look into why there are
+ // permissions defined for app notifications, yet this always sets it up?
+ var callbacks = {};
+ var nextCallbackId = 1;
+
+ chrome.appNotifications = new function() {
+ this.getChannel = function(clientId, callback) {
+ var callbackId = 0;
+ if (callback) {
+ callbackId = nextCallbackId++;
+ callbacks[callbackId] = callback;
+ }
+ GetAppNotifyChannel(clientId, callbackId);
+ };
+ }();
+});
+
+})();

Powered by Google App Engine
This is Rietveld 408576698