| 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 var tabsNatives = requireNative('tabs'); | 7 (function() { |
| 8 var OpenChannelToTab = tabsNatives.OpenChannelToTab; | |
| 9 | 8 |
| 10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 9 native function GetChromeHidden(); |
| 10 native function OpenChannelToTab(); |
| 11 |
| 12 var chromeHidden = GetChromeHidden(); |
| 11 | 13 |
| 12 chromeHidden.registerCustomHook('tabs', function(bindingsAPI, extensionId) { | 14 chromeHidden.registerCustomHook('tabs', function(bindingsAPI, extensionId) { |
| 13 var apiFunctions = bindingsAPI.apiFunctions; | 15 var apiFunctions = bindingsAPI.apiFunctions; |
| 14 | 16 |
| 15 apiFunctions.setHandleRequest('connect', function(tabId, connectInfo) { | 17 apiFunctions.setHandleRequest('connect', function(tabId, connectInfo) { |
| 16 var name = ''; | 18 var name = ''; |
| 17 if (connectInfo) { | 19 if (connectInfo) { |
| 18 name = connectInfo.name || name; | 20 name = connectInfo.name || name; |
| 19 } | 21 } |
| 20 var portId = OpenChannelToTab(tabId, extensionId, name); | 22 var portId = OpenChannelToTab(tabId, extensionId, name); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 try { | 37 try { |
| 36 if (responseCallback) | 38 if (responseCallback) |
| 37 responseCallback(response); | 39 responseCallback(response); |
| 38 } finally { | 40 } finally { |
| 39 port.disconnect(); | 41 port.disconnect(); |
| 40 port = null; | 42 port = null; |
| 41 } | 43 } |
| 42 }); | 44 }); |
| 43 }); | 45 }); |
| 44 }); | 46 }); |
| 47 |
| 48 })(); |
| OLD | NEW |