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

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

Issue 9386001: Implement a module system for the extension bindings JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-jigged to use ModuleSystem Created 8 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 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
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 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698