| 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 contains unprivileged javascript APIs for extensions and apps. It | 5 // This contains unprivileged javascript APIs for extensions and apps. It |
| 6 // can be loaded by any extension-related context, such as content scripts or | 6 // can be loaded by any extension-related context, such as content scripts or |
| 7 // background pages. See user_script_slave.cc for script that is loaded by | 7 // background pages. See user_script_slave.cc for script that is loaded by |
| 8 // content scripts only. | 8 // content scripts only. |
| 9 | 9 |
| 10 // TODO(kalman): factor requiring chrome out of here. | 10 // TODO(kalman): factor requiring chrome out of here. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if (targetExtensionId != extensionId) | 189 if (targetExtensionId != extensionId) |
| 190 return false; // not for us | 190 return false; // not for us |
| 191 | 191 |
| 192 if (ports[getOppositePortId(portId)]) | 192 if (ports[getOppositePortId(portId)]) |
| 193 return false; // this channel was opened by us, so ignore it | 193 return false; // this channel was opened by us, so ignore it |
| 194 | 194 |
| 195 // Determine whether this is coming from another extension, so we can use | 195 // Determine whether this is coming from another extension, so we can use |
| 196 // the right event. | 196 // the right event. |
| 197 var isExternal = sourceExtensionId != extensionId; | 197 var isExternal = sourceExtensionId != extensionId; |
| 198 | 198 |
| 199 var sender = {id: sourceExtensionId}; | 199 var sender = {}; |
| 200 if (sourceExtensionId != '') |
| 201 sender.id = sourceExtensionId; |
| 200 if (sourceUrl) | 202 if (sourceUrl) |
| 201 sender.url = sourceUrl; | 203 sender.url = sourceUrl; |
| 202 if (sourceTab) | 204 if (sourceTab) |
| 203 sender.tab = sourceTab; | 205 sender.tab = sourceTab; |
| 204 | 206 |
| 205 // Special case for sendRequest/onRequest and sendMessage/onMessage. | 207 // Special case for sendRequest/onRequest and sendMessage/onMessage. |
| 206 if (channelName == kRequestChannel || channelName == kMessageChannel) { | 208 if (channelName == kRequestChannel || channelName == kMessageChannel) { |
| 207 return dispatchOnRequest(portId, channelName, sender, | 209 return dispatchOnRequest(portId, channelName, sender, |
| 208 sourceExtensionId, targetExtensionId, sourceUrl, | 210 sourceExtensionId, targetExtensionId, sourceUrl, |
| 209 isExternal); | 211 isExternal); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 exports.Port = Port; | 325 exports.Port = Port; |
| 324 exports.createPort = createPort; | 326 exports.createPort = createPort; |
| 325 exports.sendMessageImpl = sendMessageImpl; | 327 exports.sendMessageImpl = sendMessageImpl; |
| 326 exports.sendMessageUpdateArguments = sendMessageUpdateArguments; | 328 exports.sendMessageUpdateArguments = sendMessageUpdateArguments; |
| 327 | 329 |
| 328 // For C++ code to call. | 330 // For C++ code to call. |
| 329 exports.hasPort = hasPort; | 331 exports.hasPort = hasPort; |
| 330 exports.dispatchOnConnect = dispatchOnConnect; | 332 exports.dispatchOnConnect = dispatchOnConnect; |
| 331 exports.dispatchOnDisconnect = dispatchOnDisconnect; | 333 exports.dispatchOnDisconnect = dispatchOnDisconnect; |
| 332 exports.dispatchOnMessage = dispatchOnMessage; | 334 exports.dispatchOnMessage = dispatchOnMessage; |
| OLD | NEW |