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..d7a9a7b9de664da11a807b8fe647d01701c2528f 100644 |
--- a/chrome/renderer/resources/extensions/runtime_custom_bindings.js |
+++ b/chrome/renderer/resources/extensions/runtime_custom_bindings.js |
@@ -4,6 +4,8 @@ |
// Custom bindings for the runtime API. |
+var bindings = new (require('schema_binding_generator').Bindings)('runtime'); |
+ |
var runtimeNatives = requireNative('runtime'); |
var extensionNatives = requireNative('extension'); |
var GetExtensionViews = extensionNatives.GetExtensionViews; |
@@ -13,14 +15,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 +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.bindings = bindings.generate(); |