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