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