| 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 extension API. | 5 // Custom bindings for the extension API. |
| 6 | 6 |
| 7 (function() { | 7 var extensionNatives = requireNative('extension'); |
| 8 var GetExtensionViews = extensionNatives.GetExtensionViews; |
| 9 var OpenChannelToExtension = extensionNatives.OpenChannelToExtension; |
| 8 | 10 |
| 9 native function GetChromeHidden(); | 11 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 10 native function GetExtensionViews(); | |
| 11 native function OpenChannelToExtension(sourceId, targetId, name); | |
| 12 | |
| 13 var chromeHidden = GetChromeHidden(); | |
| 14 | 12 |
| 15 // This should match chrome.windows.WINDOW_ID_NONE. | 13 // This should match chrome.windows.WINDOW_ID_NONE. |
| 16 // | 14 // |
| 17 // We can't use chrome.windows.WINDOW_ID_NONE directly because the | 15 // We can't use chrome.windows.WINDOW_ID_NONE directly because the |
| 18 // chrome.windows API won't exist unless this extension has permission for it; | 16 // chrome.windows API won't exist unless this extension has permission for it; |
| 19 // which may not be the case. | 17 // which may not be the case. |
| 20 var WINDOW_ID_NONE = -1; | 18 var WINDOW_ID_NONE = -1; |
| 21 | 19 |
| 22 chromeHidden.registerCustomHook('extension', | 20 chromeHidden.registerCustomHook('extension', |
| 23 function(bindingsAPI, extensionId) { | 21 function(bindingsAPI, extensionId) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 var name = ''; | 135 var name = ''; |
| 138 if (connectInfo && connectInfo.name) | 136 if (connectInfo && connectInfo.name) |
| 139 name = connectInfo.name; | 137 name = connectInfo.name; |
| 140 | 138 |
| 141 var portId = OpenChannelToExtension(extensionId, targetId, name); | 139 var portId = OpenChannelToExtension(extensionId, targetId, name); |
| 142 if (portId >= 0) | 140 if (portId >= 0) |
| 143 return chromeHidden.Port.createPort(portId, name); | 141 return chromeHidden.Port.createPort(portId, name); |
| 144 throw new Error('Error connecting to extension ' + targetId); | 142 throw new Error('Error connecting to extension ' + targetId); |
| 145 }); | 143 }); |
| 146 }); | 144 }); |
| 147 | |
| 148 })(); | |
| OLD | NEW |