Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: chrome/renderer/resources/extensions/miscellaneous_bindings.js

Issue 16174005: Implement externally_connectable! Web pages can now communicate directly with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: absolute path... Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (targetExtensionId != extensionId) 198 if (targetExtensionId != extensionId)
199 return false; // not for us 199 return false; // not for us
200 200
201 if (ports[getOppositePortId(portId)]) 201 if (ports[getOppositePortId(portId)])
202 return false; // this channel was opened by us, so ignore it 202 return false; // this channel was opened by us, so ignore it
203 203
204 // Determine whether this is coming from another extension, so we can use 204 // Determine whether this is coming from another extension, so we can use
205 // the right event. 205 // the right event.
206 var isExternal = sourceExtensionId != extensionId; 206 var isExternal = sourceExtensionId != extensionId;
207 207
208 var sender = {id: sourceExtensionId}; 208 var sender = {};
209 if (sourceExtensionId != '')
210 sender.id = sourceExtensionId;
209 if (sourceUrl) 211 if (sourceUrl)
210 sender.url = sourceUrl; 212 sender.url = sourceUrl;
211 if (sourceTab) 213 if (sourceTab)
212 sender.tab = sourceTab; 214 sender.tab = sourceTab;
213 215
214 // Special case for sendRequest/onRequest and sendMessage/onMessage. 216 // Special case for sendRequest/onRequest and sendMessage/onMessage.
215 if (channelName == kRequestChannel || channelName == kMessageChannel) { 217 if (channelName == kRequestChannel || channelName == kMessageChannel) {
216 return dispatchOnRequest(portId, channelName, sender, 218 return dispatchOnRequest(portId, channelName, sender,
217 sourceExtensionId, targetExtensionId, sourceUrl, 219 sourceExtensionId, targetExtensionId, sourceUrl,
218 isExternal); 220 isExternal);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 exports.Port = Port; 337 exports.Port = Port;
336 exports.createPort = createPort; 338 exports.createPort = createPort;
337 exports.sendMessageImpl = sendMessageImpl; 339 exports.sendMessageImpl = sendMessageImpl;
338 exports.sendMessageUpdateArguments = sendMessageUpdateArguments; 340 exports.sendMessageUpdateArguments = sendMessageUpdateArguments;
339 341
340 // For C++ code to call. 342 // For C++ code to call.
341 exports.hasPort = hasPort; 343 exports.hasPort = hasPort;
342 exports.dispatchOnConnect = dispatchOnConnect; 344 exports.dispatchOnConnect = dispatchOnConnect;
343 exports.dispatchOnDisconnect = dispatchOnDisconnect; 345 exports.dispatchOnDisconnect = dispatchOnDisconnect;
344 exports.dispatchOnMessage = dispatchOnMessage; 346 exports.dispatchOnMessage = dispatchOnMessage;
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/runtime_custom_bindings.cc ('k') | chrome/renderer/resources/extensions/runtime_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698