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