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): Calling this when parent_routing_id != MSG_ROUTING_NONE is | |
| 93 // mostly redundant, since we already pass the name and sandbox flags in | |
| 94 // createLocalChild(). We should update the Bilnk interface so it also takes | |
|
Charlie Reis
2015/05/21 23:18:17
nit: Blink
dcheng
2015/05/22 01:24:14
Dnoe.
| |
| 95 // the origin. Then it will be clear that the replication call is only needed | |
| 96 // for the case of setting up a main frame proxy. | |
| 88 proxy->SetReplicatedState(replicated_state); | 97 proxy->SetReplicatedState(replicated_state); |
| 89 | 98 |
| 90 return proxy.release(); | 99 return proxy.release(); |
| 91 } | 100 } |
| 92 | 101 |
| 93 // static | 102 // static |
| 94 RenderFrameProxy* RenderFrameProxy::FromRoutingID(int32 routing_id) { | 103 RenderFrameProxy* RenderFrameProxy::FromRoutingID(int32 routing_id) { |
| 95 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); | 104 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); |
| 96 RoutingIDProxyMap::iterator it = proxies->find(routing_id); | 105 RoutingIDProxyMap::iterator it = proxies->find(routing_id); |
| 97 return it == proxies->end() ? NULL : it->second; | 106 return it == proxies->end() ? NULL : it->second; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 blink::WebUserGestureIndicator::isProcessingUserGesture(); | 389 blink::WebUserGestureIndicator::isProcessingUserGesture(); |
| 381 blink::WebUserGestureIndicator::consumeUserGesture(); | 390 blink::WebUserGestureIndicator::consumeUserGesture(); |
| 382 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 391 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
| 383 } | 392 } |
| 384 | 393 |
| 385 void RenderFrameProxy::forwardInputEvent(const blink::WebInputEvent* event) { | 394 void RenderFrameProxy::forwardInputEvent(const blink::WebInputEvent* event) { |
| 386 Send(new FrameHostMsg_ForwardInputEvent(routing_id_, event)); | 395 Send(new FrameHostMsg_ForwardInputEvent(routing_id_, event)); |
| 387 } | 396 } |
| 388 | 397 |
| 389 } // namespace | 398 } // namespace |
| OLD | NEW |