| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // follow later. | 53 // follow later. |
| 54 blink::WebRemoteFrame* web_frame = | 54 blink::WebRemoteFrame* web_frame = |
| 55 blink::WebRemoteFrame::create(scope, proxy.get()); | 55 blink::WebRemoteFrame::create(scope, proxy.get()); |
| 56 proxy->Init(web_frame, frame_to_replace->render_view()); | 56 proxy->Init(web_frame, frame_to_replace->render_view()); |
| 57 return proxy.release(); | 57 return proxy.release(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 RenderFrameProxy* RenderFrameProxy::CreateFrameProxy( | 60 RenderFrameProxy* RenderFrameProxy::CreateFrameProxy( |
| 61 int routing_id, | 61 int routing_id, |
| 62 int parent_routing_id, | 62 int parent_routing_id, |
| 63 int opener_routing_id, |
| 63 int render_view_routing_id, | 64 int render_view_routing_id, |
| 64 const FrameReplicationState& replicated_state) { | 65 const FrameReplicationState& replicated_state) { |
| 65 scoped_ptr<RenderFrameProxy> proxy( | 66 scoped_ptr<RenderFrameProxy> proxy( |
| 66 new RenderFrameProxy(routing_id, MSG_ROUTING_NONE)); | 67 new RenderFrameProxy(routing_id, MSG_ROUTING_NONE)); |
| 67 RenderViewImpl* render_view = NULL; | 68 RenderViewImpl* render_view = NULL; |
| 68 blink::WebRemoteFrame* web_frame = NULL; | 69 blink::WebRemoteFrame* web_frame = NULL; |
| 69 if (parent_routing_id == MSG_ROUTING_NONE) { | 70 if (parent_routing_id == MSG_ROUTING_NONE) { |
| 70 // Create a top level WebRemoteFrame. | 71 // Create a top level WebRemoteFrame. |
| 71 render_view = RenderViewImpl::FromRoutingID(render_view_routing_id); | 72 render_view = RenderViewImpl::FromRoutingID(render_view_routing_id); |
| 72 web_frame = | 73 web_frame = |
| 73 blink::WebRemoteFrame::create(replicated_state.scope, proxy.get()); | 74 blink::WebRemoteFrame::create(replicated_state.scope, proxy.get()); |
| 74 render_view->webview()->setMainFrame(web_frame); | 75 render_view->webview()->setMainFrame(web_frame); |
| 75 } else { | 76 } else { |
| 76 // Create a frame under an existing parent. The parent is always expected | 77 // Create a frame under an existing parent. The parent is always expected |
| 77 // to be a RenderFrameProxy, because navigations initiated by local frames | 78 // to be a RenderFrameProxy, because navigations initiated by local frames |
| 78 // should not wind up here. | 79 // should not wind up here. |
| 79 RenderFrameProxy* parent = | 80 RenderFrameProxy* parent = |
| 80 RenderFrameProxy::FromRoutingID(parent_routing_id); | 81 RenderFrameProxy::FromRoutingID(parent_routing_id); |
| 81 web_frame = parent->web_frame()->createRemoteChild( | 82 web_frame = parent->web_frame()->createRemoteChild( |
| 82 replicated_state.scope, | 83 replicated_state.scope, |
| 83 blink::WebString::fromUTF8(replicated_state.name), | 84 blink::WebString::fromUTF8(replicated_state.name), |
| 84 replicated_state.sandbox_flags, proxy.get()); | 85 replicated_state.sandbox_flags, proxy.get()); |
| 85 render_view = parent->render_view(); | 86 render_view = parent->render_view(); |
| 86 } | 87 } |
| 87 | 88 |
| 89 blink::WebFrame* opener = |
| 90 RenderFrameImpl::ResolveOpener(opener_routing_id, nullptr); |
| 91 web_frame->setOpener(opener); |
| 92 |
| 88 proxy->Init(web_frame, render_view); | 93 proxy->Init(web_frame, render_view); |
| 89 | 94 |
| 90 // Initialize proxy's WebRemoteFrame with the security origin and other | 95 // Initialize proxy's WebRemoteFrame with the security origin and other |
| 91 // replicated information. | 96 // replicated information. |
| 92 // TODO(dcheng): Calling this when parent_routing_id != MSG_ROUTING_NONE is | 97 // 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 | 98 // mostly redundant, since we already pass the name and sandbox flags in |
| 94 // createLocalChild(). We should update the Blink interface so it also takes | 99 // createLocalChild(). We should update the Blink interface so it also takes |
| 95 // the origin. Then it will be clear that the replication call is only needed | 100 // 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. | 101 // for the case of setting up a main frame proxy. |
| 97 proxy->SetReplicatedState(replicated_state); | 102 proxy->SetReplicatedState(replicated_state); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 // Only a LocalFrame (i.e., the caller of window.open) should be able to | 427 // Only a LocalFrame (i.e., the caller of window.open) should be able to |
| 423 // update another frame's opener. | 428 // update another frame's opener. |
| 424 DCHECK(opener->isWebLocalFrame()); | 429 DCHECK(opener->isWebLocalFrame()); |
| 425 | 430 |
| 426 int opener_routing_id = | 431 int opener_routing_id = |
| 427 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID(); | 432 RenderFrameImpl::FromWebFrame(opener->toWebLocalFrame())->GetRoutingID(); |
| 428 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id)); | 433 Send(new FrameHostMsg_DidChangeOpener(routing_id_, opener_routing_id)); |
| 429 } | 434 } |
| 430 | 435 |
| 431 } // namespace | 436 } // namespace |
| OLD | NEW |