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 || {}; | |
11 (function () { | 10 (function () { |
12 native function CloseChannel(portId, notifyBrowser); | 11 var miscNatives = requireNative('miscellaneous_bindings'); |
13 native function PortAddRef(portId); | 12 var CloseChannel = miscNatives.CloseChannel; |
14 native function PortRelease(portId); | 13 var PortAddRef = miscNatives.PortAddRef; |
15 native function PostMessage(portId, msg); | 14 var PortRelease = miscNatives.PortRelease; |
16 native function GetChromeHidden(); | 15 var PostMessage = miscNatives.PostMessage; |
17 native function Print(); | |
18 | 16 |
19 var chromeHidden = GetChromeHidden(); | 17 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
20 var manifestVersion; | 18 var manifestVersion; |
21 var extensionId; | 19 var extensionId; |
22 | 20 |
23 // The reserved channel name for the sendRequest API. | 21 // The reserved channel name for the sendRequest API. |
24 chromeHidden.kRequestChannel = "chrome.extension.sendRequest"; | 22 chromeHidden.kRequestChannel = "chrome.extension.sendRequest"; |
25 | 23 |
26 // Map of port IDs to port object. | 24 // Map of port IDs to port object. |
27 var ports = {}; | 25 var ports = {}; |
28 | 26 |
29 // Map of port IDs to chromeHidden.onUnload listeners. Keep track of these | 27 // Map of port IDs to chromeHidden.onUnload listeners. Keep track of these |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 chrome.extension = chrome.extension || {}; | 202 chrome.extension = chrome.extension || {}; |
205 | 203 |
206 if (manifestVersion < 2) { | 204 if (manifestVersion < 2) { |
207 chrome.self = chrome.extension; | 205 chrome.self = chrome.extension; |
208 chrome.extension.inIncognitoTab = inIncognitoContext; | 206 chrome.extension.inIncognitoTab = inIncognitoContext; |
209 } | 207 } |
210 | 208 |
211 chrome.extension.inIncognitoContext = inIncognitoContext; | 209 chrome.extension.inIncognitoContext = inIncognitoContext; |
212 }); | 210 }); |
213 })(); | 211 })(); |
OLD | NEW |