OLD | NEW |
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 bindings for the tabs API. | 5 // Custom bindings for the tabs API. |
6 | 6 |
7 (function() { | 7 (function() { |
8 | 8 |
9 native function GetChromeHidden(); | 9 var tabsNatives = requireNative('tabs'); |
10 native function OpenChannelToTab(); | 10 var OpenChannelToTab = tabsNatives.OpenChannelToTab; |
11 | 11 |
12 var chromeHidden = GetChromeHidden(); | 12 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
13 | 13 |
14 chromeHidden.registerCustomHook('tabs', function(bindingsAPI, extensionId) { | 14 chromeHidden.registerCustomHook('tabs', function(bindingsAPI, extensionId) { |
15 var apiFunctions = bindingsAPI.apiFunctions; | 15 var apiFunctions = bindingsAPI.apiFunctions; |
16 | 16 |
17 apiFunctions.setHandleRequest('connect', function(tabId, connectInfo) { | 17 apiFunctions.setHandleRequest('connect', function(tabId, connectInfo) { |
18 var name = ''; | 18 var name = ''; |
19 if (connectInfo) { | 19 if (connectInfo) { |
20 name = connectInfo.name || name; | 20 name = connectInfo.name || name; |
21 } | 21 } |
22 var portId = OpenChannelToTab(tabId, extensionId, name); | 22 var portId = OpenChannelToTab(tabId, extensionId, name); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // If the old signature is used, add a null details object. | 58 // If the old signature is used, add a null details object. |
59 newArgs = [arguments[0], null, arguments[1]]; | 59 newArgs = [arguments[0], null, arguments[1]]; |
60 } else { | 60 } else { |
61 newArgs = arguments; | 61 newArgs = arguments; |
62 } | 62 } |
63 return newArgs; | 63 return newArgs; |
64 }); | 64 }); |
65 }); | 65 }); |
66 | 66 |
67 })(); | 67 })(); |
OLD | NEW |