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

Unified Diff: content/renderer/render_view_impl.cc

Issue 24733002: Enable sending MessagePorts to a different renderer (Chromium side) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/view_messages.h ('k') | content/test/data/click-noreferrer-links.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 557090d191853e388c0c2f781dba0567513334e3..d299a4d033d28da097fac8af70a5ab1e097e5628 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -4294,6 +4294,20 @@ bool RenderViewImpl::willCheckAndDispatchMessageEvent(
if (!target_origin.isNull())
params.target_origin = target_origin.toString();
+ WebKit::WebMessagePortChannelArray channels = event.releaseChannels();
+ if (!channels.isEmpty()) {
+ std::vector<int> message_port_ids(channels.size());
+ // Extract the port IDs from the channel array.
+ for (size_t i = 0; i < channels.size(); ++i) {
+ WebMessagePortChannelImpl* webchannel =
+ static_cast<WebMessagePortChannelImpl*>(channels[i]);
+ message_port_ids[i] = webchannel->message_port_id();
+ webchannel->QueueMessages();
+ DCHECK_NE(message_port_ids[i], MSG_ROUTING_NONE);
+ }
+ params.message_port_ids = message_port_ids;
+ }
+
// Include the routing ID for the source frame, which the browser process
// will translate into the routing ID for the equivalent frame in the target
// process.
@@ -5018,6 +5032,18 @@ void RenderViewImpl::OnPostMessageEvent(
source_frame = source_view->webview()->mainFrame();
}
+ // If the message contained MessagePorts, create the corresponding endpoints.
+ DCHECK_EQ(params.message_port_ids.size(), params.new_routing_ids.size());
+ WebKit::WebMessagePortChannelArray channels(params.message_port_ids.size());
+ for (size_t i = 0;
+ i < params.message_port_ids.size() && i < params.new_routing_ids.size();
+ ++i) {
+ channels[i] =
+ new WebMessagePortChannelImpl(params.new_routing_ids[i],
+ params.message_port_ids[i],
+ base::MessageLoopProxy::current().get());
+ }
+
// Create an event with the message. The final parameter to initMessageEvent
// is the last event ID, which is not used with postMessage.
WebDOMEvent event = frame->document().createEvent("MessageEvent");
@@ -5026,7 +5052,7 @@ void RenderViewImpl::OnPostMessageEvent(
// |canBubble| and |cancellable| are always false
false, false,
WebSerializedScriptValue::fromString(params.data),
- params.source_origin, source_frame, "");
+ params.source_origin, source_frame, "", channels);
// We must pass in the target_origin to do the security check on this side,
// since it may have changed since the original postMessage call was made.
« no previous file with comments | « content/common/view_messages.h ('k') | content/test/data/click-noreferrer-links.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698