| 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 a4db2a7e86e1b5610d837ccb533838fdd7f74679..618183c730cffbadfd37e7abd40fb01222f952e4 100644
|
| --- a/chrome/renderer/resources/extensions/runtime_custom_bindings.js
|
| +++ b/chrome/renderer/resources/extensions/runtime_custom_bindings.js
|
| @@ -2,7 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -// Custom bindings for the runtime API.
|
| +// Custom binding for the runtime API.
|
| +
|
| +var binding = require('binding').Binding.create('runtime');
|
|
|
| var runtimeNatives = requireNative('runtime');
|
| var extensionNatives = requireNative('extension');
|
| @@ -13,14 +15,15 @@ var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
|
| var sendMessageUpdateArguments =
|
| require('miscellaneous_bindings').sendMessageUpdateArguments;
|
|
|
| -chromeHidden.registerCustomHook('runtime', function(bindings, id, contextType) {
|
| - var apiFunctions = bindings.apiFunctions;
|
| +binding.registerCustomHook(function(binding, id, contextType) {
|
| + var apiFunctions = binding.apiFunctions;
|
| + var runtime = binding.compiledApi;
|
|
|
| //
|
| // Unprivileged APIs.
|
| //
|
|
|
| - chrome.runtime.id = id;
|
| + runtime.id = id;
|
|
|
| apiFunctions.setHandleRequest('getManifest', function() {
|
| return runtimeNatives.GetManifest();
|
| @@ -40,14 +43,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(targetId);
|
| + var port = runtime.connectNative(targetId);
|
| chromeHidden.Port.sendMessageImpl(port, message, responseCallback);
|
| });
|
|
|
| @@ -83,12 +86,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);
|
| @@ -103,7 +106,7 @@ chromeHidden.registerCustomHook('runtime', function(bindings, id, contextType) {
|
| apiFunctions.setHandleRequest('connectNative',
|
| function(nativeAppName) {
|
| // Turn the object into a string here, because it eventually will be.
|
| - var portId = OpenChannelToNativeApp(chrome.runtime.id, nativeAppName);
|
| + var portId = OpenChannelToNativeApp(runtime.id, nativeAppName);
|
| if (portId >= 0) {
|
| return chromeHidden.Port.createPort(portId, '');
|
| }
|
| @@ -120,3 +123,5 @@ chromeHidden.registerCustomHook('runtime', function(bindings, id, contextType) {
|
| });
|
|
|
| });
|
| +
|
| +exports.binding = binding.generate();
|
|
|