Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/renderer/resources/extensions/tabs_custom_bindings.js

Issue 15855010: Make ExtensionMsg_MessageInvoke run a module system function rather than a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test compile Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Custom binding for the tabs API. 5 // Custom binding for the tabs API.
6 6
7 var binding = require('binding').Binding.create('tabs'); 7 var binding = require('binding').Binding.create('tabs');
8 8
9 var miscBindings = require('miscellaneous_bindings');
9 var tabsNatives = requireNative('tabs'); 10 var tabsNatives = requireNative('tabs');
10 var OpenChannelToTab = tabsNatives.OpenChannelToTab; 11 var OpenChannelToTab = tabsNatives.OpenChannelToTab;
11 var sendRequestIsDisabled = requireNative('process').IsSendRequestDisabled(); 12 var sendRequestIsDisabled = requireNative('process').IsSendRequestDisabled();
12 13
13 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
14
15 binding.registerCustomHook(function(bindingsAPI, extensionId) { 14 binding.registerCustomHook(function(bindingsAPI, extensionId) {
16 var apiFunctions = bindingsAPI.apiFunctions; 15 var apiFunctions = bindingsAPI.apiFunctions;
17 var tabs = bindingsAPI.compiledApi; 16 var tabs = bindingsAPI.compiledApi;
18 17
19 apiFunctions.setHandleRequest('connect', function(tabId, connectInfo) { 18 apiFunctions.setHandleRequest('connect', function(tabId, connectInfo) {
20 var name = ''; 19 var name = '';
21 if (connectInfo) { 20 if (connectInfo) {
22 name = connectInfo.name || name; 21 name = connectInfo.name || name;
23 } 22 }
24 var portId = OpenChannelToTab(tabId, extensionId, name); 23 var portId = OpenChannelToTab(tabId, extensionId, name);
25 return chromeHidden.Port.createPort(portId, name); 24 return miscBindings.createPort(portId, name);
26 }); 25 });
27 26
28 apiFunctions.setHandleRequest('sendRequest', 27 apiFunctions.setHandleRequest('sendRequest',
29 function(tabId, request, responseCallback) { 28 function(tabId, request, responseCallback) {
30 if (sendRequestIsDisabled) 29 if (sendRequestIsDisabled)
31 throw new Error(sendRequestIsDisabled); 30 throw new Error(sendRequestIsDisabled);
32 var port = tabs.connect(tabId, {name: chromeHidden.kRequestChannel}); 31 var port = tabs.connect(tabId, {name: miscBindings.kRequestChannel});
33 chromeHidden.Port.sendMessageImpl(port, request, responseCallback); 32 miscBindings.sendMessageImpl(port, request, responseCallback);
34 }); 33 });
35 34
36 apiFunctions.setHandleRequest('sendMessage', 35 apiFunctions.setHandleRequest('sendMessage',
37 function(tabId, message, responseCallback) { 36 function(tabId, message, responseCallback) {
38 var port = tabs.connect(tabId, {name: chromeHidden.kMessageChannel}); 37 var port = tabs.connect(tabId, {name: miscBindings.kMessageChannel});
39 chromeHidden.Port.sendMessageImpl(port, message, responseCallback); 38 miscBindings.sendMessageImpl(port, message, responseCallback);
40 }); 39 });
41 }); 40 });
42 41
43 exports.binding = binding.generate(); 42 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/send_request.js ('k') | chrome/renderer/resources/extensions/unload_event.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698