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/child/webmessageportchannel_impl.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 33 // Facilitates lookup of RenderFrameProxy by WebFrame. | 33 // Facilitates lookup of RenderFrameProxy by WebFrame. |
| 34 typedef std::map<blink::WebFrame*, RenderFrameProxy*> FrameMap; | 34 typedef std::map<blink::WebFrame*, RenderFrameProxy*> FrameMap; |
| 35 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; | 35 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 // static | 39 // static |
| 40 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( | 40 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( |
| 41 RenderFrameImpl* frame_to_replace, | 41 RenderFrameImpl* frame_to_replace, |
| 42 int routing_id) { | 42 int routing_id, |
| 43 blink::WebTreeScopeType scope) { | |
| 43 CHECK_NE(routing_id, MSG_ROUTING_NONE); | 44 CHECK_NE(routing_id, MSG_ROUTING_NONE); |
| 44 | 45 |
| 45 scoped_ptr<RenderFrameProxy> proxy( | 46 scoped_ptr<RenderFrameProxy> proxy( |
| 46 new RenderFrameProxy(routing_id, frame_to_replace->GetRoutingID())); | 47 new RenderFrameProxy(routing_id, frame_to_replace->GetRoutingID())); |
| 47 | 48 |
| 48 // When a RenderFrame is replaced by a RenderProxy, the WebRemoteFrame should | 49 // When a RenderFrame is replaced by a RenderProxy, the WebRemoteFrame should |
| 49 // always come from WebRemoteFrame::create and a call to WebFrame::swap must | 50 // always come from WebRemoteFrame::create and a call to WebFrame::swap must |
| 50 // follow later. | 51 // follow later. |
| 51 blink::WebRemoteFrame* web_frame = blink::WebRemoteFrame::create(proxy.get()); | 52 blink::WebRemoteFrame* web_frame = |
| 53 blink::WebRemoteFrame::create(scope, proxy.get()); | |
| 52 proxy->Init(web_frame, frame_to_replace->render_view()); | 54 proxy->Init(web_frame, frame_to_replace->render_view()); |
| 53 return proxy.release(); | 55 return proxy.release(); |
| 54 } | 56 } |
| 55 | 57 |
| 56 RenderFrameProxy* RenderFrameProxy::CreateFrameProxy( | 58 RenderFrameProxy* RenderFrameProxy::CreateFrameProxy( |
| 57 int routing_id, | 59 int routing_id, |
| 58 int parent_routing_id, | 60 int parent_routing_id, |
| 59 int render_view_routing_id, | 61 int render_view_routing_id, |
| 60 const FrameReplicationState& replicated_state) { | 62 const FrameReplicationState& replicated_state) { |
| 61 scoped_ptr<RenderFrameProxy> proxy( | 63 scoped_ptr<RenderFrameProxy> proxy( |
| 62 new RenderFrameProxy(routing_id, MSG_ROUTING_NONE)); | 64 new RenderFrameProxy(routing_id, MSG_ROUTING_NONE)); |
| 63 RenderViewImpl* render_view = NULL; | 65 RenderViewImpl* render_view = NULL; |
| 64 blink::WebRemoteFrame* web_frame = NULL; | 66 blink::WebRemoteFrame* web_frame = NULL; |
| 65 if (parent_routing_id == MSG_ROUTING_NONE) { | 67 if (parent_routing_id == MSG_ROUTING_NONE) { |
| 66 // Create a top level frame. | 68 // Create a top level frame. |
| 67 render_view = RenderViewImpl::FromRoutingID(render_view_routing_id); | 69 render_view = RenderViewImpl::FromRoutingID(render_view_routing_id); |
| 68 web_frame = blink::WebRemoteFrame::create(proxy.get()); | 70 web_frame = |
| 71 blink::WebRemoteFrame::create(replicated_state.scope, proxy.get()); | |
| 69 render_view->webview()->setMainFrame(web_frame); | 72 render_view->webview()->setMainFrame(web_frame); |
| 70 } else { | 73 } else { |
| 71 // Create a frame under an existing parent. The parent is always expected | 74 // Create a frame under an existing parent. The parent is always expected |
| 72 // to be a RenderFrameProxy, because navigations initiated by local frames | 75 // to be a RenderFrameProxy, because navigations initiated by local frames |
| 73 // should not wind up here. | 76 // should not wind up here. |
| 74 RenderFrameProxy* parent = | 77 RenderFrameProxy* parent = |
| 75 RenderFrameProxy::FromRoutingID(parent_routing_id); | 78 RenderFrameProxy::FromRoutingID(parent_routing_id); |
| 76 web_frame = parent->web_frame()->createRemoteChild( | 79 web_frame = parent->web_frame()->createRemoteChild( |
| 80 replicated_state.scope, | |
| 77 blink::WebString::fromUTF8(replicated_state.name), | 81 blink::WebString::fromUTF8(replicated_state.name), |
| 78 RenderFrameImpl::ContentToWebSandboxFlags( | 82 RenderFrameImpl::ContentToWebSandboxFlags( |
| 79 replicated_state.sandbox_flags), | 83 replicated_state.sandbox_flags), |
| 80 proxy.get()); | 84 proxy.get()); |
| 81 render_view = parent->render_view(); | 85 render_view = parent->render_view(); |
| 82 } | 86 } |
| 83 | 87 |
| 84 proxy->Init(web_frame, render_view); | 88 proxy->Init(web_frame, render_view); |
| 85 | 89 |
| 86 // Initialize proxy's WebRemoteFrame with the security origin and other | 90 // Initialize proxy's WebRemoteFrame with the security origin and other |
| 87 // replicated information. | 91 // replicated information. |
| 92 // TODO(dcheng): Shouldn't we only need to call when creating a top-level | |
| 93 // frame proxy? | |
|
nasko
2015/05/19 16:02:47
Why would it apply only for top-level? What if we
dcheng
2015/05/19 16:09:55
In the case with a parent, most of this replicated
nasko
2015/05/19 16:14:16
I think passing all of the replication state into
dcheng
2015/05/19 16:18:49
Well, we can't (easily) do it for the main frame c
| |
| 88 proxy->SetReplicatedState(replicated_state); | 94 proxy->SetReplicatedState(replicated_state); |
| 89 | 95 |
| 90 return proxy.release(); | 96 return proxy.release(); |
| 91 } | 97 } |
| 92 | 98 |
| 93 // static | 99 // static |
| 94 RenderFrameProxy* RenderFrameProxy::FromRoutingID(int32 routing_id) { | 100 RenderFrameProxy* RenderFrameProxy::FromRoutingID(int32 routing_id) { |
| 95 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); | 101 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); |
| 96 RoutingIDProxyMap::iterator it = proxies->find(routing_id); | 102 RoutingIDProxyMap::iterator it = proxies->find(routing_id); |
| 97 return it == proxies->end() ? NULL : it->second; | 103 return it == proxies->end() ? NULL : it->second; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 blink::WebUserGestureIndicator::isProcessingUserGesture(); | 386 blink::WebUserGestureIndicator::isProcessingUserGesture(); |
| 381 blink::WebUserGestureIndicator::consumeUserGesture(); | 387 blink::WebUserGestureIndicator::consumeUserGesture(); |
| 382 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 388 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
| 383 } | 389 } |
| 384 | 390 |
| 385 void RenderFrameProxy::forwardInputEvent(const blink::WebInputEvent* event) { | 391 void RenderFrameProxy::forwardInputEvent(const blink::WebInputEvent* event) { |
| 386 Send(new FrameHostMsg_ForwardInputEvent(routing_id_, event)); | 392 Send(new FrameHostMsg_ForwardInputEvent(routing_id_, event)); |
| 387 } | 393 } |
| 388 | 394 |
| 389 } // namespace | 395 } // namespace |
| OLD | NEW |