| 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_IMPLIES(!render_view_host, | 60 CHECK_IMPLIES(!render_view_host, |
| 61 frame_tree_node_->render_manager()->ForInnerDelegate()); | 61 frame_tree_node_->render_manager()->ForInnerDelegate() && |
| 62 frame_tree_node_->IsMainFrame()); |
| 62 if (render_view_host) | 63 if (render_view_host) |
| 63 frame_tree_node_->frame_tree()->AddRenderViewHostRef(render_view_host_); | 64 frame_tree_node_->frame_tree()->AddRenderViewHostRef(render_view_host_); |
| 64 | 65 |
| 65 bool is_proxy_to_parent = !frame_tree_node_->IsMainFrame() && | 66 bool is_proxy_to_parent = !frame_tree_node_->IsMainFrame() && |
| 66 frame_tree_node_->parent() | 67 frame_tree_node_->parent() |
| 67 ->render_manager() | 68 ->render_manager() |
| 68 ->current_frame_host() | 69 ->current_frame_host() |
| 69 ->GetSiteInstance() == site_instance; | 70 ->GetSiteInstance() == site_instance; |
| 71 bool is_proxy_to_outer_delegate = |
| 72 frame_tree_node_->IsMainFrame() && |
| 73 frame_tree_node_->render_manager()->ForInnerDelegate(); |
| 70 | 74 |
| 71 // If this is a proxy to parent frame or this proxy is for the inner | 75 // If this is a proxy to parent frame or this proxy is for the inner |
| 72 // WebContents's FrameTreeNode in outer WebContents's SiteInstance, then we | 76 // WebContents's FrameTreeNode in outer WebContents's SiteInstance, then we |
| 73 // need a CrossProcessFrameConnector. | 77 // need a CrossProcessFrameConnector. |
| 74 if (is_proxy_to_parent || | 78 if (is_proxy_to_parent || is_proxy_to_outer_delegate) { |
| 75 frame_tree_node_->render_manager()->ForInnerDelegate()) { | |
| 76 // The RenderFrameHost navigating cross-process is destroyed and a proxy for | 79 // The RenderFrameHost navigating cross-process is destroyed and a proxy for |
| 77 // it is created in the parent's process. CrossProcessFrameConnector | 80 // it is created in the parent's process. CrossProcessFrameConnector |
| 78 // initialization only needs to happen on an initial cross-process | 81 // initialization only needs to happen on an initial cross-process |
| 79 // navigation, when the RenderFrameHost leaves the same process as its | 82 // navigation, when the RenderFrameHost leaves the same process as its |
| 80 // parent. The same CrossProcessFrameConnector is used for subsequent cross- | 83 // parent. The same CrossProcessFrameConnector is used for subsequent cross- |
| 81 // process navigations, but it will be destroyed if the frame is | 84 // process navigations, but it will be destroyed if the frame is |
| 82 // navigated back to the same SiteInstance as its parent. | 85 // navigated back to the same SiteInstance as its parent. |
| 83 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); | 86 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); |
| 84 } | 87 } |
| 85 } | 88 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 render_frame_proxy_created_ = true; | 195 render_frame_proxy_created_ = true; |
| 193 return true; | 196 return true; |
| 194 } | 197 } |
| 195 | 198 |
| 196 void RenderFrameProxyHost::DisownOpener() { | 199 void RenderFrameProxyHost::DisownOpener() { |
| 197 Send(new FrameMsg_DisownOpener(GetRoutingID())); | 200 Send(new FrameMsg_DisownOpener(GetRoutingID())); |
| 198 } | 201 } |
| 199 | 202 |
| 200 void RenderFrameProxyHost::OnDetach() { | 203 void RenderFrameProxyHost::OnDetach() { |
| 201 if (frame_tree_node_->render_manager()->ForInnerDelegate()) { | 204 if (frame_tree_node_->render_manager()->ForInnerDelegate()) { |
| 205 // Only main frame proxy can detach for inner WebContents. |
| 206 DCHECK(frame_tree_node_->IsMainFrame()); |
| 202 frame_tree_node_->render_manager()->RemoveOuterDelegateFrame(); | 207 frame_tree_node_->render_manager()->RemoveOuterDelegateFrame(); |
| 203 return; | 208 return; |
| 204 } | 209 } |
| 205 | 210 |
| 206 // This message should only be received for subframes. Note that we can't | 211 // This message should only be received for subframes. Note that we can't |
| 207 // restrict it to just the current SiteInstances of the ancestors of this | 212 // restrict it to just the current SiteInstances of the ancestors of this |
| 208 // frame, because another frame in the tree may be able to detach this frame | 213 // frame, because another frame in the tree may be able to detach this frame |
| 209 // by navigating its parent. | 214 // by navigating its parent. |
| 210 if (frame_tree_node_->IsMainFrame()) { | 215 if (frame_tree_node_->IsMainFrame()) { |
| 211 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH); | 216 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, | 292 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, |
| 288 message_port_message_filter, target_rfh->GetRoutingID(), | 293 message_port_message_filter, target_rfh->GetRoutingID(), |
| 289 new_params)); | 294 new_params)); |
| 290 } else { | 295 } else { |
| 291 target_rfh->Send( | 296 target_rfh->Send( |
| 292 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); | 297 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); |
| 293 } | 298 } |
| 294 } | 299 } |
| 295 | 300 |
| 296 } // namespace content | 301 } // namespace content |
| OLD | NEW |