Index: chrome/renderer/resources/extensions/tabs_custom_bindings.js |
diff --git a/chrome/renderer/resources/extensions/tabs_custom_bindings.js b/chrome/renderer/resources/extensions/tabs_custom_bindings.js |
index e0cc59cb71e9c6a57d3336b9f6c65f2149373090..283609d04b79d006d55c36ff4a97b8184264f997 100644 |
--- a/chrome/renderer/resources/extensions/tabs_custom_bindings.js |
+++ b/chrome/renderer/resources/extensions/tabs_custom_bindings.js |
@@ -23,22 +23,13 @@ chromeHidden.registerCustomHook('tabs', function(bindingsAPI, extensionId) { |
apiFunctions.setHandleRequest('sendRequest', |
function(tabId, request, responseCallback) { |
- var port = chrome.tabs.connect(tabId, |
- {name: chromeHidden.kRequestChannel}); |
- port.postMessage(request); |
- port.onDisconnect.addListener(function() { |
- // For onDisconnects, we only notify the callback if there was an error. |
- if (chrome.extension.lastError && responseCallback) |
- responseCallback(); |
- }); |
- port.onMessage.addListener(function(response) { |
- try { |
- if (responseCallback) |
- responseCallback(response); |
- } finally { |
- port.disconnect(); |
- port = null; |
- } |
- }); |
+ var port = chrome.tabs.connect(tabId, {name: chromeHidden.kRequestChannel}); |
+ chromeHidden.Port.sendMessageImpl(port, request, responseCallback); |
+ }); |
+ |
+ apiFunctions.setHandleRequest('sendMessage', |
+ function(tabId, message, responseCallback) { |
+ var port = chrome.tabs.connect(tabId, {name: chromeHidden.kMessageChannel}); |
+ chromeHidden.Port.sendMessageImpl(port, message, responseCallback); |
}); |
}); |