| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 toolstrips. | 7 // scripts or toolstrips. |
| 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 // TODO(mpcomplete): we also load this in regular web pages, but don't need | 9 // TODO(mpcomplete): we also load this in regular web pages, but don't need |
| 10 // to. | 10 // to. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 // Disconnects the port from the other end. | 137 // Disconnects the port from the other end. |
| 138 chrome.Port.prototype.disconnect = function() { | 138 chrome.Port.prototype.disconnect = function() { |
| 139 delete ports[this.portId_]; | 139 delete ports[this.portId_]; |
| 140 CloseChannel(this.portId_); | 140 CloseChannel(this.portId_); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // This function is called on context initialization for both content scripts | 143 // This function is called on context initialization for both content scripts |
| 144 // and extension contexts. | 144 // and extension contexts. |
| 145 chrome.initExtension = function(extensionId, warnOnPrivilegedApiAccess, | 145 chrome.initExtension = function(extensionId, warnOnPrivilegedApiAccess, |
| 146 inIncognitoTab) { | 146 inIncognitoContext) { |
| 147 delete chrome.initExtension; | 147 delete chrome.initExtension; |
| 148 chromeHidden.extensionId = extensionId; | 148 chromeHidden.extensionId = extensionId; |
| 149 | 149 |
| 150 chrome.extension = chrome.extension || {}; | 150 chrome.extension = chrome.extension || {}; |
| 151 chrome.self = chrome.extension; | 151 chrome.self = chrome.extension; |
| 152 | 152 |
| 153 chrome.extension.inIncognitoTab = inIncognitoTab; | 153 chrome.extension.inIncognitoTab = inIncognitoContext; // deprecated |
| 154 chrome.extension.inIncognitoContext = inIncognitoContext; |
| 154 | 155 |
| 155 // Events for when a message channel is opened to our extension. | 156 // Events for when a message channel is opened to our extension. |
| 156 chrome.extension.onConnect = new chrome.Event(); | 157 chrome.extension.onConnect = new chrome.Event(); |
| 157 chrome.extension.onConnectExternal = new chrome.Event(); | 158 chrome.extension.onConnectExternal = new chrome.Event(); |
| 158 chrome.extension.onRequest = new chrome.Event(); | 159 chrome.extension.onRequest = new chrome.Event(); |
| 159 chrome.extension.onRequestExternal = new chrome.Event(); | 160 chrome.extension.onRequestExternal = new chrome.Event(); |
| 160 | 161 |
| 161 // Opens a message channel to the given target extension, or the current one | 162 // Opens a message channel to the given target extension, or the current one |
| 162 // if unspecified. Returns a Port for message passing. | 163 // if unspecified. Returns a Port for message passing. |
| 163 chrome.extension.connect = function(targetId_opt, connectInfo_opt) { | 164 chrome.extension.connect = function(targetId_opt, connectInfo_opt) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 "extension.onConnectExternal", | 286 "extension.onConnectExternal", |
| 286 "extension.onRequestExternal", | 287 "extension.onRequestExternal", |
| 287 "i18n.getAcceptLanguages" | 288 "i18n.getAcceptLanguages" |
| 288 ]; | 289 ]; |
| 289 for (var i = 0; i < privileged.length; i++) { | 290 for (var i = 0; i < privileged.length; i++) { |
| 290 createStub(privileged[i]); | 291 createStub(privileged[i]); |
| 291 } | 292 } |
| 292 } | 293 } |
| 293 | 294 |
| 294 })(); | 295 })(); |
| OLD | NEW |