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 <stdint.h> | 7 #include <stdint.h> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 RenderFrameProxy* parent = nullptr; | 82 RenderFrameProxy* parent = nullptr; |
83 if (parent_routing_id != MSG_ROUTING_NONE) { | 83 if (parent_routing_id != MSG_ROUTING_NONE) { |
84 parent = RenderFrameProxy::FromRoutingID(parent_routing_id); | 84 parent = RenderFrameProxy::FromRoutingID(parent_routing_id); |
85 // It is possible that the parent proxy has been detached in this renderer | 85 // It is possible that the parent proxy has been detached in this renderer |
86 // process, just as the parent's real frame was creating this child frame. | 86 // process, just as the parent's real frame was creating this child frame. |
87 // In this case, do not create the proxy. See https://crbug.com/568670. | 87 // In this case, do not create the proxy. See https://crbug.com/568670. |
88 if (!parent) | 88 if (!parent) |
89 return nullptr; | 89 return nullptr; |
90 } | 90 } |
91 | 91 |
92 blink::WebFrame* opener = | |
93 RenderFrameImpl::ResolveOpener(opener_routing_id, nullptr); | |
dcheng
2016/02/23 00:11:32
It's a bit awkward to do this lookup again, but th
| |
94 | |
92 scoped_ptr<RenderFrameProxy> proxy( | 95 scoped_ptr<RenderFrameProxy> proxy( |
93 new RenderFrameProxy(routing_id, MSG_ROUTING_NONE)); | 96 new RenderFrameProxy(routing_id, MSG_ROUTING_NONE)); |
94 RenderViewImpl* render_view = nullptr; | 97 RenderViewImpl* render_view = nullptr; |
95 RenderWidget* render_widget = nullptr; | 98 RenderWidget* render_widget = nullptr; |
96 blink::WebRemoteFrame* web_frame = nullptr; | 99 blink::WebRemoteFrame* web_frame = nullptr; |
97 | 100 |
98 if (!parent) { | 101 if (!parent) { |
99 // Create a top level WebRemoteFrame. | 102 // Create a top level WebRemoteFrame. |
100 render_view = RenderViewImpl::FromRoutingID(render_view_routing_id); | 103 render_view = RenderViewImpl::FromRoutingID(render_view_routing_id); |
101 web_frame = | 104 web_frame = blink::WebRemoteFrame::create(replicated_state.scope, |
102 blink::WebRemoteFrame::create(replicated_state.scope, proxy.get()); | 105 proxy.get(), opener); |
103 render_view->webview()->setMainFrame(web_frame); | 106 render_view->webview()->setMainFrame(web_frame); |
104 render_widget = render_view; | 107 render_widget = render_view; |
105 } else { | 108 } else { |
106 // Create a frame under an existing parent. The parent is always expected | 109 // Create a frame under an existing parent. The parent is always expected |
107 // to be a RenderFrameProxy, because navigations initiated by local frames | 110 // to be a RenderFrameProxy, because navigations initiated by local frames |
108 // should not wind up here. | 111 // should not wind up here. |
109 | 112 |
110 web_frame = parent->web_frame()->createRemoteChild( | 113 web_frame = parent->web_frame()->createRemoteChild( |
111 replicated_state.scope, | 114 replicated_state.scope, |
112 blink::WebString::fromUTF8(replicated_state.name), | 115 blink::WebString::fromUTF8(replicated_state.name), |
113 blink::WebString::fromUTF8(replicated_state.unique_name), | 116 blink::WebString::fromUTF8(replicated_state.unique_name), |
114 replicated_state.sandbox_flags, proxy.get()); | 117 replicated_state.sandbox_flags, proxy.get(), opener); |
115 render_view = parent->render_view(); | 118 render_view = parent->render_view(); |
116 render_widget = parent->render_widget(); | 119 render_widget = parent->render_widget(); |
117 } | 120 } |
118 | 121 |
119 blink::WebFrame* opener = | |
120 RenderFrameImpl::ResolveOpener(opener_routing_id, nullptr); | |
121 web_frame->setOpener(opener); | |
122 | |
123 proxy->Init(web_frame, render_view, render_widget); | 122 proxy->Init(web_frame, render_view, render_widget); |
124 | 123 |
125 // Initialize proxy's WebRemoteFrame with the security origin and other | 124 // Initialize proxy's WebRemoteFrame with the security origin and other |
126 // replicated information. | 125 // replicated information. |
127 // TODO(dcheng): Calling this when parent_routing_id != MSG_ROUTING_NONE is | 126 // TODO(dcheng): Calling this when parent_routing_id != MSG_ROUTING_NONE is |
128 // mostly redundant, since we already pass the name and sandbox flags in | 127 // mostly redundant, since we already pass the name and sandbox flags in |
129 // createLocalChild(). We should update the Blink interface so it also takes | 128 // createLocalChild(). We should update the Blink interface so it also takes |
130 // the origin. Then it will be clear that the replication call is only needed | 129 // the origin. Then it will be clear that the replication call is only needed |
131 // for the case of setting up a main frame proxy. | 130 // for the case of setting up a main frame proxy. |
132 proxy->SetReplicatedState(replicated_state); | 131 proxy->SetReplicatedState(replicated_state); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 blink::WebLocalFrame* source) { | 479 blink::WebLocalFrame* source) { |
481 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); | 480 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); |
482 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); | 481 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); |
483 } | 482 } |
484 | 483 |
485 void RenderFrameProxy::frameFocused() { | 484 void RenderFrameProxy::frameFocused() { |
486 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 485 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
487 } | 486 } |
488 | 487 |
489 } // namespace | 488 } // namespace |
OLD | NEW |