OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 329 } |
330 | 330 |
331 void RenderFrameHostManager::OnCrossSiteResponse( | 331 void RenderFrameHostManager::OnCrossSiteResponse( |
332 RenderFrameHostImpl* pending_render_frame_host, | 332 RenderFrameHostImpl* pending_render_frame_host, |
333 const GlobalRequestID& global_request_id, | 333 const GlobalRequestID& global_request_id, |
334 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request, | 334 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request, |
335 const std::vector<GURL>& transfer_url_chain, | 335 const std::vector<GURL>& transfer_url_chain, |
336 const Referrer& referrer, | 336 const Referrer& referrer, |
337 PageTransition page_transition, | 337 PageTransition page_transition, |
338 bool should_replace_current_entry) { | 338 bool should_replace_current_entry) { |
| 339 LOG(ERROR) << "RFHM::OnCrossSiteResponse[" << this << "]"; |
339 // This should be called either when the pending RFH is ready to commit or | 340 // This should be called either when the pending RFH is ready to commit or |
340 // when we realize that the current RFH's request requires a transfer. | 341 // when we realize that the current RFH's request requires a transfer. |
341 DCHECK(pending_render_frame_host == pending_render_frame_host_ || | 342 DCHECK(pending_render_frame_host == pending_render_frame_host_ || |
342 pending_render_frame_host == render_frame_host_); | 343 pending_render_frame_host == render_frame_host_); |
343 | 344 |
344 // TODO(creis): Eventually we will want to check all navigation responses | 345 // TODO(creis): Eventually we will want to check all navigation responses |
345 // here, but currently we pass information for a transfer if | 346 // here, but currently we pass information for a transfer if |
346 // ShouldSwapProcessesForRedirect returned true in the network stack. | 347 // ShouldSwapProcessesForRedirect returned true in the network stack. |
347 // In that case, we should set up a transfer after the unload handler runs. | 348 // In that case, we should set up a transfer after the unload handler runs. |
348 // If |cross_site_transferring_request| is NULL, we will just run the unload | 349 // If |cross_site_transferring_request| is NULL, we will just run the unload |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 static_cast<RenderProcessHostImpl*>( | 433 static_cast<RenderProcessHostImpl*>( |
433 pending_render_frame_host_->GetProcess()); | 434 pending_render_frame_host_->GetProcess()); |
434 pending_process->ResumeDeferredNavigation( | 435 pending_process->ResumeDeferredNavigation( |
435 pending_nav_params_->global_request_id); | 436 pending_nav_params_->global_request_id); |
436 } | 437 } |
437 pending_nav_params_.reset(); | 438 pending_nav_params_.reset(); |
438 } | 439 } |
439 | 440 |
440 void RenderFrameHostManager::DidNavigateFrame( | 441 void RenderFrameHostManager::DidNavigateFrame( |
441 RenderFrameHostImpl* render_frame_host) { | 442 RenderFrameHostImpl* render_frame_host) { |
| 443 LOG(ERROR) << "RFHM[" << this << "]::DidNavigateFrame:"; |
442 if (!cross_navigation_pending_) { | 444 if (!cross_navigation_pending_) { |
443 DCHECK(!pending_render_frame_host_); | 445 DCHECK(!pending_render_frame_host_); |
444 | 446 |
445 // We should only hear this from our current renderer. | 447 // We should only hear this from our current renderer. |
446 DCHECK_EQ(render_frame_host_, render_frame_host); | 448 DCHECK_EQ(render_frame_host_, render_frame_host); |
447 | 449 |
448 // Even when there is no pending RVH, there may be a pending Web UI. | 450 // Even when there is no pending RVH, there may be a pending Web UI. |
449 if (pending_web_ui()) | 451 if (pending_web_ui()) |
450 CommitPending(); | 452 CommitPending(); |
451 return; | 453 return; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 // from the map and not leaked. | 532 // from the map and not leaked. |
531 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find( | 533 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find( |
532 render_frame_host_->GetSiteInstance()->GetId()); | 534 render_frame_host_->GetSiteInstance()->GetId()); |
533 if (iter != proxy_hosts_.end()) { | 535 if (iter != proxy_hosts_.end()) { |
534 delete iter->second; | 536 delete iter->second; |
535 proxy_hosts_.erase(iter); | 537 proxy_hosts_.erase(iter); |
536 } | 538 } |
537 | 539 |
538 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | 540 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
539 render_frame_host_->GetSiteInstance(), frame_tree_node_); | 541 render_frame_host_->GetSiteInstance(), frame_tree_node_); |
540 proxy_hosts_[render_frame_host_->GetSiteInstance()->GetId()] = proxy; | 542 std::pair<RenderFrameProxyHostMap::iterator, bool> result = |
| 543 proxy_hosts_.insert(std::make_pair( |
| 544 render_frame_host_->GetSiteInstance()->GetId(), proxy)); |
| 545 CHECK(result.second) << "Inserting a duplicate item."; |
541 | 546 |
542 // Tell the old frame it is being swapped out. This will fire the unload | 547 // Tell the old frame it is being swapped out. This will fire the unload |
543 // handler in the background (without firing the beforeunload handler a second | 548 // handler in the background (without firing the beforeunload handler a second |
544 // time). When the navigation completes, we will send a message to the | 549 // time). When the navigation completes, we will send a message to the |
545 // ResourceDispatcherHost, allowing the pending RVH's response to resume. | 550 // ResourceDispatcherHost, allowing the pending RVH's response to resume. |
546 render_frame_host_->SwapOut(proxy); | 551 render_frame_host_->SwapOut(proxy); |
547 | 552 |
548 // ResourceDispatcherHost has told us to run the onunload handler, which | 553 // ResourceDispatcherHost has told us to run the onunload handler, which |
549 // means it is not a download or unsafe page, and we are going to perform the | 554 // means it is not a download or unsafe page, and we are going to perform the |
550 // navigation. Thus, we no longer need to remember that the RenderFrameHost | 555 // navigation. Thus, we no longer need to remember that the RenderFrameHost |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 | 878 |
874 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost( | 879 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost( |
875 SiteInstance* site_instance, | 880 SiteInstance* site_instance, |
876 int view_routing_id, | 881 int view_routing_id, |
877 int frame_routing_id, | 882 int frame_routing_id, |
878 bool swapped_out, | 883 bool swapped_out, |
879 bool hidden) { | 884 bool hidden) { |
880 if (frame_routing_id == MSG_ROUTING_NONE) | 885 if (frame_routing_id == MSG_ROUTING_NONE) |
881 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); | 886 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); |
882 | 887 |
883 // Create a RVH for main frames, or find the existing one for subframes. | 888 // Create a RVH for the new frame or find an existing one. |
884 FrameTree* frame_tree = frame_tree_node_->frame_tree(); | 889 FrameTree* frame_tree = frame_tree_node_->frame_tree(); |
885 RenderViewHostImpl* render_view_host = NULL; | 890 RenderViewHostImpl* render_view_host = |
886 if (frame_tree_node_->IsMainFrame()) { | 891 frame_tree->GetRenderViewHost(site_instance); |
887 render_view_host = frame_tree->CreateRenderViewHostForMainFrame( | 892 LOG(ERROR) << "RFHM::CreateRenderFrameHost[" << this << "]:" |
| 893 << " routing_id: " << frame_routing_id |
| 894 << ", rvh: " << render_view_host |
| 895 << ", swapped_out: " << swapped_out; |
| 896 if (!render_view_host) { |
| 897 render_view_host = frame_tree->CreateRenderViewHost( |
888 site_instance, view_routing_id, frame_routing_id, swapped_out, hidden); | 898 site_instance, view_routing_id, frame_routing_id, swapped_out, hidden); |
889 } else { | |
890 render_view_host = frame_tree->GetRenderViewHostForSubFrame(site_instance); | |
891 | |
892 // If we haven't found a RVH for a subframe RFH, it's because we currently | |
893 // do not create top-level RFHs for pending subframe navigations. Create | |
894 // the RVH here for now. | |
895 // TODO(creis): Mirror the frame tree so this check isn't necessary. | |
896 if (!render_view_host) { | |
897 render_view_host = frame_tree->CreateRenderViewHostForMainFrame( | |
898 site_instance, view_routing_id, frame_routing_id, swapped_out, | |
899 hidden); | |
900 } | |
901 } | 899 } |
902 | 900 |
903 // TODO(creis): Pass hidden to RFH. | 901 // TODO(creis): Pass hidden to RFH. |
904 scoped_ptr<RenderFrameHostImpl> render_frame_host = | 902 scoped_ptr<RenderFrameHostImpl> render_frame_host = |
905 make_scoped_ptr(RenderFrameHostFactory::Create(render_view_host, | 903 make_scoped_ptr(RenderFrameHostFactory::Create(render_view_host, |
906 render_frame_delegate_, | 904 render_frame_delegate_, |
907 frame_tree, | 905 frame_tree, |
908 frame_tree_node_, | 906 frame_tree_node_, |
909 frame_routing_id, | 907 frame_routing_id, |
910 swapped_out).release()); | 908 swapped_out).release()); |
911 return render_frame_host.Pass(); | 909 return render_frame_host.Pass(); |
912 } | 910 } |
913 | 911 |
914 int RenderFrameHostManager::CreateRenderFrame( | 912 int RenderFrameHostManager::CreateRenderFrame( |
915 SiteInstance* instance, | 913 SiteInstance* instance, |
916 int opener_route_id, | 914 int opener_route_id, |
917 bool swapped_out, | 915 bool swapped_out, |
| 916 bool for_main_frame, |
918 bool hidden) { | 917 bool hidden) { |
919 CHECK(instance); | 918 CHECK(instance); |
920 DCHECK(!swapped_out || hidden); // Swapped out views should always be hidden. | 919 DCHECK(!swapped_out || hidden); // Swapped out views should always be hidden. |
921 | 920 |
| 921 LOG(ERROR) << "RFHM::CreateRenderFrame[" << this << "]:" |
| 922 << " site:" << instance->GetSiteURL() << ", swapped:" << swapped_out; |
| 923 |
| 924 // TODO(nasko): Remove this check once cross-site navigation no longer |
| 925 // relies on swapped out RFH for the top-level frame. |
| 926 if (!frame_tree_node_->IsMainFrame()) { |
| 927 CHECK(!swapped_out); |
| 928 } |
| 929 |
922 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 930 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
923 RenderFrameHostImpl* frame_to_announce = NULL; | 931 RenderFrameHostImpl* frame_to_announce = NULL; |
924 int routing_id = MSG_ROUTING_NONE; | 932 int routing_id = MSG_ROUTING_NONE; |
925 | 933 |
926 // We are creating a pending or swapped out RFH here. We should never create | 934 // We are creating a pending or swapped out RFH here. We should never create |
927 // it in the same SiteInstance as our current RFH. | 935 // it in the same SiteInstance as our current RFH. |
928 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); | 936 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); |
929 | 937 |
930 // Check if we've already created an RFH for this SiteInstance. If so, try | 938 // Check if we've already created an RFH for this SiteInstance. If so, try |
931 // to re-use the existing one, which has already been initialized. We'll | 939 // to re-use the existing one, which has already been initialized. We'll |
932 // remove it from the list of swapped out hosts if it commits. | 940 // remove it from the list of swapped out hosts if it commits. |
933 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 941 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
934 | 942 |
935 if (proxy) { | 943 if (proxy) { |
936 routing_id = proxy->GetRenderViewHost()->GetRoutingID(); | 944 routing_id = proxy->GetRoutingID(); |
| 945 LOG(ERROR) << "RFHM::CreateRenderFrame[" << this << "]:" |
| 946 << " proxy exists: " << routing_id; |
937 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. | 947 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. |
938 // Prevent the process from exiting while we're trying to use it. | 948 // Prevent the process from exiting while we're trying to use it. |
939 if (!swapped_out) { | 949 if (!swapped_out) { |
940 new_render_frame_host = proxy->PassFrameHostOwnership(); | 950 new_render_frame_host = proxy->PassFrameHostOwnership(); |
941 new_render_frame_host->GetProcess()->AddPendingView(); | 951 new_render_frame_host->GetProcess()->AddPendingView(); |
942 | 952 |
943 proxy_hosts_.erase(instance->GetId()); | 953 proxy_hosts_.erase(instance->GetId()); |
944 delete proxy; | 954 delete proxy; |
945 | 955 |
946 // When a new render view is created by the renderer, the new WebContents | 956 // When a new render view is created by the renderer, the new WebContents |
947 // gets a RenderViewHost in the SiteInstance of its opener WebContents. | 957 // gets a RenderViewHost in the SiteInstance of its opener WebContents. |
948 // If not used in the first navigation, this RVH is swapped out and is not | 958 // If not used in the first navigation, this RVH is swapped out and is not |
949 // granted bindings, so we may need to grant them when swapping it in. | 959 // granted bindings, so we may need to grant them when swapping it in. |
950 if (pending_web_ui() && | 960 if (pending_web_ui() && |
951 !new_render_frame_host->GetProcess()->IsIsolatedGuest()) { | 961 !new_render_frame_host->GetProcess()->IsIsolatedGuest()) { |
952 int required_bindings = pending_web_ui()->GetBindings(); | 962 int required_bindings = pending_web_ui()->GetBindings(); |
953 RenderViewHost* rvh = new_render_frame_host->render_view_host(); | 963 RenderViewHost* rvh = new_render_frame_host->render_view_host(); |
954 if ((rvh->GetEnabledBindings() & required_bindings) != | 964 if ((rvh->GetEnabledBindings() & required_bindings) != |
955 required_bindings) { | 965 required_bindings) { |
956 rvh->AllowBindings(required_bindings); | 966 rvh->AllowBindings(required_bindings); |
957 } | 967 } |
958 } | 968 } |
959 } | 969 } |
960 } else { | 970 } else { |
| 971 LOG(ERROR) << "RFHM::CreateRenderFrame[" << this << "]:" |
| 972 << " creating new RFH"; |
961 // Create a new RenderFrameHost if we don't find an existing one. | 973 // Create a new RenderFrameHost if we don't find an existing one. |
962 new_render_frame_host = CreateRenderFrameHost( | 974 new_render_frame_host = CreateRenderFrameHost( |
963 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden); | 975 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden); |
964 RenderViewHostImpl* render_view_host = | 976 RenderViewHostImpl* render_view_host = |
965 new_render_frame_host->render_view_host(); | 977 new_render_frame_host->render_view_host(); |
966 int proxy_routing_id = MSG_ROUTING_NONE; | 978 int proxy_routing_id = MSG_ROUTING_NONE; |
967 | 979 |
968 // Prevent the process from exiting while we're trying to navigate in it. | 980 // Prevent the process from exiting while we're trying to navigate in it. |
969 // Otherwise, if the new RFH is swapped out already, store it. | 981 // Otherwise, if the new RFH is swapped out already, store it. |
970 if (!swapped_out) { | 982 if (!swapped_out) { |
971 new_render_frame_host->GetProcess()->AddPendingView(); | 983 new_render_frame_host->GetProcess()->AddPendingView(); |
972 } else { | 984 } else { |
973 proxy = new RenderFrameProxyHost( | 985 proxy = new RenderFrameProxyHost( |
974 new_render_frame_host->GetSiteInstance(), frame_tree_node_); | 986 new_render_frame_host->GetSiteInstance(), frame_tree_node_); |
975 proxy_hosts_[instance->GetId()] = proxy; | 987 proxy_hosts_[instance->GetId()] = proxy; |
976 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); | 988 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); |
977 proxy_routing_id = proxy->GetRoutingID(); | 989 proxy_routing_id = proxy->GetRoutingID(); |
978 } | 990 } |
979 | 991 |
980 bool success = InitRenderView( | 992 bool success = InitRenderView( |
981 render_view_host, opener_route_id, proxy_routing_id, | 993 render_view_host, opener_route_id, proxy_routing_id, for_main_frame); |
982 frame_tree_node_->IsMainFrame()); | 994 if (success) { |
983 if (success && frame_tree_node_->IsMainFrame()) { | 995 if (frame_tree_node_->IsMainFrame()) { |
984 // Don't show the main frame's view until we get a DidNavigate from it. | 996 // Don't show the main frame's view until we get a DidNavigate from it. |
985 render_view_host->GetView()->Hide(); | 997 render_view_host->GetView()->Hide(); |
| 998 } else if (!swapped_out) { |
| 999 // Init the RFH, so a RenderFrame is created in the renderer. |
| 1000 DCHECK(new_render_frame_host.get()); |
| 1001 success = InitRenderFrame(new_render_frame_host.get()); |
| 1002 } |
| 1003 if (swapped_out) { |
| 1004 proxy_hosts_[instance->GetId()]->InitRenderFrameProxy(); |
| 1005 } |
986 } else if (!swapped_out && pending_render_frame_host_) { | 1006 } else if (!swapped_out && pending_render_frame_host_) { |
987 CancelPending(); | 1007 CancelPending(); |
988 } | 1008 } |
989 routing_id = render_view_host->GetRoutingID(); | 1009 routing_id = render_view_host->GetRoutingID(); |
990 frame_to_announce = new_render_frame_host.get(); | 1010 frame_to_announce = new_render_frame_host.get(); |
991 } | 1011 } |
992 | 1012 |
993 // Use this as our new pending RFH if it isn't swapped out. | 1013 // Use this as our new pending RFH if it isn't swapped out. |
994 if (!swapped_out) | 1014 if (!swapped_out) |
995 pending_render_frame_host_ = new_render_frame_host.Pass(); | 1015 pending_render_frame_host_ = new_render_frame_host.Pass(); |
996 | 1016 |
997 // If a brand new RFH was created, announce it to observers. | 1017 // If a brand new RFH was created, announce it to observers. |
998 if (frame_to_announce) | 1018 if (frame_to_announce) |
999 render_frame_delegate_->RenderFrameCreated(frame_to_announce); | 1019 render_frame_delegate_->RenderFrameCreated(frame_to_announce); |
1000 | 1020 |
| 1021 LOG(ERROR) << "RFHM::CreateRenderFrame[" << this << "]:" |
| 1022 << "complete: " << routing_id; |
| 1023 |
1001 return routing_id; | 1024 return routing_id; |
1002 } | 1025 } |
1003 | 1026 |
| 1027 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance, |
| 1028 int opener_route_id) { |
| 1029 LOG(ERROR) << "RFHM::CreateRenderFrameProxy[" << this << "]:" |
| 1030 << " " << instance->GetSiteURL(); |
| 1031 |
| 1032 // A RenderFrameProxyHost should never be created in the same SiteInstance as |
| 1033 // the current RFH. |
| 1034 CHECK(instance); |
| 1035 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); |
| 1036 |
| 1037 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
| 1038 if (proxy) { |
| 1039 LOG(ERROR) << "RFHM::CreateRenderFrameProxy[" << this << "]:" |
| 1040 << " found existing proxy"; |
| 1041 return proxy->GetRoutingID(); |
| 1042 } |
| 1043 |
| 1044 LOG(ERROR) << "RFHM::CreateRenderFrameProxy[" << this << "]:" |
| 1045 << " creating new proxy"; |
| 1046 proxy = new RenderFrameProxyHost(instance, frame_tree_node_); |
| 1047 proxy_hosts_[instance->GetId()] = proxy; |
| 1048 proxy->InitRenderFrameProxy(); |
| 1049 return proxy->GetRoutingID(); |
| 1050 } |
| 1051 |
1004 bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, | 1052 bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, |
1005 int opener_route_id, | 1053 int opener_route_id, |
1006 int proxy_routing_id, | 1054 int proxy_routing_id, |
1007 bool for_main_frame) { | 1055 bool for_main_frame) { |
1008 // We may have initialized this RenderViewHost for another RenderFrameHost. | 1056 // We may have initialized this RenderViewHost for another RenderFrameHost. |
1009 if (render_view_host->IsRenderViewLive()) | 1057 if (render_view_host->IsRenderViewLive()) |
1010 return true; | 1058 return true; |
1011 | 1059 |
1012 // If the pending navigation is to a WebUI and the RenderView is not in a | 1060 // If the pending navigation is to a WebUI and the RenderView is not in a |
1013 // guest process, tell the RenderViewHost about any bindings it will need | 1061 // guest process, tell the RenderViewHost about any bindings it will need |
1014 // enabled. | 1062 // enabled. |
1015 if (pending_web_ui() && !render_view_host->GetProcess()->IsIsolatedGuest()) { | 1063 if (pending_web_ui() && !render_view_host->GetProcess()->IsIsolatedGuest()) { |
1016 render_view_host->AllowBindings(pending_web_ui()->GetBindings()); | 1064 render_view_host->AllowBindings(pending_web_ui()->GetBindings()); |
1017 } else { | 1065 } else { |
1018 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled | 1066 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled |
1019 // process unless it's swapped out. | 1067 // process unless it's swapped out. |
1020 RenderViewHostImpl* rvh_impl = | 1068 RenderViewHostImpl* rvh_impl = |
1021 static_cast<RenderViewHostImpl*>(render_view_host); | 1069 static_cast<RenderViewHostImpl*>(render_view_host); |
1022 if (!rvh_impl->IsSwappedOut()) { | 1070 if (!rvh_impl->IsSwappedOut()) { |
1023 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 1071 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
1024 render_view_host->GetProcess()->GetID())); | 1072 render_view_host->GetProcess()->GetID())); |
1025 } | 1073 } |
1026 } | 1074 } |
1027 | 1075 |
1028 return delegate_->CreateRenderViewForRenderManager( | 1076 return delegate_->CreateRenderViewForRenderManager( |
1029 render_view_host, opener_route_id, proxy_routing_id, for_main_frame); | 1077 render_view_host, opener_route_id, proxy_routing_id, for_main_frame); |
1030 } | 1078 } |
1031 | 1079 |
| 1080 bool RenderFrameHostManager::InitRenderFrame( |
| 1081 RenderFrameHost* render_frame_host) { |
| 1082 RenderFrameHostImpl* rfh = |
| 1083 static_cast<RenderFrameHostImpl*>(render_frame_host); |
| 1084 if (rfh->IsRenderFrameLive()) |
| 1085 return true; |
| 1086 |
| 1087 int parent_routing_id = MSG_ROUTING_NONE; |
| 1088 if (frame_tree_node_->parent()) { |
| 1089 parent_routing_id = frame_tree_node_->parent()->render_manager()-> |
| 1090 GetRoutingIdForSiteInstance(render_frame_host->GetSiteInstance()); |
| 1091 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); |
| 1092 } |
| 1093 return delegate_->CreateRenderFrameForRenderManager( |
| 1094 render_frame_host, parent_routing_id); |
| 1095 } |
| 1096 |
| 1097 int RenderFrameHostManager::GetRoutingIdForSiteInstance( |
| 1098 SiteInstance* site_instance) { |
| 1099 if (render_frame_host_->GetSiteInstance() == site_instance) |
| 1100 return render_frame_host_->GetRoutingID(); |
| 1101 |
| 1102 RenderFrameProxyHostMap::iterator iter = |
| 1103 proxy_hosts_.find(site_instance->GetId()); |
| 1104 if (iter != proxy_hosts_.end()) |
| 1105 return iter->second->GetRoutingID(); |
| 1106 |
| 1107 return MSG_ROUTING_NONE; |
| 1108 } |
| 1109 |
1032 void RenderFrameHostManager::CommitPending() { | 1110 void RenderFrameHostManager::CommitPending() { |
| 1111 LOG(ERROR) << "RFHM[" << this << "]::CommitPending:"; |
1033 // First check whether we're going to want to focus the location bar after | 1112 // First check whether we're going to want to focus the location bar after |
1034 // this commit. We do this now because the navigation hasn't formally | 1113 // this commit. We do this now because the navigation hasn't formally |
1035 // committed yet, so if we've already cleared |pending_web_ui_| the call chain | 1114 // committed yet, so if we've already cleared |pending_web_ui_| the call chain |
1036 // this triggers won't be able to figure out what's going on. | 1115 // this triggers won't be able to figure out what's going on. |
1037 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1116 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
1038 | 1117 |
1039 // We expect SwapOutOldPage to have canceled any modal dialogs and told the | 1118 // We expect SwapOutOldPage to have canceled any modal dialogs and told the |
1040 // renderer to suppress any further dialogs until it is swapped out. However, | 1119 // renderer to suppress any further dialogs until it is swapped out. However, |
1041 // crash reports indicate that it's still possible for modal dialogs to exist | 1120 // crash reports indicate that it's still possible for modal dialogs to exist |
1042 // at this point, which poses a risk if we delete their RenderViewHost below. | 1121 // at this point, which poses a risk if we delete their RenderViewHost below. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 // TODO(creis): Swap out the subframe in --site-per-process. | 1223 // TODO(creis): Swap out the subframe in --site-per-process. |
1145 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) | 1224 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) |
1146 DCHECK(old_render_frame_host->is_swapped_out() || | 1225 DCHECK(old_render_frame_host->is_swapped_out() || |
1147 !RenderViewHostImpl::IsRVHStateActive( | 1226 !RenderViewHostImpl::IsRVHStateActive( |
1148 old_render_frame_host->render_view_host()->rvh_state())); | 1227 old_render_frame_host->render_view_host()->rvh_state())); |
1149 | 1228 |
1150 // If the RenderViewHost backing the RenderFrameHost is pending shutdown, | 1229 // If the RenderViewHost backing the RenderFrameHost is pending shutdown, |
1151 // the RenderFrameHost should be put in the map of RenderFrameHosts pending | 1230 // the RenderFrameHost should be put in the map of RenderFrameHosts pending |
1152 // shutdown. Otherwise, it is stored in the map of proxy hosts. | 1231 // shutdown. Otherwise, it is stored in the map of proxy hosts. |
1153 if (old_render_frame_host->render_view_host()->rvh_state() == | 1232 if (old_render_frame_host->render_view_host()->rvh_state() == |
1154 RenderViewHostImpl::STATE_PENDING_SHUTDOWN) { | 1233 RenderViewHostImpl::STATE_PENDING_SHUTDOWN) { |
1155 // The proxy for this RenderFrameHost is created when sending the | 1234 // The proxy for this RenderFrameHost is created when sending the |
1156 // SwapOut message, so check if it already exists and delete it. | 1235 // SwapOut message, so check if it already exists and delete it. |
1157 RenderFrameProxyHostMap::iterator iter = | 1236 RenderFrameProxyHostMap::iterator iter = |
1158 proxy_hosts_.find(old_site_instance_id); | 1237 proxy_hosts_.find(old_site_instance_id); |
1159 if (iter != proxy_hosts_.end()) { | 1238 if (iter != proxy_hosts_.end()) { |
1160 delete iter->second; | 1239 delete iter->second; |
1161 proxy_hosts_.erase(iter); | 1240 proxy_hosts_.erase(iter); |
1162 } | 1241 } |
1163 RFHPendingDeleteMap::iterator pending_delete_iter = | 1242 RFHPendingDeleteMap::iterator pending_delete_iter = |
1164 pending_delete_hosts_.find(old_site_instance_id); | 1243 pending_delete_hosts_.find(old_site_instance_id); |
1165 if (pending_delete_iter == pending_delete_hosts_.end() || | 1244 if (pending_delete_iter == pending_delete_hosts_.end() || |
1166 pending_delete_iter->second.get() != old_render_frame_host) { | 1245 pending_delete_iter->second.get() != old_render_frame_host) { |
1167 pending_delete_hosts_[old_site_instance_id] = | 1246 pending_delete_hosts_[old_site_instance_id] = |
1168 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release()); | 1247 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release()); |
1169 } | 1248 } |
1170 } else { | 1249 } else { |
| 1250 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == |
| 1251 proxy_hosts_.end()); |
| 1252 |
1171 // Capture the active view count on the old RFH SiteInstance, since the | 1253 // Capture the active view count on the old RFH SiteInstance, since the |
1172 // ownership will be passed into the proxy and the pointer will be invalid. | 1254 // ownership might be passed into the proxy and the pointer will be |
| 1255 // invalid. |
1173 int active_view_count = | 1256 int active_view_count = |
1174 static_cast<SiteInstanceImpl*>(old_render_frame_host->GetSiteInstance()) | 1257 static_cast<SiteInstanceImpl*>(old_render_frame_host->GetSiteInstance()) |
1175 ->active_view_count(); | 1258 ->active_view_count(); |
1176 | 1259 |
1177 RenderFrameProxyHostMap::iterator iter = | 1260 if (is_main_frame) { |
1178 proxy_hosts_.find(old_site_instance_id); | 1261 RenderFrameProxyHostMap::iterator iter = |
1179 CHECK(iter != proxy_hosts_.end()); | 1262 proxy_hosts_.find(old_site_instance_id); |
1180 iter->second->TakeFrameHostOwnership(old_render_frame_host.Pass()); | 1263 CHECK(iter != proxy_hosts_.end()); |
| 1264 iter->second->TakeFrameHostOwnership(old_render_frame_host.Pass()); |
| 1265 } |
1181 | 1266 |
1182 // If there are no active views in this SiteInstance, it means that | 1267 // If there are no active views in this SiteInstance, it means that |
1183 // this RFH was the last active one in the SiteInstance. Now that we | 1268 // this RFH was the last active one in the SiteInstance. Now that we |
1184 // know that all RFHs are swapped out, we can delete all the RFHs and RVHs | 1269 // know that all RFHs are swapped out, we can delete all the RFHs and RVHs |
1185 // in this SiteInstance. | 1270 // in this SiteInstance. |
1186 if (!active_view_count) { | 1271 if (!active_view_count) { |
1187 ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id); | 1272 ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id); |
1188 } else { | 1273 } else { |
1189 // If this is a subframe, it should have a CrossProcessFrameConnector | 1274 // If this is a subframe, it should have a CrossProcessFrameConnector |
1190 // created already and we just need to link it to the proper view in the | 1275 // created already and we just need to link it to the proper view in the |
1191 // new process. | 1276 // new process. |
1192 if (!is_main_frame) { | 1277 if (!is_main_frame) { |
1193 RenderFrameProxyHost* proxy = GetProxyToParent(); | 1278 RenderFrameProxyHost* proxy = GetProxyToParent(); |
1194 if (proxy) { | 1279 if (proxy) { |
| 1280 LOG(ERROR) << "RFHM[" << this << "]::CommitPending:" |
| 1281 << " setting child view for proxy:" << proxy |
| 1282 << " view:" << render_frame_host_->render_view_host()->GetV
iew(); |
1195 proxy->SetChildRWHView( | 1283 proxy->SetChildRWHView( |
1196 render_frame_host_->render_view_host()->GetView()); | 1284 render_frame_host_->render_view_host()->GetView()); |
1197 } | 1285 } |
1198 } | 1286 } |
1199 } | 1287 } |
1200 } | 1288 } |
1201 } | 1289 } |
1202 | 1290 |
1203 void RenderFrameHostManager::ShutdownRenderFrameHostsInSiteInstance( | 1291 void RenderFrameHostManager::ShutdownRenderFrameHostsInSiteInstance( |
1204 int32 site_instance_id) { | 1292 int32 site_instance_id) { |
(...skipping 26 matching lines...) Expand all Loading... |
1231 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( | 1319 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( |
1232 const NavigationEntryImpl& entry) { | 1320 const NavigationEntryImpl& entry) { |
1233 // If we are currently navigating cross-process, we want to get back to normal | 1321 // If we are currently navigating cross-process, we want to get back to normal |
1234 // and then navigate as usual. | 1322 // and then navigate as usual. |
1235 if (cross_navigation_pending_) { | 1323 if (cross_navigation_pending_) { |
1236 if (pending_render_frame_host_) | 1324 if (pending_render_frame_host_) |
1237 CancelPending(); | 1325 CancelPending(); |
1238 cross_navigation_pending_ = false; | 1326 cross_navigation_pending_ = false; |
1239 } | 1327 } |
1240 | 1328 |
1241 // render_frame_host_'s SiteInstance and new_instance will not be deleted | 1329 // render_frame_host_'s SiteInstance will not be deleted before the end of |
1242 // before the end of this method, so we don't have to worry about their ref | 1330 // this method, so we don't have to worry about the ref count dropping to |
1243 // counts dropping to zero. | 1331 // zero. The new_instance is possibly passed to CreateProxiesForSiteInstance, |
| 1332 // which expects properly ref-counted object, so use a scoped_refptr for it. |
1244 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 1333 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
1245 SiteInstance* new_instance = current_instance; | 1334 scoped_refptr<SiteInstance> new_instance(current_instance); |
1246 | 1335 |
1247 // We do not currently swap processes for navigations in webview tag guests. | 1336 // We do not currently swap processes for navigations in webview tag guests. |
1248 bool is_guest_scheme = current_instance->GetSiteURL().SchemeIs(kGuestScheme); | 1337 bool is_guest_scheme = current_instance->GetSiteURL().SchemeIs(kGuestScheme); |
1249 | 1338 |
1250 // Determine if we need a new BrowsingInstance for this entry. If true, this | 1339 // Determine if we need a new BrowsingInstance for this entry. If true, this |
1251 // implies that it will get a new SiteInstance (and likely process), and that | 1340 // implies that it will get a new SiteInstance (and likely process), and that |
1252 // other tabs in the current BrowsingInstance will be unable to script it. | 1341 // other tabs in the current BrowsingInstance will be unable to script it. |
1253 // This is used for cases that require a process swap even in the | 1342 // This is used for cases that require a process swap even in the |
1254 // process-per-tab model, such as WebUI pages. | 1343 // process-per-tab model, such as WebUI pages. |
1255 const NavigationEntry* current_entry = | 1344 const NavigationEntry* current_entry = |
(...skipping 21 matching lines...) Expand all Loading... |
1277 // not have its bindings set appropriately. | 1366 // not have its bindings set appropriately. |
1278 SetPendingWebUI(entry); | 1367 SetPendingWebUI(entry); |
1279 | 1368 |
1280 // Ensure that we have created RFHs for the new RFH's opener chain if | 1369 // Ensure that we have created RFHs for the new RFH's opener chain if |
1281 // we are staying in the same BrowsingInstance. This allows the pending RFH | 1370 // we are staying in the same BrowsingInstance. This allows the pending RFH |
1282 // to send cross-process script calls to its opener(s). | 1371 // to send cross-process script calls to its opener(s). |
1283 int opener_route_id = MSG_ROUTING_NONE; | 1372 int opener_route_id = MSG_ROUTING_NONE; |
1284 if (new_instance->IsRelatedSiteInstance(current_instance)) { | 1373 if (new_instance->IsRelatedSiteInstance(current_instance)) { |
1285 opener_route_id = | 1374 opener_route_id = |
1286 delegate_->CreateOpenerRenderViewsForRenderManager(new_instance); | 1375 delegate_->CreateOpenerRenderViewsForRenderManager(new_instance); |
| 1376 |
| 1377 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1378 switches::kSitePerProcess)) { |
| 1379 // Create the swapped out RVH for the new SiteInstance. This will create |
| 1380 // a top-level swapped out RFH as well, which will be wrapped by a |
| 1381 // RenderFrameProxyHost in the subsequent call to create proxies. |
| 1382 if (!frame_tree_node_->IsMainFrame()) { |
| 1383 RenderViewHostImpl* render_view_host = |
| 1384 frame_tree_node_->frame_tree()->GetRenderViewHost( |
| 1385 new_instance); |
| 1386 LOG(ERROR) << "RFHM::UpdateRendererStateForNavigate[" << this << "]:" |
| 1387 << " rvh: " << render_view_host; |
| 1388 if (!render_view_host) { |
| 1389 frame_tree_node_->frame_tree()->root()->render_manager() |
| 1390 ->CreateRenderFrame(new_instance, MSG_ROUTING_NONE, true, false,
true); |
| 1391 } |
| 1392 } |
| 1393 |
| 1394 // Ensure that the frame tree has RenderFrameProxyHosts for the new |
| 1395 // SiteInstance in all nodes except the current one. |
| 1396 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( |
| 1397 frame_tree_node_, new_instance); |
| 1398 } |
1287 } | 1399 } |
1288 | 1400 |
1289 // Create a non-swapped-out pending RFH with the given opener and navigate | 1401 // Create a non-swapped-out pending RFH with the given opener and navigate |
1290 // it. | 1402 // it. |
1291 int route_id = CreateRenderFrame(new_instance, opener_route_id, false, | 1403 int route_id = CreateRenderFrame(new_instance, opener_route_id, false, |
| 1404 frame_tree_node_->IsMainFrame(), |
1292 delegate_->IsHidden()); | 1405 delegate_->IsHidden()); |
1293 if (route_id == MSG_ROUTING_NONE) | 1406 if (route_id == MSG_ROUTING_NONE) |
1294 return NULL; | 1407 return NULL; |
1295 | 1408 |
1296 // Check if our current RFH is live before we set up a transition. | 1409 // Check if our current RFH is live before we set up a transition. |
1297 if (!render_frame_host_->render_view_host()->IsRenderViewLive()) { | 1410 if (!render_frame_host_->render_view_host()->IsRenderViewLive()) { |
| 1411 LOG(ERROR) << "RFHM::UpdateRendererStateForNavigate[" << this << "]:" |
| 1412 << " rvh isn't live"; |
1298 if (!cross_navigation_pending_) { | 1413 if (!cross_navigation_pending_) { |
| 1414 LOG(ERROR) << "RFHM::UpdateRendererStateForNavigate[" << this << "]:" |
| 1415 << " !cross_nav_pending_, will CommitPending"; |
1299 // The current RFH is not live. There's no reason to sit around with a | 1416 // The current RFH is not live. There's no reason to sit around with a |
1300 // sad tab or a newly created RFH while we wait for the pending RFH to | 1417 // sad tab or a newly created RFH while we wait for the pending RFH to |
1301 // navigate. Just switch to the pending RFH now and go back to non | 1418 // navigate. Just switch to the pending RFH now and go back to non |
1302 // cross-navigating (Note that we don't care about on{before}unload | 1419 // cross-navigating (Note that we don't care about on{before}unload |
1303 // handlers if the current RFH isn't live.) | 1420 // handlers if the current RFH isn't live.) |
1304 CommitPending(); | 1421 CommitPending(); |
1305 return render_frame_host_.get(); | 1422 return render_frame_host_.get(); |
1306 } else { | 1423 } else { |
1307 NOTREACHED(); | 1424 NOTREACHED(); |
1308 return render_frame_host_.get(); | 1425 return render_frame_host_.get(); |
1309 } | 1426 } |
1310 } | 1427 } |
1311 // Otherwise, it's safe to treat this as a pending cross-site transition. | 1428 // Otherwise, it's safe to treat this as a pending cross-site transition. |
1312 | 1429 |
1313 // We need to wait until the beforeunload handler has run, unless we are | 1430 // We need to wait until the beforeunload handler has run, unless we are |
1314 // transferring an existing request (in which case it has already run). | 1431 // transferring an existing request (in which case it has already run). |
1315 // Suspend the new render view (i.e., don't let it send the cross-site | 1432 // Suspend the new render view (i.e., don't let it send the cross-site |
1316 // Navigate message) until we hear back from the old renderer's | 1433 // Navigate message) until we hear back from the old renderer's |
1317 // beforeunload handler. If the handler returns false, we'll have to | 1434 // beforeunload handler. If the handler returns false, we'll have to |
1318 // cancel the request. | 1435 // cancel the request. |
1319 DCHECK(!pending_render_frame_host_->render_view_host()-> | 1436 DCHECK(!pending_render_frame_host_->render_view_host()-> |
1320 are_navigations_suspended()); | 1437 are_navigations_suspended()); |
1321 bool is_transfer = | 1438 bool is_transfer = |
1322 entry.transferred_global_request_id() != GlobalRequestID(); | 1439 entry.transferred_global_request_id() != GlobalRequestID(); |
1323 if (is_transfer) { | 1440 if (is_transfer) { |
| 1441 LOG(ERROR) << "RFHM::UpdateStateForNavigate[" << this << "]:" |
| 1442 << " is_transfer: " << pending_nav_params_->global_request_id.child_
id; |
1324 // We don't need to stop the old renderer or run beforeunload/unload | 1443 // We don't need to stop the old renderer or run beforeunload/unload |
1325 // handlers, because those have already been done. | 1444 // handlers, because those have already been done. |
1326 DCHECK(pending_nav_params_->global_request_id == | 1445 DCHECK(pending_nav_params_->global_request_id == |
1327 entry.transferred_global_request_id()); | 1446 entry.transferred_global_request_id()); |
1328 } else { | 1447 } else { |
| 1448 LOG(ERROR) << "RFHM::UpdateStateForNavigate[" << this << "]:" |
| 1449 << " !is_transfer: "; |
1329 // Also make sure the old render view stops, in case a load is in | 1450 // Also make sure the old render view stops, in case a load is in |
1330 // progress. (We don't want to do this for transfers, since it will | 1451 // progress. (We don't want to do this for transfers, since it will |
1331 // interrupt the transfer with an unexpected DidStopLoading.) | 1452 // interrupt the transfer with an unexpected DidStopLoading.) |
1332 render_frame_host_->render_view_host()->Send(new ViewMsg_Stop( | 1453 render_frame_host_->render_view_host()->Send(new ViewMsg_Stop( |
1333 render_frame_host_->render_view_host()->GetRoutingID())); | 1454 render_frame_host_->render_view_host()->GetRoutingID())); |
1334 | 1455 |
1335 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( | 1456 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( |
1336 true, base::TimeTicks()); | 1457 true, base::TimeTicks()); |
1337 | 1458 |
1338 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site | 1459 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site |
1339 // request, so that ResourceDispatcherHost will know to tell us to run the | 1460 // request, so that ResourceDispatcherHost will know to tell us to run the |
1340 // old page's unload handler before it sends the response. | 1461 // old page's unload handler before it sends the response. |
1341 // TODO(creis): This needs to be on the RFH. | 1462 // TODO(creis): This needs to be on the RFH. |
1342 pending_render_frame_host_->render_view_host()-> | 1463 pending_render_frame_host_->render_view_host()-> |
1343 SetHasPendingCrossSiteRequest(true); | 1464 SetHasPendingCrossSiteRequest(true); |
1344 } | 1465 } |
1345 | 1466 |
1346 // We now have a pending RFH. | 1467 // We now have a pending RFH. |
1347 DCHECK(!cross_navigation_pending_); | 1468 DCHECK(!cross_navigation_pending_); |
1348 cross_navigation_pending_ = true; | 1469 cross_navigation_pending_ = true; |
1349 | 1470 |
1350 // Unless we are transferring an existing request, we should now | 1471 // Unless we are transferring an existing request, we should now |
1351 // tell the old render view to run its beforeunload handler, since it | 1472 // tell the old render view to run its beforeunload handler, since it |
1352 // doesn't otherwise know that the cross-site request is happening. This | 1473 // doesn't otherwise know that the cross-site request is happening. This |
1353 // will trigger a call to OnBeforeUnloadACK with the reply. | 1474 // will trigger a call to OnBeforeUnloadACK with the reply. |
1354 if (!is_transfer) | 1475 if (!is_transfer) |
1355 render_frame_host_->DispatchBeforeUnload(true); | 1476 render_frame_host_->DispatchBeforeUnload(true); |
1356 | 1477 |
| 1478 LOG(ERROR) << "RFHM::UpdateRendererStateForNavigate[" << this << "]:" |
| 1479 << " returning " << pending_render_frame_host_.get(); |
1357 return pending_render_frame_host_.get(); | 1480 return pending_render_frame_host_.get(); |
1358 } | 1481 } |
1359 | 1482 |
1360 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. | 1483 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. |
1361 DCHECK(!cross_navigation_pending_); | 1484 DCHECK(!cross_navigation_pending_); |
1362 if (ShouldReuseWebUI(current_entry, &entry)) { | 1485 if (ShouldReuseWebUI(current_entry, &entry)) { |
1363 pending_web_ui_.reset(); | 1486 pending_web_ui_.reset(); |
1364 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); | 1487 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); |
1365 } else { | 1488 } else { |
1366 SetPendingWebUI(entry); | 1489 SetPendingWebUI(entry); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 SiteInstanceImpl* site_instance = static_cast<SiteInstanceImpl*>( | 1529 SiteInstanceImpl* site_instance = static_cast<SiteInstanceImpl*>( |
1407 pending_render_frame_host->GetSiteInstance()); | 1530 pending_render_frame_host->GetSiteInstance()); |
1408 if (site_instance->active_view_count() > 1) { | 1531 if (site_instance->active_view_count() > 1) { |
1409 // Any currently suspended navigations are no longer needed. | 1532 // Any currently suspended navigations are no longer needed. |
1410 pending_render_frame_host->render_view_host()->CancelSuspendedNavigations(); | 1533 pending_render_frame_host->render_view_host()->CancelSuspendedNavigations(); |
1411 | 1534 |
1412 RenderFrameProxyHost* proxy = | 1535 RenderFrameProxyHost* proxy = |
1413 new RenderFrameProxyHost(site_instance, frame_tree_node_); | 1536 new RenderFrameProxyHost(site_instance, frame_tree_node_); |
1414 proxy_hosts_[site_instance->GetId()] = proxy; | 1537 proxy_hosts_[site_instance->GetId()] = proxy; |
1415 pending_render_frame_host->SwapOut(proxy); | 1538 pending_render_frame_host->SwapOut(proxy); |
1416 proxy->TakeFrameHostOwnership(pending_render_frame_host.Pass()); | 1539 if (frame_tree_node_->IsMainFrame()) { |
| 1540 proxy->TakeFrameHostOwnership(pending_render_frame_host.Pass()); |
| 1541 } |
| 1542 proxy_hosts_[site_instance->GetId()] = proxy; |
1417 } else { | 1543 } else { |
1418 // We won't be coming back, so delete this one. | 1544 // We won't be coming back, so delete this one. |
1419 pending_render_frame_host.reset(); | 1545 pending_render_frame_host.reset(); |
1420 } | 1546 } |
1421 | 1547 |
1422 pending_web_ui_.reset(); | 1548 pending_web_ui_.reset(); |
1423 pending_and_current_web_ui_.reset(); | 1549 pending_and_current_web_ui_.reset(); |
1424 } | 1550 } |
1425 | 1551 |
1426 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::SetRenderFrameHost( | 1552 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::SetRenderFrameHost( |
(...skipping 20 matching lines...) Expand all Loading... |
1447 | 1573 |
1448 return old_render_frame_host.Pass(); | 1574 return old_render_frame_host.Pass(); |
1449 } | 1575 } |
1450 | 1576 |
1451 bool RenderFrameHostManager::IsRVHOnSwappedOutList( | 1577 bool RenderFrameHostManager::IsRVHOnSwappedOutList( |
1452 RenderViewHostImpl* rvh) const { | 1578 RenderViewHostImpl* rvh) const { |
1453 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost( | 1579 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost( |
1454 rvh->GetSiteInstance()); | 1580 rvh->GetSiteInstance()); |
1455 if (!proxy) | 1581 if (!proxy) |
1456 return false; | 1582 return false; |
| 1583 // If there is a proxy without RFH, it is for a subframe in the SiteInstance |
| 1584 // of |rvh|. Subframes should be ignored in this case. |
| 1585 if (!proxy->render_frame_host()) |
| 1586 return false; |
1457 return IsOnSwappedOutList(proxy->render_frame_host()); | 1587 return IsOnSwappedOutList(proxy->render_frame_host()); |
1458 } | 1588 } |
1459 | 1589 |
1460 bool RenderFrameHostManager::IsOnSwappedOutList( | 1590 bool RenderFrameHostManager::IsOnSwappedOutList( |
1461 RenderFrameHostImpl* rfh) const { | 1591 RenderFrameHostImpl* rfh) const { |
1462 if (!rfh->GetSiteInstance()) | 1592 if (!rfh->GetSiteInstance()) |
1463 return false; | 1593 return false; |
1464 | 1594 |
1465 RenderFrameProxyHostMap::const_iterator iter = proxy_hosts_.find( | 1595 RenderFrameProxyHostMap::const_iterator iter = proxy_hosts_.find( |
1466 rfh->GetSiteInstance()->GetId()); | 1596 rfh->GetSiteInstance()->GetId()); |
(...skipping 15 matching lines...) Expand all Loading... |
1482 SiteInstance* instance) const { | 1612 SiteInstance* instance) const { |
1483 RenderFrameProxyHostMap::const_iterator iter = | 1613 RenderFrameProxyHostMap::const_iterator iter = |
1484 proxy_hosts_.find(instance->GetId()); | 1614 proxy_hosts_.find(instance->GetId()); |
1485 if (iter != proxy_hosts_.end()) | 1615 if (iter != proxy_hosts_.end()) |
1486 return iter->second; | 1616 return iter->second; |
1487 | 1617 |
1488 return NULL; | 1618 return NULL; |
1489 } | 1619 } |
1490 | 1620 |
1491 } // namespace content | 1621 } // namespace content |
OLD | NEW |