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/browser/frame_host/render_frame_proxy_host.h" | 5 #include "content/browser/frame_host/render_frame_proxy_host.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "content/browser/bad_message.h" | 8 #include "content/browser/bad_message.h" |
9 #include "content/browser/frame_host/cross_process_frame_connector.h" | 9 #include "content/browser/frame_host/cross_process_frame_connector.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 process_(site_instance->GetProcess()), | 51 process_(site_instance->GetProcess()), |
52 frame_tree_node_(frame_tree_node), | 52 frame_tree_node_(frame_tree_node), |
53 render_frame_proxy_created_(false), | 53 render_frame_proxy_created_(false), |
54 render_view_host_(render_view_host) { | 54 render_view_host_(render_view_host) { |
55 GetProcess()->AddRoute(routing_id_, this); | 55 GetProcess()->AddRoute(routing_id_, this); |
56 CHECK(g_routing_id_frame_proxy_map.Get().insert( | 56 CHECK(g_routing_id_frame_proxy_map.Get().insert( |
57 std::make_pair( | 57 std::make_pair( |
58 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), | 58 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), |
59 this)).second); | 59 this)).second); |
60 CHECK(render_view_host_); | 60 CHECK(render_view_host_); |
61 frame_tree_node_->frame_tree()->AddRenderViewHostRef(render_view_host_); | 61 // TODO(lazyboy): Comment why we skip this. |
| 62 if (!frame_tree_node_->render_manager()->ForInnerDelegate()) |
| 63 frame_tree_node_->frame_tree()->AddRenderViewHostRef(render_view_host_); |
62 | 64 |
63 if (!frame_tree_node_->IsMainFrame() && | 65 bool is_proxy_to_parent = !frame_tree_node_->IsMainFrame() && |
64 frame_tree_node_->parent() | 66 frame_tree_node_->parent() |
65 ->render_manager() | 67 ->render_manager() |
66 ->current_frame_host() | 68 ->current_frame_host() |
67 ->GetSiteInstance() == site_instance) { | 69 ->GetSiteInstance() == site_instance; |
| 70 |
| 71 // If this is a proxy to parent frame or this proxy is for the inner |
| 72 // WebContents's FrameTreeNode in outer WebContents's process, then we need a |
| 73 // CrossProcessFrameConnector. |
| 74 if (is_proxy_to_parent || |
| 75 frame_tree_node_->render_manager()->ForInnerDelegate()) { |
68 // The RenderFrameHost navigating cross-process is destroyed and a proxy for | 76 // The RenderFrameHost navigating cross-process is destroyed and a proxy for |
69 // it is created in the parent's process. CrossProcessFrameConnector | 77 // it is created in the parent's process. CrossProcessFrameConnector |
70 // initialization only needs to happen on an initial cross-process | 78 // initialization only needs to happen on an initial cross-process |
71 // navigation, when the RenderFrameHost leaves the same process as its | 79 // navigation, when the RenderFrameHost leaves the same process as its |
72 // parent. The same CrossProcessFrameConnector is used for subsequent cross- | 80 // parent. The same CrossProcessFrameConnector is used for subsequent cross- |
73 // process navigations, but it will be destroyed if the frame is | 81 // process navigations, but it will be destroyed if the frame is |
74 // navigated back to the same SiteInstance as its parent. | 82 // navigated back to the same SiteInstance as its parent. |
75 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); | 83 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); |
76 } | 84 } |
77 } | 85 } |
78 | 86 |
79 RenderFrameProxyHost::~RenderFrameProxyHost() { | 87 RenderFrameProxyHost::~RenderFrameProxyHost() { |
80 if (GetProcess()->HasConnection()) { | 88 if (GetProcess()->HasConnection()) { |
81 // TODO(nasko): For now, don't send this IPC for top-level frames, as | 89 // TODO(nasko): For now, don't send this IPC for top-level frames, as |
82 // the top-level RenderFrame will delete the RenderFrameProxy. | 90 // the top-level RenderFrame will delete the RenderFrameProxy. |
83 // This can be removed once we don't have a swapped out state on | 91 // This can be removed once we don't have a swapped out state on |
84 // RenderFrame. See https://crbug.com/357747 | 92 // RenderFrame. See https://crbug.com/357747 |
85 if (!frame_tree_node_->IsMainFrame()) | 93 if (!frame_tree_node_->IsMainFrame()) |
86 Send(new FrameMsg_DeleteProxy(routing_id_)); | 94 Send(new FrameMsg_DeleteProxy(routing_id_)); |
87 } | 95 } |
88 | 96 |
89 frame_tree_node_->frame_tree()->ReleaseRenderViewHostRef(render_view_host_); | 97 // TODO(lazyboy): Comment why we skip this. |
| 98 if (!frame_tree_node_->render_manager()->ForInnerDelegate()) |
| 99 frame_tree_node_->frame_tree()->ReleaseRenderViewHostRef(render_view_host_); |
90 GetProcess()->RemoveRoute(routing_id_); | 100 GetProcess()->RemoveRoute(routing_id_); |
91 g_routing_id_frame_proxy_map.Get().erase( | 101 g_routing_id_frame_proxy_map.Get().erase( |
92 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_)); | 102 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_)); |
93 } | 103 } |
94 | 104 |
95 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { | 105 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { |
96 cross_process_frame_connector_->set_view( | 106 cross_process_frame_connector_->set_view( |
97 static_cast<RenderWidgetHostViewChildFrame*>(view)); | 107 static_cast<RenderWidgetHostViewChildFrame*>(view)); |
98 } | 108 } |
99 | 109 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 188 |
179 render_frame_proxy_created_ = true; | 189 render_frame_proxy_created_ = true; |
180 return true; | 190 return true; |
181 } | 191 } |
182 | 192 |
183 void RenderFrameProxyHost::DisownOpener() { | 193 void RenderFrameProxyHost::DisownOpener() { |
184 Send(new FrameMsg_DisownOpener(GetRoutingID())); | 194 Send(new FrameMsg_DisownOpener(GetRoutingID())); |
185 } | 195 } |
186 | 196 |
187 void RenderFrameProxyHost::OnDetach() { | 197 void RenderFrameProxyHost::OnDetach() { |
| 198 if (frame_tree_node_->render_manager()->ForInnerDelegate()) { |
| 199 frame_tree_node_->render_manager()->RemoveOuterDelegateFrame(); |
| 200 return; |
| 201 } |
| 202 |
188 // This message should only be received for subframes. Note that we can't | 203 // This message should only be received for subframes. Note that we can't |
189 // restrict it to just the current SiteInstances of the ancestors of this | 204 // restrict it to just the current SiteInstances of the ancestors of this |
190 // frame, because another frame in the tree may be able to detach this frame | 205 // frame, because another frame in the tree may be able to detach this frame |
191 // by navigating its parent. | 206 // by navigating its parent. |
192 if (frame_tree_node_->IsMainFrame()) { | 207 if (frame_tree_node_->IsMainFrame()) { |
193 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH); | 208 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH); |
194 return; | 209 return; |
195 } | 210 } |
196 frame_tree_node_->frame_tree()->RemoveFrame(frame_tree_node_); | 211 frame_tree_node_->frame_tree()->RemoveFrame(frame_tree_node_); |
197 } | 212 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, | 293 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, |
279 message_port_message_filter, target_rfh->GetRoutingID(), | 294 message_port_message_filter, target_rfh->GetRoutingID(), |
280 new_params)); | 295 new_params)); |
281 } else { | 296 } else { |
282 target_rfh->Send( | 297 target_rfh->Send( |
283 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); | 298 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); |
284 } | 299 } |
285 } | 300 } |
286 | 301 |
287 } // namespace content | 302 } // namespace content |
OLD | NEW |