| Index: chrome/renderer/resources/extensions/runtime_custom_bindings.js
|
| diff --git a/chrome/renderer/resources/extensions/runtime_custom_bindings.js b/chrome/renderer/resources/extensions/runtime_custom_bindings.js
|
| index c5e63ac1fa50aad9a6a1d5149e145a8353bdb33a..c382d91ebb86ab8853eb71c25bb8db2e64115f49 100644
|
| --- a/chrome/renderer/resources/extensions/runtime_custom_bindings.js
|
| +++ b/chrome/renderer/resources/extensions/runtime_custom_bindings.js
|
| @@ -4,6 +4,9 @@
|
|
|
| // Custom bindings for the runtime API.
|
|
|
| +var Bindings = require('schema_binding_generator').Bindings;
|
| +var bindings = new Bindings('runtime');
|
| +
|
| var runtimeNatives = requireNative('runtime');
|
| var extensionNatives = requireNative('extension');
|
| var GetExtensionViews = extensionNatives.GetExtensionViews;
|
| @@ -13,14 +16,15 @@ var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
|
| var sendMessageUpdateArguments =
|
| require('miscellaneous_bindings').sendMessageUpdateArguments;
|
|
|
| -chromeHidden.registerCustomHook('runtime', function(bindings, id, contextType) {
|
| +bindings.registerCustomHook(function(bindings, id, contextType) {
|
| var apiFunctions = bindings.apiFunctions;
|
| + var runtime = bindings.compiledApi;
|
|
|
| //
|
| // Unprivileged APIs.
|
| //
|
|
|
| - chrome.runtime.id = id;
|
| + runtime.id = id;
|
|
|
| apiFunctions.setHandleRequest('getManifest', function() {
|
| return runtimeNatives.GetManifest();
|
| @@ -40,14 +44,14 @@ chromeHidden.registerCustomHook('runtime', function(bindings, id, contextType) {
|
|
|
| apiFunctions.setHandleRequest('sendMessage',
|
| function(targetId, message, responseCallback) {
|
| - var port = chrome.runtime.connect(targetId || chrome.runtime.id,
|
| + var port = runtime.connect(targetId || runtime.id,
|
| {name: chromeHidden.kMessageChannel});
|
| chromeHidden.Port.sendMessageImpl(port, message, responseCallback);
|
| });
|
|
|
| apiFunctions.setHandleRequest('sendNativeMessage',
|
| function(targetId, message, responseCallback) {
|
| - var port = chrome.runtime.connectNative(
|
| + var port = runtime.connectNative(
|
| targetId, message, chromeHidden.kNativeMessageChannel);
|
| chromeHidden.Port.sendMessageImpl(port, '', responseCallback);
|
| });
|
| @@ -95,12 +99,12 @@ chromeHidden.registerCustomHook('runtime', function(bindings, id, contextType) {
|
|
|
| apiFunctions.setHandleRequest('connect', function(targetId, connectInfo) {
|
| if (!targetId)
|
| - targetId = chrome.runtime.id;
|
| + targetId = runtime.id;
|
| var name = '';
|
| if (connectInfo && connectInfo.name)
|
| name = connectInfo.name;
|
|
|
| - var portId = OpenChannelToExtension(chrome.runtime.id, targetId, name);
|
| + var portId = OpenChannelToExtension(runtime.id, targetId, name);
|
| if (portId >= 0)
|
| return chromeHidden.Port.createPort(portId, name);
|
| throw new Error('Error connecting to extension ' + targetId);
|
| @@ -115,7 +119,7 @@ chromeHidden.registerCustomHook('runtime', function(bindings, id, contextType) {
|
| apiFunctions.setHandleRequest('connectNative',
|
| function(nativeAppName, connectInfo) {
|
| // Turn the object into a string here, because it eventually will be.
|
| - var portId = OpenChannelToNativeApp(chrome.runtime.id,
|
| + var portId = OpenChannelToNativeApp(runtime.id,
|
| nativeAppName,
|
| connectInfo.name,
|
| JSON.stringify(connectInfo.message));
|
| @@ -135,3 +139,5 @@ chromeHidden.registerCustomHook('runtime', function(bindings, id, contextType) {
|
| });
|
|
|
| });
|
| +
|
| +exports.bindings = bindings.generate();
|
|
|