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

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

Issue 12313142: Revert 184837 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 bindings for the tabs API.
6
7 var binding = require('binding').Binding.create('tabs');
8 6
9 var tabsNatives = requireNative('tabs'); 7 var tabsNatives = requireNative('tabs');
10 var OpenChannelToTab = tabsNatives.OpenChannelToTab; 8 var OpenChannelToTab = tabsNatives.OpenChannelToTab;
11 var sendRequestIsDisabled = requireNative('process').IsSendRequestDisabled(); 9 var sendRequestIsDisabled = requireNative('process').IsSendRequestDisabled();
12 10
13 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 11 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
14 12
15 binding.registerCustomHook(function(bindingsAPI, extensionId) { 13 chromeHidden.registerCustomHook('tabs', function(bindingsAPI, extensionId) {
16 var apiFunctions = bindingsAPI.apiFunctions; 14 var apiFunctions = bindingsAPI.apiFunctions;
17 var tabs = bindingsAPI.compiledApi;
18 15
19 apiFunctions.setHandleRequest('connect', function(tabId, connectInfo) { 16 apiFunctions.setHandleRequest('connect', function(tabId, connectInfo) {
20 var name = ''; 17 var name = '';
21 if (connectInfo) { 18 if (connectInfo) {
22 name = connectInfo.name || name; 19 name = connectInfo.name || name;
23 } 20 }
24 var portId = OpenChannelToTab(tabId, extensionId, name); 21 var portId = OpenChannelToTab(tabId, extensionId, name);
25 return chromeHidden.Port.createPort(portId, name); 22 return chromeHidden.Port.createPort(portId, name);
26 }); 23 });
27 24
28 apiFunctions.setHandleRequest('sendRequest', 25 apiFunctions.setHandleRequest('sendRequest',
29 function(tabId, request, responseCallback) { 26 function(tabId, request, responseCallback) {
30 if (sendRequestIsDisabled) 27 if (sendRequestIsDisabled)
31 throw new Error(sendRequestIsDisabled); 28 throw new Error(sendRequestIsDisabled);
32 var port = tabs.connect(tabId, {name: chromeHidden.kRequestChannel}); 29 var port = chrome.tabs.connect(tabId, {name: chromeHidden.kRequestChannel});
33 chromeHidden.Port.sendMessageImpl(port, request, responseCallback); 30 chromeHidden.Port.sendMessageImpl(port, request, responseCallback);
34 }); 31 });
35 32
36 apiFunctions.setHandleRequest('sendMessage', 33 apiFunctions.setHandleRequest('sendMessage',
37 function(tabId, message, responseCallback) { 34 function(tabId, message, responseCallback) {
38 var port = tabs.connect(tabId, {name: chromeHidden.kMessageChannel}); 35 var port = chrome.tabs.connect(tabId, {name: chromeHidden.kMessageChannel});
39 chromeHidden.Port.sendMessageImpl(port, message, responseCallback); 36 chromeHidden.Port.sendMessageImpl(port, message, responseCallback);
40 }); 37 });
41 }); 38 });
42
43 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698