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 // This script contains unprivileged javascript APIs related to chrome | 5 // This script contains unprivileged javascript APIs related to chrome |
6 // extensions. It is loaded by any extension-related context, such as content | 6 // extensions. It is loaded by any extension-related context, such as content |
7 // scripts or background pages. | 7 // scripts or background pages. |
8 // See user_script_slave.cc for script that is loaded by content scripts only. | 8 // See user_script_slave.cc for script that is loaded by content scripts only. |
9 | 9 |
10 var chrome = chrome || {}; | 10 require('json_schema'); |
11 (function () { | 11 require('event_bindings'); |
12 native function CloseChannel(portId, notifyBrowser); | 12 var miscNatives = requireNative('miscellaneous_bindings'); |
13 native function PortAddRef(portId); | 13 var CloseChannel = miscNatives.CloseChannel; |
14 native function PortRelease(portId); | 14 var PortAddRef = miscNatives.PortAddRef; |
15 native function PostMessage(portId, msg); | 15 var PortRelease = miscNatives.PortRelease; |
16 native function GetChromeHidden(); | 16 var PostMessage = miscNatives.PostMessage; |
17 native function Print(); | 17 var BindToGC = miscNatives.BindToGC; |
18 native function BindToGC(); | |
19 | 18 |
20 var chromeHidden = GetChromeHidden(); | 19 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
21 var manifestVersion; | 20 var manifestVersion; |
22 var extensionId; | 21 var extensionId; |
23 | 22 |
24 // The reserved channel name for the sendRequest API. | 23 // The reserved channel name for the sendRequest API. |
25 chromeHidden.kRequestChannel = "chrome.extension.sendRequest"; | 24 chromeHidden.kRequestChannel = "chrome.extension.sendRequest"; |
26 | 25 |
27 // Map of port IDs to port object. | 26 // Map of port IDs to port object. |
28 var ports = {}; | 27 var ports = {}; |
29 | 28 |
30 // Map of port IDs to chromeHidden.onUnload listeners. Keep track of these | 29 // Map of port IDs to chromeHidden.onUnload listeners. Keep track of these |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 214 |
216 chrome.extension = chrome.extension || {}; | 215 chrome.extension = chrome.extension || {}; |
217 | 216 |
218 if (manifestVersion < 2) { | 217 if (manifestVersion < 2) { |
219 chrome.self = chrome.extension; | 218 chrome.self = chrome.extension; |
220 chrome.extension.inIncognitoTab = inIncognitoContext; | 219 chrome.extension.inIncognitoTab = inIncognitoContext; |
221 } | 220 } |
222 | 221 |
223 chrome.extension.inIncognitoContext = inIncognitoContext; | 222 chrome.extension.inIncognitoContext = inIncognitoContext; |
224 }); | 223 }); |
225 })(); | |
OLD | NEW |