Chromium Code Reviews| 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 | |
|
Avi (use Gerrit)
2014/09/09 18:25:12
Why two \n\n? Just one is enough.
| |
| 249 void RenderFrameProxy::postMessageEvent( | |
| 250 blink::WebLocalFrame* source_frame, | |
| 251 blink::WebRemoteFrame* target_frame, | |
| 252 blink::WebSecurityOrigin target_origin, | |
| 253 blink::WebDOMMessageEvent event) { | |
| 254 DCHECK(!web_frame_ || web_frame_ == target_frame); | |
| 255 | |
| 256 ViewMsg_PostMessage_Params params; | |
| 257 params.is_data_raw_string = false; | |
| 258 params.data = event.data().toString(); | |
| 259 params.source_origin = event.origin(); | |
| 260 if (!target_origin.isNull()) | |
| 261 params.target_origin = target_origin.toString(); | |
| 262 | |
| 263 blink::WebMessagePortChannelArray channels = event.releaseChannels(); | |
| 264 if (!channels.isEmpty()) { | |
| 265 std::vector<int> message_port_ids(channels.size()); | |
| 266 // Extract the port IDs from the channel array. | |
| 267 for (size_t i = 0; i < channels.size(); ++i) { | |
| 268 WebMessagePortChannelImpl* webchannel = | |
| 269 static_cast<WebMessagePortChannelImpl*>(channels[i]); | |
| 270 message_port_ids[i] = webchannel->message_port_id(); | |
| 271 webchannel->QueueMessages(); | |
| 272 DCHECK_NE(message_port_ids[i], MSG_ROUTING_NONE); | |
| 273 } | |
| 274 params.message_port_ids = message_port_ids; | |
| 275 } | |
| 276 | |
| 277 // Include the routing ID for the source frame (if one exists), which the | |
| 278 // browser process will translate into the routing ID for the equivalent | |
| 279 // frame in the target process. | |
| 280 params.source_routing_id = MSG_ROUTING_NONE; | |
| 281 if (source_frame) { | |
| 282 RenderViewImpl* source_view = | |
| 283 RenderViewImpl::FromWebView(source_frame->view()); | |
| 284 if (source_view) | |
| 285 params.source_routing_id = source_view->routing_id(); | |
| 286 } | |
| 287 | |
| 288 Send(new ViewHostMsg_RouteMessageEvent(render_view_->GetRoutingID(), params)); | |
| 289 } | |
| 290 | |
| 245 } // namespace | 291 } // namespace |
| OLD | NEW |