diff options
Diffstat (limited to 'chrome/renderer/resources')
4 files changed, 57 insertions, 57 deletions
diff --git a/chrome/renderer/resources/extensions/app.js b/chrome/renderer/resources/extensions/app.js deleted file mode 100644 index 7337d86..0000000 --- a/chrome/renderer/resources/extensions/app.js +++ /dev/null @@ -1,41 +0,0 @@ -// 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. - - var natives = requireNative('app'); - var GetIsInstalled = natives.GetIsInstalled; - var Install = natives.Install; - var GetDetails = natives.GetDetails; - var GetDetailsForFrame = natives.GetDetailsForFrame; - var GetAppNotifyChannel = natives.GetAppNotifyChannel; - - var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); - var callbacks = {}; - var nextCallbackId = 1; - - chrome.app = new function() { - this.__defineGetter__('isInstalled', GetIsInstalled); - this.install = Install; - this.getDetails = GetDetails; - this.getDetailsForFrame = GetDetailsForFrame; - }(); - - chrome.appNotifications = new function() { - this.getChannel = function(clientId, callback) { - var callbackId = 0; - if (callback) { - callbackId = nextCallbackId++; - callbacks[callbackId] = callback; - } - GetAppNotifyChannel(clientId, callbackId); - }; - }(); - - chromeHidden.app = {}; - chromeHidden.app.onGetAppNotifyChannelResponse = - function(channelId, error, callbackId) { - if (callbackId) { - callbacks[callbackId](channelId, error); - delete callbacks[callbackId]; - } - }; 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 0000000..9cae9d4 --- /dev/null +++ b/chrome/renderer/resources/extensions/app_custom_bindings.js @@ -0,0 +1,52 @@ +// 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. + +var appNatives = requireNative('app'); +var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); + +chrome.app = { + getIsInstalled: appNatives.GetIsInstalled, + install: appNatives.Install, + getDetails: appNatives.GetDetails, + getDetailsForFrame: appNatives.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', appNatives.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 = { + getChannel: function getChannel(clientId, callback) { + var callbackId = 0; + if (callback) { + callbackId = nextCallbackId++; + callbacks[callbackId] = callback; + } + appNatives.GetAppNotifyChannel(clientId, callbackId); + } +}; diff --git a/chrome/renderer/resources/extensions/schema_generated_bindings.js b/chrome/renderer/resources/extensions/schema_generated_bindings.js index ab11923..217414c 100644 --- a/chrome/renderer/resources/extensions/schema_generated_bindings.js +++ b/chrome/renderer/resources/extensions/schema_generated_bindings.js @@ -531,6 +531,11 @@ var platform = getPlatform(); apiDefinitions.forEach(function(apiDef) { + // TODO(kalman): Remove this, or refactor schema_generated_bindings.js so + // that it isn't necessary. For now, chrome.app is entirely handwritten. + if (apiDef.namespace === 'app') + return; + if (!isSchemaNodeSupported(apiDef, platform, manifestVersion)) return; diff --git a/chrome/renderer/resources/extensions/setup_bindings.js b/chrome/renderer/resources/extensions/setup_bindings.js deleted file mode 100644 index ba002d9..0000000 --- a/chrome/renderer/resources/extensions/setup_bindings.js +++ /dev/null @@ -1,16 +0,0 @@ -// 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. - -var contextInfo = requireNative('context_info'); -var sgb = requireNative('schema_generated_bindings'); - -require('miscellaneous_bindings'); -require('schema_generated_bindings'); -require('apitest'); - -// Load the custom bindings for each API. -sgb.GetExtensionAPIDefinition().forEach(function(apiDef) { - if (contextInfo.IsAPIAllowed(apiDef.namespace)) - require(apiDef.namespace); -}); |