OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/renderer/render_frame_proxy.h" | 5 #include "content/renderer/render_frame_proxy.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "content/child/webmessageportchannel_impl.h" |
10 #include "content/common/frame_messages.h" | 11 #include "content/common/frame_messages.h" |
11 #include "content/common/swapped_out_messages.h" | 12 #include "content/common/swapped_out_messages.h" |
| 13 #include "content/common/view_messages.h" |
12 #include "content/renderer/child_frame_compositing_helper.h" | 14 #include "content/renderer/child_frame_compositing_helper.h" |
13 #include "content/renderer/render_frame_impl.h" | 15 #include "content/renderer/render_frame_impl.h" |
14 #include "content/renderer/render_thread_impl.h" | 16 #include "content/renderer/render_thread_impl.h" |
15 #include "content/renderer/render_view_impl.h" | 17 #include "content/renderer/render_view_impl.h" |
| 18 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
16 #include "third_party/WebKit/public/web/WebView.h" | 19 #include "third_party/WebKit/public/web/WebView.h" |
17 | 20 |
18 namespace content { | 21 namespace content { |
19 | 22 |
20 namespace { | 23 namespace { |
21 | 24 |
22 // Facilitates lookup of RenderFrameProxy by routing_id. | 25 // Facilitates lookup of RenderFrameProxy by routing_id. |
23 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap; | 26 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap; |
24 static base::LazyInstance<RoutingIDProxyMap> g_routing_id_proxy_map = | 27 static base::LazyInstance<RoutingIDProxyMap> g_routing_id_proxy_map = |
25 LAZY_INSTANCE_INITIALIZER; | 28 LAZY_INSTANCE_INITIALIZER; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 if (render_frame) { | 238 if (render_frame) { |
236 if (render_frame->GetWebFrame()->opener()) | 239 if (render_frame->GetWebFrame()->opener()) |
237 render_frame->GetWebFrame()->setOpener(NULL); | 240 render_frame->GetWebFrame()->setOpener(NULL); |
238 return; | 241 return; |
239 } | 242 } |
240 | 243 |
241 if (web_frame_->opener()) | 244 if (web_frame_->opener()) |
242 web_frame_->setOpener(NULL); | 245 web_frame_->setOpener(NULL); |
243 } | 246 } |
244 | 247 |
| 248 void RenderFrameProxy::postMessageEvent( |
| 249 blink::WebLocalFrame* source_frame, |
| 250 blink::WebRemoteFrame* target_frame, |
| 251 blink::WebSecurityOrigin target_origin, |
| 252 blink::WebDOMMessageEvent event) { |
| 253 DCHECK(!web_frame_ || web_frame_ == target_frame); |
| 254 |
| 255 ViewMsg_PostMessage_Params params; |
| 256 params.is_data_raw_string = false; |
| 257 params.data = event.data().toString(); |
| 258 params.source_origin = event.origin(); |
| 259 if (!target_origin.isNull()) |
| 260 params.target_origin = target_origin.toString(); |
| 261 |
| 262 blink::WebMessagePortChannelArray channels = event.releaseChannels(); |
| 263 if (!channels.isEmpty()) { |
| 264 std::vector<int> message_port_ids(channels.size()); |
| 265 // Extract the port IDs from the channel array. |
| 266 for (size_t i = 0; i < channels.size(); ++i) { |
| 267 WebMessagePortChannelImpl* webchannel = |
| 268 static_cast<WebMessagePortChannelImpl*>(channels[i]); |
| 269 message_port_ids[i] = webchannel->message_port_id(); |
| 270 webchannel->QueueMessages(); |
| 271 DCHECK_NE(message_port_ids[i], MSG_ROUTING_NONE); |
| 272 } |
| 273 params.message_port_ids = message_port_ids; |
| 274 } |
| 275 |
| 276 // Include the routing ID for the source frame (if one exists), which the |
| 277 // browser process will translate into the routing ID for the equivalent |
| 278 // frame in the target process. |
| 279 params.source_routing_id = MSG_ROUTING_NONE; |
| 280 if (source_frame) { |
| 281 RenderViewImpl* source_view = |
| 282 RenderViewImpl::FromWebView(source_frame->view()); |
| 283 if (source_view) |
| 284 params.source_routing_id = source_view->routing_id(); |
| 285 } |
| 286 |
| 287 Send(new ViewHostMsg_RouteMessageEvent(render_view_->GetRoutingID(), params)); |
| 288 } |
| 289 |
245 } // namespace | 290 } // namespace |
OLD | NEW |