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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // It is important to delete those prior to deleting the current | 77 // It is important to delete those prior to deleting the current |
78 // RenderFrameHost, since the CrossProcessFrameConnector (owned by | 78 // RenderFrameHost, since the CrossProcessFrameConnector (owned by |
79 // RenderFrameProxyHost) points to the RenderWidgetHostView associated with | 79 // RenderFrameProxyHost) points to the RenderWidgetHostView associated with |
80 // the current RenderFrameHost and uses it during its destructor. | 80 // the current RenderFrameHost and uses it during its destructor. |
81 ResetProxyHosts(); | 81 ResetProxyHosts(); |
82 | 82 |
83 // We should always have a current RenderFrameHost except in some tests. | 83 // We should always have a current RenderFrameHost except in some tests. |
84 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); | 84 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); |
85 } | 85 } |
86 | 86 |
87 void RenderFrameHostManager::Init(SiteInstance* site_instance, | 87 void RenderFrameHostManager::Init(SiteInstanceImpl* site_instance, |
88 int32_t view_routing_id, | 88 int32_t view_routing_id, |
89 int32_t frame_routing_id, | 89 int32_t frame_routing_id, |
90 int32_t widget_routing_id) { | 90 int32_t widget_routing_id) { |
91 DCHECK(site_instance); | 91 DCHECK(site_instance); |
92 // TODO(avi): While RenderViewHostImpl is-a RenderWidgetHostImpl, this must | 92 // TODO(avi): While RenderViewHostImpl is-a RenderWidgetHostImpl, this must |
93 // hold true to avoid having two RenderWidgetHosts for the top-level frame. | 93 // hold true to avoid having two RenderWidgetHosts for the top-level frame. |
94 // https://crbug.com/545684 | 94 // https://crbug.com/545684 |
95 DCHECK(!frame_tree_node_->IsMainFrame() || | 95 DCHECK(!frame_tree_node_->IsMainFrame() || |
96 view_routing_id == widget_routing_id); | 96 view_routing_id == widget_routing_id); |
97 SetRenderFrameHost(CreateRenderFrameHost(site_instance, view_routing_id, | 97 SetRenderFrameHost(CreateRenderFrameHost(site_instance, view_routing_id, |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 } | 557 } |
558 } | 558 } |
559 } else { | 559 } else { |
560 // No one else should be sending us DidNavigate in this state. | 560 // No one else should be sending us DidNavigate in this state. |
561 NOTREACHED(); | 561 NOTREACHED(); |
562 } | 562 } |
563 } | 563 } |
564 | 564 |
565 void RenderFrameHostManager::DidChangeOpener( | 565 void RenderFrameHostManager::DidChangeOpener( |
566 int opener_routing_id, | 566 int opener_routing_id, |
567 SiteInstance* source_site_instance) { | 567 SiteInstanceImpl* source_site_instance) { |
568 FrameTreeNode* opener = nullptr; | 568 FrameTreeNode* opener = nullptr; |
569 if (opener_routing_id != MSG_ROUTING_NONE) { | 569 if (opener_routing_id != MSG_ROUTING_NONE) { |
570 RenderFrameHostImpl* opener_rfhi = RenderFrameHostImpl::FromID( | 570 RenderFrameHostImpl* opener_rfhi = RenderFrameHostImpl::FromID( |
571 source_site_instance->GetProcess()->GetID(), opener_routing_id); | 571 source_site_instance->GetProcess()->GetID(), opener_routing_id); |
572 // If |opener_rfhi| is null, the opener RFH has already disappeared. In | 572 // If |opener_rfhi| is null, the opener RFH has already disappeared. In |
573 // this case, clear the opener rather than keeping the old opener around. | 573 // this case, clear the opener rather than keeping the old opener around. |
574 if (opener_rfhi) | 574 if (opener_rfhi) |
575 opener = opener_rfhi->frame_tree_node(); | 575 opener = opener_rfhi->frame_tree_node(); |
576 } | 576 } |
577 | 577 |
(...skipping 29 matching lines...) Expand all Loading... |
607 void RenderFrameHostManager::CommitPendingSandboxFlags() { | 607 void RenderFrameHostManager::CommitPendingSandboxFlags() { |
608 // Return early if there were no pending sandbox flags updates. | 608 // Return early if there were no pending sandbox flags updates. |
609 if (!frame_tree_node_->CommitPendingSandboxFlags()) | 609 if (!frame_tree_node_->CommitPendingSandboxFlags()) |
610 return; | 610 return; |
611 | 611 |
612 // Sandbox flags updates can only happen when the frame has a parent. | 612 // Sandbox flags updates can only happen when the frame has a parent. |
613 CHECK(frame_tree_node_->parent()); | 613 CHECK(frame_tree_node_->parent()); |
614 | 614 |
615 // Notify all of the frame's proxies about updated sandbox flags, excluding | 615 // Notify all of the frame's proxies about updated sandbox flags, excluding |
616 // the parent process since it already knows the latest flags. | 616 // the parent process since it already knows the latest flags. |
617 SiteInstance* parent_site_instance = | 617 SiteInstanceImpl* parent_site_instance = |
618 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance(); | 618 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance(); |
619 for (const auto& pair : proxy_hosts_) { | 619 for (const auto& pair : proxy_hosts_) { |
620 if (pair.second->GetSiteInstance() != parent_site_instance) { | 620 if (pair.second->GetSiteInstance() != parent_site_instance) { |
621 pair.second->Send(new FrameMsg_DidUpdateSandboxFlags( | 621 pair.second->Send(new FrameMsg_DidUpdateSandboxFlags( |
622 pair.second->GetRoutingID(), | 622 pair.second->GetRoutingID(), |
623 frame_tree_node_->current_replication_state().sandbox_flags)); | 623 frame_tree_node_->current_replication_state().sandbox_flags)); |
624 } | 624 } |
625 } | 625 } |
626 } | 626 } |
627 | 627 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 CHECK(IsBrowserSideNavigationEnabled()); | 776 CHECK(IsBrowserSideNavigationEnabled()); |
777 RenderFrameHostImpl* dest_rfh = GetFrameHostForNavigation(request); | 777 RenderFrameHostImpl* dest_rfh = GetFrameHostForNavigation(request); |
778 DCHECK(dest_rfh); | 778 DCHECK(dest_rfh); |
779 } | 779 } |
780 | 780 |
781 // PlzNavigate | 781 // PlzNavigate |
782 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( | 782 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( |
783 const NavigationRequest& request) { | 783 const NavigationRequest& request) { |
784 CHECK(IsBrowserSideNavigationEnabled()); | 784 CHECK(IsBrowserSideNavigationEnabled()); |
785 | 785 |
786 SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance(); | 786 SiteInstanceImpl* current_site_instance = |
| 787 render_frame_host_->GetSiteInstance(); |
787 | 788 |
788 SiteInstance* candidate_site_instance = | 789 SiteInstanceImpl* candidate_site_instance = |
789 speculative_render_frame_host_ | 790 speculative_render_frame_host_ |
790 ? speculative_render_frame_host_->GetSiteInstance() | 791 ? speculative_render_frame_host_->GetSiteInstance() |
791 : nullptr; | 792 : nullptr; |
792 | 793 |
793 scoped_refptr<SiteInstance> dest_site_instance = GetSiteInstanceForNavigation( | 794 scoped_refptr<SiteInstanceImpl> dest_site_instance = |
794 request.common_params().url, request.source_site_instance(), | 795 GetSiteInstanceForNavigation( |
795 request.dest_site_instance(), candidate_site_instance, | 796 request.common_params().url, request.source_site_instance(), |
796 request.common_params().transition, | 797 request.dest_site_instance(), candidate_site_instance, |
797 request.restore_type() != NavigationEntryImpl::RESTORE_NONE, | 798 request.common_params().transition, |
798 request.is_view_source()); | 799 request.restore_type() != NavigationEntryImpl::RESTORE_NONE, |
| 800 request.is_view_source()); |
799 | 801 |
800 // The appropriate RenderFrameHost to commit the navigation. | 802 // The appropriate RenderFrameHost to commit the navigation. |
801 RenderFrameHostImpl* navigation_rfh = nullptr; | 803 RenderFrameHostImpl* navigation_rfh = nullptr; |
802 | 804 |
803 bool notify_webui_of_rv_creation = false; | 805 bool notify_webui_of_rv_creation = false; |
804 | 806 |
805 // Reuse the current RenderFrameHost if its SiteInstance matches the | 807 // Reuse the current RenderFrameHost if its SiteInstance matches the |
806 // navigation's. | 808 // navigation's. |
807 bool no_renderer_swap = current_site_instance == dest_site_instance.get(); | 809 bool no_renderer_swap = current_site_instance == dest_site_instance.get(); |
808 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { | 810 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 SiteInstanceImpl* site_instance) { | 1013 SiteInstanceImpl* site_instance) { |
1012 // |site_instance| no longer contains any active RenderFrameHosts, so we don't | 1014 // |site_instance| no longer contains any active RenderFrameHosts, so we don't |
1013 // need to maintain a proxy there anymore. | 1015 // need to maintain a proxy there anymore. |
1014 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); | 1016 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); |
1015 CHECK(proxy); | 1017 CHECK(proxy); |
1016 | 1018 |
1017 DeleteRenderFrameProxyHost(site_instance); | 1019 DeleteRenderFrameProxyHost(site_instance); |
1018 } | 1020 } |
1019 | 1021 |
1020 RenderFrameProxyHost* RenderFrameHostManager::CreateRenderFrameProxyHost( | 1022 RenderFrameProxyHost* RenderFrameHostManager::CreateRenderFrameProxyHost( |
1021 SiteInstance* site_instance, | 1023 SiteInstanceImpl* site_instance, |
1022 RenderViewHostImpl* rvh) { | 1024 RenderViewHostImpl* rvh) { |
1023 int site_instance_id = site_instance->GetId(); | 1025 int site_instance_id = site_instance->GetId(); |
1024 CHECK(proxy_hosts_.find(site_instance_id) == proxy_hosts_.end()) | 1026 CHECK(proxy_hosts_.find(site_instance_id) == proxy_hosts_.end()) |
1025 << "A proxy already existed for this SiteInstance."; | 1027 << "A proxy already existed for this SiteInstance."; |
1026 RenderFrameProxyHost* proxy_host = | 1028 RenderFrameProxyHost* proxy_host = |
1027 new RenderFrameProxyHost(site_instance, rvh, frame_tree_node_); | 1029 new RenderFrameProxyHost(site_instance, rvh, frame_tree_node_); |
1028 proxy_hosts_[site_instance_id] = make_scoped_ptr(proxy_host); | 1030 proxy_hosts_[site_instance_id] = make_scoped_ptr(proxy_host); |
1029 static_cast<SiteInstanceImpl*>(site_instance)->AddObserver(this); | 1031 static_cast<SiteInstanceImpl*>(site_instance)->AddObserver(this); |
1030 return proxy_host; | 1032 return proxy_host; |
1031 } | 1033 } |
1032 | 1034 |
1033 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1035 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1034 SiteInstance* site_instance) { | 1036 SiteInstanceImpl* site_instance) { |
1035 static_cast<SiteInstanceImpl*>(site_instance)->RemoveObserver(this); | 1037 static_cast<SiteInstanceImpl*>(site_instance)->RemoveObserver(this); |
1036 proxy_hosts_.erase(site_instance->GetId()); | 1038 proxy_hosts_.erase(site_instance->GetId()); |
1037 } | 1039 } |
1038 | 1040 |
1039 bool RenderFrameHostManager::ShouldTransitionCrossSite() { | 1041 bool RenderFrameHostManager::ShouldTransitionCrossSite() { |
1040 // The logic below is weaker than "are all sites isolated" -- it asks instead, | 1042 // The logic below is weaker than "are all sites isolated" -- it asks instead, |
1041 // "is any site isolated". That's appropriate here since we're just trying to | 1043 // "is any site isolated". That's appropriate here since we're just trying to |
1042 // figure out if we're in any kind of site isolated mode, and in which case, | 1044 // figure out if we're in any kind of site isolated mode, and in which case, |
1043 // we ignore the kSingleProcess and kProcessPerTab settings. | 1045 // we ignore the kSingleProcess and kProcessPerTab settings. |
1044 // | 1046 // |
(...skipping 11 matching lines...) Expand all Loading... |
1056 // SiteIsolationPolicy. | 1058 // SiteIsolationPolicy. |
1057 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1059 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1058 switches::kSingleProcess) && | 1060 switches::kSingleProcess) && |
1059 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1061 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1060 switches::kProcessPerTab); | 1062 switches::kProcessPerTab); |
1061 } | 1063 } |
1062 | 1064 |
1063 bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( | 1065 bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( |
1064 const GURL& current_effective_url, | 1066 const GURL& current_effective_url, |
1065 bool current_is_view_source_mode, | 1067 bool current_is_view_source_mode, |
1066 SiteInstance* new_site_instance, | 1068 SiteInstanceImpl* new_site_instance, |
1067 const GURL& new_effective_url, | 1069 const GURL& new_effective_url, |
1068 bool new_is_view_source_mode) const { | 1070 bool new_is_view_source_mode) const { |
1069 // A subframe must stay in the same BrowsingInstance as its parent. | 1071 // A subframe must stay in the same BrowsingInstance as its parent. |
1070 // TODO(nasko): Ensure that SiteInstance swap is still triggered for subframes | 1072 // TODO(nasko): Ensure that SiteInstance swap is still triggered for subframes |
1071 // in the cases covered by the rest of the checks in this method. | 1073 // in the cases covered by the rest of the checks in this method. |
1072 if (!frame_tree_node_->IsMainFrame()) | 1074 if (!frame_tree_node_->IsMainFrame()) |
1073 return false; | 1075 return false; |
1074 | 1076 |
1075 // If new_entry already has a SiteInstance, assume it is correct. We only | 1077 // If new_entry already has a SiteInstance, assume it is correct. We only |
1076 // need to force a swap if it is in a different BrowsingInstance. | 1078 // need to force a swap if it is in a different BrowsingInstance. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 // We can't switch a RenderView between view source and non-view source mode | 1133 // We can't switch a RenderView between view source and non-view source mode |
1132 // without screwing up the session history sometimes (when navigating between | 1134 // without screwing up the session history sometimes (when navigating between |
1133 // "view-source:http://foo.com/" and "http://foo.com/", Blink doesn't treat | 1135 // "view-source:http://foo.com/" and "http://foo.com/", Blink doesn't treat |
1134 // it as a new navigation). So require a BrowsingInstance switch. | 1136 // it as a new navigation). So require a BrowsingInstance switch. |
1135 if (current_is_view_source_mode != new_is_view_source_mode) | 1137 if (current_is_view_source_mode != new_is_view_source_mode) |
1136 return true; | 1138 return true; |
1137 | 1139 |
1138 return false; | 1140 return false; |
1139 } | 1141 } |
1140 | 1142 |
1141 scoped_refptr<SiteInstance> | 1143 scoped_refptr<SiteInstanceImpl> |
1142 RenderFrameHostManager::GetSiteInstanceForNavigation( | 1144 RenderFrameHostManager::GetSiteInstanceForNavigation( |
1143 const GURL& dest_url, | 1145 const GURL& dest_url, |
1144 SiteInstance* source_instance, | 1146 SiteInstanceImpl* source_instance, |
1145 SiteInstance* dest_instance, | 1147 SiteInstanceImpl* dest_instance, |
1146 SiteInstance* candidate_instance, | 1148 SiteInstanceImpl* candidate_instance, |
1147 ui::PageTransition transition, | 1149 ui::PageTransition transition, |
1148 bool dest_is_restore, | 1150 bool dest_is_restore, |
1149 bool dest_is_view_source_mode) { | 1151 bool dest_is_view_source_mode) { |
1150 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 1152 SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance(); |
1151 | 1153 |
1152 // We do not currently swap processes for navigations in webview tag guests. | 1154 // We do not currently swap processes for navigations in webview tag guests. |
1153 if (current_instance->GetSiteURL().SchemeIs(kGuestScheme)) | 1155 if (current_instance->GetSiteURL().SchemeIs(kGuestScheme)) |
1154 return current_instance; | 1156 return current_instance; |
1155 | 1157 |
1156 // Determine if we need a new BrowsingInstance for this entry. If true, this | 1158 // Determine if we need a new BrowsingInstance for this entry. If true, this |
1157 // implies that it will get a new SiteInstance (and likely process), and that | 1159 // implies that it will get a new SiteInstance (and likely process), and that |
1158 // other tabs in the current BrowsingInstance will be unable to script it. | 1160 // other tabs in the current BrowsingInstance will be unable to script it. |
1159 // This is used for cases that require a process swap even in the | 1161 // This is used for cases that require a process swap even in the |
1160 // process-per-tab model, such as WebUI pages. | 1162 // process-per-tab model, such as WebUI pages. |
(...skipping 15 matching lines...) Expand all Loading... |
1176 SiteInstanceImpl::GetEffectiveURL(browser_context, dest_url), | 1178 SiteInstanceImpl::GetEffectiveURL(browser_context, dest_url), |
1177 dest_is_view_source_mode); | 1179 dest_is_view_source_mode); |
1178 SiteInstanceDescriptor new_instance_descriptor = | 1180 SiteInstanceDescriptor new_instance_descriptor = |
1179 SiteInstanceDescriptor(current_instance); | 1181 SiteInstanceDescriptor(current_instance); |
1180 if (ShouldTransitionCrossSite() || force_swap) { | 1182 if (ShouldTransitionCrossSite() || force_swap) { |
1181 new_instance_descriptor = DetermineSiteInstanceForURL( | 1183 new_instance_descriptor = DetermineSiteInstanceForURL( |
1182 dest_url, source_instance, current_instance, dest_instance, transition, | 1184 dest_url, source_instance, current_instance, dest_instance, transition, |
1183 dest_is_restore, dest_is_view_source_mode, force_swap); | 1185 dest_is_restore, dest_is_view_source_mode, force_swap); |
1184 } | 1186 } |
1185 | 1187 |
1186 scoped_refptr<SiteInstance> new_instance = | 1188 scoped_refptr<SiteInstanceImpl> new_instance = |
1187 ConvertToSiteInstance(new_instance_descriptor, candidate_instance); | 1189 ConvertToSiteInstance(new_instance_descriptor, candidate_instance); |
1188 // If |force_swap| is true, we must use a different SiteInstance than the | 1190 // If |force_swap| is true, we must use a different SiteInstance than the |
1189 // current one. If we didn't, we would have two RenderFrameHosts in the same | 1191 // current one. If we didn't, we would have two RenderFrameHosts in the same |
1190 // SiteInstance and the same frame, resulting in page_id conflicts for their | 1192 // SiteInstance and the same frame, resulting in page_id conflicts for their |
1191 // NavigationEntries. | 1193 // NavigationEntries. |
1192 if (force_swap) | 1194 if (force_swap) |
1193 CHECK_NE(new_instance, current_instance); | 1195 CHECK_NE(new_instance, current_instance); |
1194 | 1196 |
1195 return new_instance; | 1197 return new_instance; |
1196 } | 1198 } |
1197 | 1199 |
1198 RenderFrameHostManager::SiteInstanceDescriptor | 1200 RenderFrameHostManager::SiteInstanceDescriptor |
1199 RenderFrameHostManager::DetermineSiteInstanceForURL( | 1201 RenderFrameHostManager::DetermineSiteInstanceForURL( |
1200 const GURL& dest_url, | 1202 const GURL& dest_url, |
1201 SiteInstance* source_instance, | 1203 SiteInstanceImpl* source_instance, |
1202 SiteInstance* current_instance, | 1204 SiteInstanceImpl* current_instance, |
1203 SiteInstance* dest_instance, | 1205 SiteInstanceImpl* dest_instance, |
1204 ui::PageTransition transition, | 1206 ui::PageTransition transition, |
1205 bool dest_is_restore, | 1207 bool dest_is_restore, |
1206 bool dest_is_view_source_mode, | 1208 bool dest_is_view_source_mode, |
1207 bool force_browsing_instance_swap) { | 1209 bool force_browsing_instance_swap) { |
1208 SiteInstanceImpl* current_instance_impl = | 1210 SiteInstanceImpl* current_instance_impl = |
1209 static_cast<SiteInstanceImpl*>(current_instance); | 1211 static_cast<SiteInstanceImpl*>(current_instance); |
1210 NavigationControllerImpl& controller = | 1212 NavigationControllerImpl& controller = |
1211 delegate_->GetControllerForRenderManager(); | 1213 delegate_->GetControllerForRenderManager(); |
1212 BrowserContext* browser_context = controller.GetBrowserContext(); | 1214 BrowserContext* browser_context = controller.GetBrowserContext(); |
1213 | 1215 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 if (SiteIsolationPolicy::IsTopDocumentIsolationEnabled() && | 1436 if (SiteIsolationPolicy::IsTopDocumentIsolationEnabled() && |
1435 (!frame_tree_node_->IsMainFrame() || | 1437 (!frame_tree_node_->IsMainFrame() || |
1436 rfh->GetSiteInstance()->is_default_subframe_site_instance())) { | 1438 rfh->GetSiteInstance()->is_default_subframe_site_instance())) { |
1437 // Always attempt a transfer in these cases. | 1439 // Always attempt a transfer in these cases. |
1438 return true; | 1440 return true; |
1439 } | 1441 } |
1440 | 1442 |
1441 return false; | 1443 return false; |
1442 } | 1444 } |
1443 | 1445 |
1444 scoped_refptr<SiteInstance> RenderFrameHostManager::ConvertToSiteInstance( | 1446 scoped_refptr<SiteInstanceImpl> RenderFrameHostManager::ConvertToSiteInstance( |
1445 const SiteInstanceDescriptor& descriptor, | 1447 const SiteInstanceDescriptor& descriptor, |
1446 SiteInstance* candidate_instance) { | 1448 SiteInstanceImpl* candidate_instance) { |
1447 SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance(); | 1449 SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance(); |
1448 | 1450 |
1449 // Note: If the |candidate_instance| matches the descriptor, it will already | 1451 // Note: If the |candidate_instance| matches the descriptor, it will already |
1450 // be set to |descriptor.existing_site_instance|. | 1452 // be set to |descriptor.existing_site_instance|. |
1451 if (descriptor.existing_site_instance) | 1453 if (descriptor.existing_site_instance) |
1452 return descriptor.existing_site_instance; | 1454 return descriptor.existing_site_instance; |
1453 | 1455 |
1454 // Note: If the |candidate_instance| matches the descriptor, | 1456 // Note: If the |candidate_instance| matches the descriptor, |
1455 // GetRelatedSiteInstance will return it. | 1457 // GetRelatedSiteInstance will return it. |
1456 if (descriptor.relation == SiteInstanceRelation::RELATED) | 1458 if (descriptor.relation == SiteInstanceRelation::RELATED) |
1457 return current_instance->GetRelatedSiteInstance(descriptor.new_site_url); | 1459 return current_instance->GetRelatedSiteInstanceImpl( |
| 1460 descriptor.new_site_url); |
1458 | 1461 |
1459 if (descriptor.relation == SiteInstanceRelation::RELATED_DEFAULT_SUBFRAME) | 1462 if (descriptor.relation == SiteInstanceRelation::RELATED_DEFAULT_SUBFRAME) |
1460 return current_instance->GetDefaultSubframeSiteInstance(); | 1463 return current_instance->GetDefaultSubframeSiteInstance(); |
1461 | 1464 |
1462 // At this point we know an unrelated site instance must be returned. First | 1465 // At this point we know an unrelated site instance must be returned. First |
1463 // check if the candidate matches. | 1466 // check if the candidate matches. |
1464 if (candidate_instance && | 1467 if (candidate_instance && |
1465 !current_instance->IsRelatedSiteInstance(candidate_instance) && | 1468 !current_instance->IsRelatedSiteInstance(candidate_instance) && |
1466 candidate_instance->GetSiteURL() == descriptor.new_site_url) { | 1469 candidate_instance->GetSiteURL() == descriptor.new_site_url) { |
1467 return candidate_instance; | 1470 return candidate_instance; |
1468 } | 1471 } |
1469 | 1472 |
1470 // Otherwise return a newly created one. | 1473 // Otherwise return a newly created one. |
1471 return SiteInstance::CreateForURL( | 1474 return SiteInstanceImpl::CreateForURL( |
1472 delegate_->GetControllerForRenderManager().GetBrowserContext(), | 1475 delegate_->GetControllerForRenderManager().GetBrowserContext(), |
1473 descriptor.new_site_url); | 1476 descriptor.new_site_url); |
1474 } | 1477 } |
1475 | 1478 |
1476 bool RenderFrameHostManager::IsCurrentlySameSite(RenderFrameHostImpl* candidate, | 1479 bool RenderFrameHostManager::IsCurrentlySameSite(RenderFrameHostImpl* candidate, |
1477 const GURL& dest_url) { | 1480 const GURL& dest_url) { |
1478 BrowserContext* browser_context = | 1481 BrowserContext* browser_context = |
1479 delegate_->GetControllerForRenderManager().GetBrowserContext(); | 1482 delegate_->GetControllerForRenderManager().GetBrowserContext(); |
1480 | 1483 |
1481 // If the process type is incorrect, reject the candidate even if |dest_url| | 1484 // If the process type is incorrect, reject the candidate even if |dest_url| |
(...skipping 30 matching lines...) Expand all Loading... |
1512 browser_context, | 1515 browser_context, |
1513 GURL(candidate->GetLastCommittedOrigin().Serialize()), dest_url)) { | 1516 GURL(candidate->GetLastCommittedOrigin().Serialize()), dest_url)) { |
1514 return true; | 1517 return true; |
1515 } | 1518 } |
1516 | 1519 |
1517 // Not same-site. | 1520 // Not same-site. |
1518 return false; | 1521 return false; |
1519 } | 1522 } |
1520 | 1523 |
1521 void RenderFrameHostManager::CreatePendingRenderFrameHost( | 1524 void RenderFrameHostManager::CreatePendingRenderFrameHost( |
1522 SiteInstance* old_instance, | 1525 SiteInstanceImpl* old_instance, |
1523 SiteInstance* new_instance) { | 1526 SiteInstanceImpl* new_instance) { |
1524 if (pending_render_frame_host_) | 1527 if (pending_render_frame_host_) |
1525 CancelPending(); | 1528 CancelPending(); |
1526 | 1529 |
1527 // The process for the new SiteInstance may (if we're sharing a process with | 1530 // The process for the new SiteInstance may (if we're sharing a process with |
1528 // another host that already initialized it) or may not (we have our own | 1531 // another host that already initialized it) or may not (we have our own |
1529 // process or the existing process crashed) have been initialized. Calling | 1532 // process or the existing process crashed) have been initialized. Calling |
1530 // Init multiple times will be ignored, so this is safe. | 1533 // Init multiple times will be ignored, so this is safe. |
1531 if (!new_instance->GetProcess()->Init()) | 1534 if (!new_instance->GetProcess()->Init()) |
1532 return; | 1535 return; |
1533 | 1536 |
1534 CreateProxiesForNewRenderFrameHost(old_instance, new_instance); | 1537 CreateProxiesForNewRenderFrameHost(old_instance, new_instance); |
1535 | 1538 |
1536 // Create a non-swapped-out RFH with the given opener. | 1539 // Create a non-swapped-out RFH with the given opener. |
1537 pending_render_frame_host_ = | 1540 pending_render_frame_host_ = |
1538 CreateRenderFrame(new_instance, delegate_->IsHidden(), nullptr); | 1541 CreateRenderFrame(new_instance, delegate_->IsHidden(), nullptr); |
1539 } | 1542 } |
1540 | 1543 |
1541 void RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( | 1544 void RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( |
1542 SiteInstance* old_instance, | 1545 SiteInstanceImpl* old_instance, |
1543 SiteInstance* new_instance) { | 1546 SiteInstanceImpl* new_instance) { |
1544 // Only create opener proxies if they are in the same BrowsingInstance. | 1547 // Only create opener proxies if they are in the same BrowsingInstance. |
1545 if (new_instance->IsRelatedSiteInstance(old_instance)) { | 1548 if (new_instance->IsRelatedSiteInstance(old_instance)) { |
1546 CreateOpenerProxies(new_instance, frame_tree_node_); | 1549 CreateOpenerProxies(new_instance, frame_tree_node_); |
1547 } else if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { | 1550 } else if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
1548 // Ensure that the frame tree has RenderFrameProxyHosts for the | 1551 // Ensure that the frame tree has RenderFrameProxyHosts for the |
1549 // new SiteInstance in all nodes except the current one. We do this for | 1552 // new SiteInstance in all nodes except the current one. We do this for |
1550 // all frames in the tree, whether they are in the same BrowsingInstance or | 1553 // all frames in the tree, whether they are in the same BrowsingInstance or |
1551 // not. If |new_instance| is in the same BrowsingInstance as | 1554 // not. If |new_instance| is in the same BrowsingInstance as |
1552 // |old_instance|, this will be done as part of CreateOpenerProxies above; | 1555 // |old_instance|, this will be done as part of CreateOpenerProxies above; |
1553 // otherwise, we do this here. We will still check whether two frames are | 1556 // otherwise, we do this here. We will still check whether two frames are |
(...skipping 11 matching lines...) Expand all Loading... |
1565 DCHECK(!frame_tree_node_->frame_name().empty()); | 1568 DCHECK(!frame_tree_node_->frame_name().empty()); |
1566 | 1569 |
1567 // If this is a top-level frame, create proxies for this node in the | 1570 // If this is a top-level frame, create proxies for this node in the |
1568 // SiteInstances of its opener's ancestors, which are allowed to discover | 1571 // SiteInstances of its opener's ancestors, which are allowed to discover |
1569 // this frame by name (see https://crbug.com/511474 and part 4 of | 1572 // this frame by name (see https://crbug.com/511474 and part 4 of |
1570 // https://html.spec.whatwg.org/#the-rules-for-choosing-a-browsing-context- | 1573 // https://html.spec.whatwg.org/#the-rules-for-choosing-a-browsing-context- |
1571 // given-a-browsing-context-name). | 1574 // given-a-browsing-context-name). |
1572 FrameTreeNode* opener = frame_tree_node_->opener(); | 1575 FrameTreeNode* opener = frame_tree_node_->opener(); |
1573 if (!opener || !frame_tree_node_->IsMainFrame()) | 1576 if (!opener || !frame_tree_node_->IsMainFrame()) |
1574 return; | 1577 return; |
1575 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 1578 SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance(); |
1576 | 1579 |
1577 // Start from opener's parent. There's no need to create a proxy in the | 1580 // Start from opener's parent. There's no need to create a proxy in the |
1578 // opener's SiteInstance, since new windows are always first opened in the | 1581 // opener's SiteInstance, since new windows are always first opened in the |
1579 // same SiteInstance as their opener, and if the new window navigates | 1582 // same SiteInstance as their opener, and if the new window navigates |
1580 // cross-site, that proxy would be created as part of swapping out. | 1583 // cross-site, that proxy would be created as part of swapping out. |
1581 for (FrameTreeNode* ancestor = opener->parent(); ancestor; | 1584 for (FrameTreeNode* ancestor = opener->parent(); ancestor; |
1582 ancestor = ancestor->parent()) { | 1585 ancestor = ancestor->parent()) { |
1583 RenderFrameHostImpl* ancestor_rfh = ancestor->current_frame_host(); | 1586 RenderFrameHostImpl* ancestor_rfh = ancestor->current_frame_host(); |
1584 if (ancestor_rfh->GetSiteInstance() != current_instance) | 1587 if (ancestor_rfh->GetSiteInstance() != current_instance) |
1585 CreateRenderFrameProxy(ancestor_rfh->GetSiteInstance()); | 1588 CreateRenderFrameProxy(ancestor_rfh->GetSiteInstance()); |
1586 } | 1589 } |
1587 } | 1590 } |
1588 | 1591 |
1589 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost( | 1592 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost( |
1590 SiteInstance* site_instance, | 1593 SiteInstanceImpl* site_instance, |
1591 int32_t view_routing_id, | 1594 int32_t view_routing_id, |
1592 int32_t frame_routing_id, | 1595 int32_t frame_routing_id, |
1593 int32_t widget_routing_id, | 1596 int32_t widget_routing_id, |
1594 bool hidden) { | 1597 bool hidden) { |
1595 if (frame_routing_id == MSG_ROUTING_NONE) | 1598 if (frame_routing_id == MSG_ROUTING_NONE) |
1596 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); | 1599 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); |
1597 | 1600 |
1598 // Create a RVH for main frames, or find the existing one for subframes. | 1601 // Create a RVH for main frames, or find the existing one for subframes. |
1599 FrameTree* frame_tree = frame_tree_node_->frame_tree(); | 1602 FrameTree* frame_tree = frame_tree_node_->frame_tree(); |
1600 RenderViewHostImpl* render_view_host = nullptr; | 1603 RenderViewHostImpl* render_view_host = nullptr; |
(...skipping 20 matching lines...) Expand all Loading... |
1621 } | 1624 } |
1622 | 1625 |
1623 return RenderFrameHostFactory::Create( | 1626 return RenderFrameHostFactory::Create( |
1624 site_instance, render_view_host, render_frame_delegate_, | 1627 site_instance, render_view_host, render_frame_delegate_, |
1625 render_widget_delegate_, frame_tree, frame_tree_node_, frame_routing_id, | 1628 render_widget_delegate_, frame_tree, frame_tree_node_, frame_routing_id, |
1626 widget_routing_id, hidden); | 1629 widget_routing_id, hidden); |
1627 } | 1630 } |
1628 | 1631 |
1629 // PlzNavigate | 1632 // PlzNavigate |
1630 bool RenderFrameHostManager::CreateSpeculativeRenderFrameHost( | 1633 bool RenderFrameHostManager::CreateSpeculativeRenderFrameHost( |
1631 SiteInstance* old_instance, | 1634 SiteInstanceImpl* old_instance, |
1632 SiteInstance* new_instance) { | 1635 SiteInstanceImpl* new_instance) { |
1633 CHECK(new_instance); | 1636 CHECK(new_instance); |
1634 CHECK_NE(old_instance, new_instance); | 1637 CHECK_NE(old_instance, new_instance); |
1635 | 1638 |
1636 // The process for the new SiteInstance may (if we're sharing a process with | 1639 // The process for the new SiteInstance may (if we're sharing a process with |
1637 // another host that already initialized it) or may not (we have our own | 1640 // another host that already initialized it) or may not (we have our own |
1638 // process or the existing process crashed) have been initialized. Calling | 1641 // process or the existing process crashed) have been initialized. Calling |
1639 // Init multiple times will be ignored, so this is safe. | 1642 // Init multiple times will be ignored, so this is safe. |
1640 if (!new_instance->GetProcess()->Init()) | 1643 if (!new_instance->GetProcess()->Init()) |
1641 return false; | 1644 return false; |
1642 | 1645 |
1643 CreateProxiesForNewRenderFrameHost(old_instance, new_instance); | 1646 CreateProxiesForNewRenderFrameHost(old_instance, new_instance); |
1644 | 1647 |
1645 speculative_render_frame_host_ = | 1648 speculative_render_frame_host_ = |
1646 CreateRenderFrame(new_instance, delegate_->IsHidden(), nullptr); | 1649 CreateRenderFrame(new_instance, delegate_->IsHidden(), nullptr); |
1647 | 1650 |
1648 return !!speculative_render_frame_host_; | 1651 return !!speculative_render_frame_host_; |
1649 } | 1652 } |
1650 | 1653 |
1651 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( | 1654 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( |
1652 SiteInstance* instance, | 1655 SiteInstanceImpl* instance, |
1653 bool hidden, | 1656 bool hidden, |
1654 int* view_routing_id_ptr) { | 1657 int* view_routing_id_ptr) { |
1655 int32_t widget_routing_id = MSG_ROUTING_NONE; | 1658 int32_t widget_routing_id = MSG_ROUTING_NONE; |
1656 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1659 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
1657 | 1660 |
1658 CHECK(instance); | 1661 CHECK(instance); |
1659 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible() || | 1662 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible() || |
1660 frame_tree_node_->IsMainFrame()); | 1663 frame_tree_node_->IsMainFrame()); |
1661 | 1664 |
1662 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 1665 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 } | 1722 } |
1720 | 1723 |
1721 // Return the new RenderFrameHost on successful creation. | 1724 // Return the new RenderFrameHost on successful creation. |
1722 if (success) { | 1725 if (success) { |
1723 DCHECK(new_render_frame_host->GetSiteInstance() == instance); | 1726 DCHECK(new_render_frame_host->GetSiteInstance() == instance); |
1724 return new_render_frame_host; | 1727 return new_render_frame_host; |
1725 } | 1728 } |
1726 return nullptr; | 1729 return nullptr; |
1727 } | 1730 } |
1728 | 1731 |
1729 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) { | 1732 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstanceImpl* instance) { |
1730 // A RenderFrameProxyHost should never be created in the same SiteInstance as | 1733 // A RenderFrameProxyHost should never be created in the same SiteInstance as |
1731 // the current RFH. | 1734 // the current RFH. |
1732 CHECK(instance); | 1735 CHECK(instance); |
1733 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); | 1736 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); |
1734 | 1737 |
1735 RenderViewHostImpl* render_view_host = nullptr; | 1738 RenderViewHostImpl* render_view_host = nullptr; |
1736 | 1739 |
1737 // Ensure a RenderViewHost exists for |instance|, as it creates the page | 1740 // Ensure a RenderViewHost exists for |instance|, as it creates the page |
1738 // level structure in Blink. | 1741 // level structure in Blink. |
1739 render_view_host = | 1742 render_view_host = |
(...skipping 29 matching lines...) Expand all Loading... |
1769 if (pair.second.get() == outer_delegate_proxy) | 1772 if (pair.second.get() == outer_delegate_proxy) |
1770 continue; | 1773 continue; |
1771 | 1774 |
1772 child->render_manager()->CreateRenderFrameProxy( | 1775 child->render_manager()->CreateRenderFrameProxy( |
1773 pair.second->GetSiteInstance()); | 1776 pair.second->GetSiteInstance()); |
1774 } | 1777 } |
1775 } | 1778 } |
1776 | 1779 |
1777 void RenderFrameHostManager::EnsureRenderViewInitialized( | 1780 void RenderFrameHostManager::EnsureRenderViewInitialized( |
1778 RenderViewHostImpl* render_view_host, | 1781 RenderViewHostImpl* render_view_host, |
1779 SiteInstance* instance) { | 1782 SiteInstanceImpl* instance) { |
1780 DCHECK(frame_tree_node_->IsMainFrame()); | 1783 DCHECK(frame_tree_node_->IsMainFrame()); |
1781 | 1784 |
1782 if (render_view_host->IsRenderViewLive()) | 1785 if (render_view_host->IsRenderViewLive()) |
1783 return; | 1786 return; |
1784 | 1787 |
1785 // If the proxy in |instance| doesn't exist, this RenderView is not swapped | 1788 // If the proxy in |instance| doesn't exist, this RenderView is not swapped |
1786 // out and shouldn't be reinitialized here. | 1789 // out and shouldn't be reinitialized here. |
1787 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1790 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
1788 if (!proxy) | 1791 if (!proxy) |
1789 return; | 1792 return; |
1790 | 1793 |
1791 InitRenderView(render_view_host, proxy); | 1794 InitRenderView(render_view_host, proxy); |
1792 } | 1795 } |
1793 | 1796 |
1794 void RenderFrameHostManager::CreateOuterDelegateProxy( | 1797 void RenderFrameHostManager::CreateOuterDelegateProxy( |
1795 SiteInstance* outer_contents_site_instance, | 1798 SiteInstanceImpl* outer_contents_site_instance, |
1796 RenderFrameHostImpl* render_frame_host) { | 1799 RenderFrameHostImpl* render_frame_host) { |
1797 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); | 1800 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); |
1798 RenderFrameProxyHost* proxy = | 1801 RenderFrameProxyHost* proxy = |
1799 CreateRenderFrameProxyHost(outer_contents_site_instance, nullptr); | 1802 CreateRenderFrameProxyHost(outer_contents_site_instance, nullptr); |
1800 | 1803 |
1801 // Swap the outer WebContents's frame with the proxy to inner WebContents. | 1804 // Swap the outer WebContents's frame with the proxy to inner WebContents. |
1802 // | 1805 // |
1803 // We are in the outer WebContents, and its FrameTree would never see | 1806 // We are in the outer WebContents, and its FrameTree would never see |
1804 // a load start for any of its inner WebContents. Eventually, that also makes | 1807 // a load start for any of its inner WebContents. Eventually, that also makes |
1805 // the FrameTree never see the matching load stop. Therefore, we always pass | 1808 // the FrameTree never see the matching load stop. Therefore, we always pass |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 proxy->set_render_frame_proxy_created(true); | 1846 proxy->set_render_frame_proxy_created(true); |
1844 | 1847 |
1845 return created; | 1848 return created; |
1846 } | 1849 } |
1847 | 1850 |
1848 bool RenderFrameHostManager::InitRenderFrame( | 1851 bool RenderFrameHostManager::InitRenderFrame( |
1849 RenderFrameHostImpl* render_frame_host) { | 1852 RenderFrameHostImpl* render_frame_host) { |
1850 if (render_frame_host->IsRenderFrameLive()) | 1853 if (render_frame_host->IsRenderFrameLive()) |
1851 return true; | 1854 return true; |
1852 | 1855 |
1853 SiteInstance* site_instance = render_frame_host->GetSiteInstance(); | 1856 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); |
1854 | 1857 |
1855 int opener_routing_id = MSG_ROUTING_NONE; | 1858 int opener_routing_id = MSG_ROUTING_NONE; |
1856 if (frame_tree_node_->opener()) | 1859 if (frame_tree_node_->opener()) |
1857 opener_routing_id = GetOpenerRoutingID(site_instance); | 1860 opener_routing_id = GetOpenerRoutingID(site_instance); |
1858 | 1861 |
1859 int parent_routing_id = MSG_ROUTING_NONE; | 1862 int parent_routing_id = MSG_ROUTING_NONE; |
1860 if (frame_tree_node_->parent()) { | 1863 if (frame_tree_node_->parent()) { |
1861 parent_routing_id = frame_tree_node_->parent() | 1864 parent_routing_id = frame_tree_node_->parent() |
1862 ->render_manager() | 1865 ->render_manager() |
1863 ->GetRoutingIdForSiteInstance(site_instance); | 1866 ->GetRoutingIdForSiteInstance(site_instance); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1923 // https://crbug.com/591478. Verify that the parent routing ID | 1926 // https://crbug.com/591478. Verify that the parent routing ID |
1924 // points to a live RenderFrameProxy when this is not a remote-to-local | 1927 // points to a live RenderFrameProxy when this is not a remote-to-local |
1925 // navigation (i.e., when there's no |existing_proxy|). | 1928 // navigation (i.e., when there's no |existing_proxy|). |
1926 if (!existing_proxy && frame_tree_node_->parent()) { | 1929 if (!existing_proxy && frame_tree_node_->parent()) { |
1927 RenderFrameProxyHost* parent_proxy = RenderFrameProxyHost::FromID( | 1930 RenderFrameProxyHost* parent_proxy = RenderFrameProxyHost::FromID( |
1928 render_frame_host->GetProcess()->GetID(), parent_routing_id); | 1931 render_frame_host->GetProcess()->GetID(), parent_routing_id); |
1929 if (!parent_proxy || !parent_proxy->is_render_frame_proxy_live()) { | 1932 if (!parent_proxy || !parent_proxy->is_render_frame_proxy_live()) { |
1930 base::debug::SetCrashKeyValue("initrf_parent_proxy_exists", | 1933 base::debug::SetCrashKeyValue("initrf_parent_proxy_exists", |
1931 parent_proxy ? "yes" : "no"); | 1934 parent_proxy ? "yes" : "no"); |
1932 | 1935 |
1933 SiteInstance* parent_instance = | 1936 SiteInstanceImpl* parent_instance = |
1934 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance(); | 1937 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance(); |
1935 base::debug::SetCrashKeyValue( | 1938 base::debug::SetCrashKeyValue( |
1936 "initrf_parent_is_in_same_site_instance", | 1939 "initrf_parent_is_in_same_site_instance", |
1937 site_instance == parent_instance ? "yes" : "no"); | 1940 site_instance == parent_instance ? "yes" : "no"); |
1938 base::debug::SetCrashKeyValue("initrf_parent_process_is_live", | 1941 base::debug::SetCrashKeyValue("initrf_parent_process_is_live", |
1939 frame_tree_node_->parent() | 1942 frame_tree_node_->parent() |
1940 ->current_frame_host() | 1943 ->current_frame_host() |
1941 ->GetProcess() | 1944 ->GetProcess() |
1942 ->HasConnection() | 1945 ->HasConnection() |
1943 ? "yes" | 1946 ? "yes" |
1944 : "no"); | 1947 : "no"); |
1945 base::debug::SetCrashKeyValue( | 1948 base::debug::SetCrashKeyValue( |
1946 "initrf_render_view_is_live", | 1949 "initrf_render_view_is_live", |
1947 render_frame_host->render_view_host()->IsRenderViewLive() ? "yes" | 1950 render_frame_host->render_view_host()->IsRenderViewLive() ? "yes" |
1948 : "no"); | 1951 : "no"); |
1949 | 1952 |
1950 // Collect some additional information for root's proxy if it's different | 1953 // Collect some additional information for root's proxy if it's different |
1951 // from the parent. | 1954 // from the parent. |
1952 FrameTreeNode* root = frame_tree_node_->frame_tree()->root(); | 1955 FrameTreeNode* root = frame_tree_node_->frame_tree()->root(); |
1953 if (root != frame_tree_node_->parent()) { | 1956 if (root != frame_tree_node_->parent()) { |
1954 SiteInstance* root_instance = | 1957 SiteInstanceImpl* root_instance = |
1955 root->current_frame_host()->GetSiteInstance(); | 1958 root->current_frame_host()->GetSiteInstance(); |
1956 base::debug::SetCrashKeyValue( | 1959 base::debug::SetCrashKeyValue( |
1957 "initrf_root_is_in_same_site_instance", | 1960 "initrf_root_is_in_same_site_instance", |
1958 site_instance == root_instance ? "yes" : "no"); | 1961 site_instance == root_instance ? "yes" : "no"); |
1959 base::debug::SetCrashKeyValue( | 1962 base::debug::SetCrashKeyValue( |
1960 "initrf_root_is_in_same_site_instance_as_parent", | 1963 "initrf_root_is_in_same_site_instance_as_parent", |
1961 parent_instance == root_instance ? "yes" : "no"); | 1964 parent_instance == root_instance ? "yes" : "no"); |
1962 base::debug::SetCrashKeyValue("initrf_root_process_is_live", | 1965 base::debug::SetCrashKeyValue("initrf_root_process_is_live", |
1963 frame_tree_node_->frame_tree() | 1966 frame_tree_node_->frame_tree() |
1964 ->root() | 1967 ->root() |
(...skipping 15 matching lines...) Expand all Loading... |
1980 base::debug::DumpWithoutCrashing(); | 1983 base::debug::DumpWithoutCrashing(); |
1981 } | 1984 } |
1982 } | 1985 } |
1983 | 1986 |
1984 return delegate_->CreateRenderFrameForRenderManager( | 1987 return delegate_->CreateRenderFrameForRenderManager( |
1985 render_frame_host, proxy_routing_id, opener_routing_id, parent_routing_id, | 1988 render_frame_host, proxy_routing_id, opener_routing_id, parent_routing_id, |
1986 previous_sibling_routing_id); | 1989 previous_sibling_routing_id); |
1987 } | 1990 } |
1988 | 1991 |
1989 int RenderFrameHostManager::GetRoutingIdForSiteInstance( | 1992 int RenderFrameHostManager::GetRoutingIdForSiteInstance( |
1990 SiteInstance* site_instance) { | 1993 SiteInstanceImpl* site_instance) { |
1991 if (render_frame_host_->GetSiteInstance() == site_instance) | 1994 if (render_frame_host_->GetSiteInstance() == site_instance) |
1992 return render_frame_host_->GetRoutingID(); | 1995 return render_frame_host_->GetRoutingID(); |
1993 | 1996 |
1994 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); | 1997 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); |
1995 if (proxy) | 1998 if (proxy) |
1996 return proxy->GetRoutingID(); | 1999 return proxy->GetRoutingID(); |
1997 | 2000 |
1998 return MSG_ROUTING_NONE; | 2001 return MSG_ROUTING_NONE; |
1999 } | 2002 } |
2000 | 2003 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2136 proxy_to_parent->SetChildRWHView(render_frame_host_->GetView()); | 2139 proxy_to_parent->SetChildRWHView(render_frame_host_->GetView()); |
2137 } | 2140 } |
2138 | 2141 |
2139 // After all is done, there must never be a proxy in the list which has the | 2142 // After all is done, there must never be a proxy in the list which has the |
2140 // same SiteInstance as the current RenderFrameHost. | 2143 // same SiteInstance as the current RenderFrameHost. |
2141 CHECK(!GetRenderFrameProxyHost(render_frame_host_->GetSiteInstance())); | 2144 CHECK(!GetRenderFrameProxyHost(render_frame_host_->GetSiteInstance())); |
2142 } | 2145 } |
2143 | 2146 |
2144 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( | 2147 RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( |
2145 const GURL& dest_url, | 2148 const GURL& dest_url, |
2146 SiteInstance* source_instance, | 2149 SiteInstanceImpl* source_instance, |
2147 SiteInstance* dest_instance, | 2150 SiteInstanceImpl* dest_instance, |
2148 ui::PageTransition transition, | 2151 ui::PageTransition transition, |
2149 bool dest_is_restore, | 2152 bool dest_is_restore, |
2150 bool dest_is_view_source_mode, | 2153 bool dest_is_view_source_mode, |
2151 const GlobalRequestID& transferred_request_id, | 2154 const GlobalRequestID& transferred_request_id, |
2152 int bindings) { | 2155 int bindings) { |
2153 if (!frame_tree_node_->IsMainFrame()) { | 2156 if (!frame_tree_node_->IsMainFrame()) { |
2154 // Don't swap for subframes unless we are in an OOPIF-enabled mode. We can | 2157 // Don't swap for subframes unless we are in an OOPIF-enabled mode. We can |
2155 // get here in tests for subframes (e.g., NavigateFrameToURL). | 2158 // get here in tests for subframes (e.g., NavigateFrameToURL). |
2156 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) | 2159 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
2157 return render_frame_host_.get(); | 2160 return render_frame_host_.get(); |
(...skipping 15 matching lines...) Expand all Loading... |
2173 // the policy determines that a transfer would have been needed. We can get | 2176 // the policy determines that a transfer would have been needed. We can get |
2174 // here for session restore. | 2177 // here for session restore. |
2175 if (!IsRendererTransferNeededForNavigation(render_frame_host_.get(), | 2178 if (!IsRendererTransferNeededForNavigation(render_frame_host_.get(), |
2176 resolved_url)) { | 2179 resolved_url)) { |
2177 DCHECK(!dest_instance || | 2180 DCHECK(!dest_instance || |
2178 dest_instance == render_frame_host_->GetSiteInstance()); | 2181 dest_instance == render_frame_host_->GetSiteInstance()); |
2179 return render_frame_host_.get(); | 2182 return render_frame_host_.get(); |
2180 } | 2183 } |
2181 } | 2184 } |
2182 | 2185 |
2183 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 2186 SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance(); |
2184 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 2187 scoped_refptr<SiteInstanceImpl> new_instance = GetSiteInstanceForNavigation( |
2185 dest_url, source_instance, dest_instance, nullptr, transition, | 2188 dest_url, source_instance, dest_instance, nullptr, transition, |
2186 dest_is_restore, dest_is_view_source_mode); | 2189 dest_is_restore, dest_is_view_source_mode); |
2187 | 2190 |
2188 // If we are currently navigating cross-process to a pending RFH for a | 2191 // If we are currently navigating cross-process to a pending RFH for a |
2189 // different SiteInstance, we want to get back to normal and then navigate as | 2192 // different SiteInstance, we want to get back to normal and then navigate as |
2190 // usual. We will reuse the pending RFH below if it matches the destination | 2193 // usual. We will reuse the pending RFH below if it matches the destination |
2191 // SiteInstance. | 2194 // SiteInstance. |
2192 if (pending_render_frame_host_ && | 2195 if (pending_render_frame_host_ && |
2193 pending_render_frame_host_->GetSiteInstance() != new_instance) | 2196 pending_render_frame_host_->GetSiteInstance() != new_instance) |
2194 CancelPending(); | 2197 CancelPending(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 return false; | 2384 return false; |
2382 | 2385 |
2383 RenderFrameProxyHost* host = GetRenderFrameProxyHost(rfh->GetSiteInstance()); | 2386 RenderFrameProxyHost* host = GetRenderFrameProxyHost(rfh->GetSiteInstance()); |
2384 if (!host) | 2387 if (!host) |
2385 return false; | 2388 return false; |
2386 | 2389 |
2387 return host->render_frame_host() == rfh; | 2390 return host->render_frame_host() == rfh; |
2388 } | 2391 } |
2389 | 2392 |
2390 RenderViewHostImpl* RenderFrameHostManager::GetSwappedOutRenderViewHost( | 2393 RenderViewHostImpl* RenderFrameHostManager::GetSwappedOutRenderViewHost( |
2391 SiteInstance* instance) const { | 2394 SiteInstance* instance) const { |
2392 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 2395 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
2393 if (proxy) | 2396 if (proxy) |
2394 return proxy->GetRenderViewHost(); | 2397 return proxy->GetRenderViewHost(); |
2395 return nullptr; | 2398 return nullptr; |
2396 } | 2399 } |
2397 | 2400 |
2398 RenderFrameProxyHost* RenderFrameHostManager::GetRenderFrameProxyHost( | 2401 RenderFrameProxyHost* RenderFrameHostManager::GetRenderFrameProxyHost( |
2399 SiteInstance* instance) const { | 2402 SiteInstance* instance) const { |
2400 auto it = proxy_hosts_.find(instance->GetId()); | 2403 auto it = |
| 2404 proxy_hosts_.find(static_cast<SiteInstanceImpl*>(instance)->GetId()); |
2401 if (it != proxy_hosts_.end()) | 2405 if (it != proxy_hosts_.end()) |
2402 return it->second.get(); | 2406 return it->second.get(); |
2403 return nullptr; | 2407 return nullptr; |
2404 } | 2408 } |
2405 | 2409 |
2406 int RenderFrameHostManager::GetProxyCount() { | 2410 int RenderFrameHostManager::GetProxyCount() { |
2407 return proxy_hosts_.size(); | 2411 return proxy_hosts_.size(); |
2408 } | 2412 } |
2409 | 2413 |
2410 void RenderFrameHostManager::CollectOpenerFrameTrees( | 2414 void RenderFrameHostManager::CollectOpenerFrameTrees( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2443 size_t position = | 2447 size_t position = |
2444 std::distance(opener_frame_trees->begin(), existing_tree_it); | 2448 std::distance(opener_frame_trees->begin(), existing_tree_it); |
2445 if (position < visited_index) | 2449 if (position < visited_index) |
2446 nodes_with_back_links->insert(node); | 2450 nodes_with_back_links->insert(node); |
2447 } | 2451 } |
2448 } | 2452 } |
2449 } | 2453 } |
2450 } | 2454 } |
2451 | 2455 |
2452 void RenderFrameHostManager::CreateOpenerProxies( | 2456 void RenderFrameHostManager::CreateOpenerProxies( |
2453 SiteInstance* instance, | 2457 SiteInstanceImpl* instance, |
2454 FrameTreeNode* skip_this_node) { | 2458 FrameTreeNode* skip_this_node) { |
2455 std::vector<FrameTree*> opener_frame_trees; | 2459 std::vector<FrameTree*> opener_frame_trees; |
2456 base::hash_set<FrameTreeNode*> nodes_with_back_links; | 2460 base::hash_set<FrameTreeNode*> nodes_with_back_links; |
2457 | 2461 |
2458 CollectOpenerFrameTrees(&opener_frame_trees, &nodes_with_back_links); | 2462 CollectOpenerFrameTrees(&opener_frame_trees, &nodes_with_back_links); |
2459 | 2463 |
2460 // Create opener proxies for frame trees, processing furthest openers from | 2464 // Create opener proxies for frame trees, processing furthest openers from |
2461 // this node first and this node last. In the common case without cycles, | 2465 // this node first and this node last. In the common case without cycles, |
2462 // this will ensure that each tree's openers are created before the tree's | 2466 // this will ensure that each tree's openers are created before the tree's |
2463 // nodes need to reference them. | 2467 // nodes need to reference them. |
(...skipping 21 matching lines...) Expand all Loading... |
2485 | 2489 |
2486 int opener_routing_id = | 2490 int opener_routing_id = |
2487 node->render_manager()->GetOpenerRoutingID(instance); | 2491 node->render_manager()->GetOpenerRoutingID(instance); |
2488 DCHECK_NE(opener_routing_id, MSG_ROUTING_NONE); | 2492 DCHECK_NE(opener_routing_id, MSG_ROUTING_NONE); |
2489 proxy->Send(new FrameMsg_UpdateOpener(proxy->GetRoutingID(), | 2493 proxy->Send(new FrameMsg_UpdateOpener(proxy->GetRoutingID(), |
2490 opener_routing_id)); | 2494 opener_routing_id)); |
2491 } | 2495 } |
2492 } | 2496 } |
2493 | 2497 |
2494 void RenderFrameHostManager::CreateOpenerProxiesForFrameTree( | 2498 void RenderFrameHostManager::CreateOpenerProxiesForFrameTree( |
2495 SiteInstance* instance, | 2499 SiteInstanceImpl* instance, |
2496 FrameTreeNode* skip_this_node) { | 2500 FrameTreeNode* skip_this_node) { |
2497 // Currently, this function is only called on main frames. It should | 2501 // Currently, this function is only called on main frames. It should |
2498 // actually work correctly for subframes as well, so if that need ever | 2502 // actually work correctly for subframes as well, so if that need ever |
2499 // arises, it should be sufficient to remove this DCHECK. | 2503 // arises, it should be sufficient to remove this DCHECK. |
2500 DCHECK(frame_tree_node_->IsMainFrame()); | 2504 DCHECK(frame_tree_node_->IsMainFrame()); |
2501 | 2505 |
2502 if (frame_tree_node_ == skip_this_node) | 2506 if (frame_tree_node_ == skip_this_node) |
2503 return; | 2507 return; |
2504 | 2508 |
2505 FrameTree* frame_tree = frame_tree_node_->frame_tree(); | 2509 FrameTree* frame_tree = frame_tree_node_->frame_tree(); |
(...skipping 27 matching lines...) Expand all Loading... |
2533 EnsureRenderViewInitialized(rvh, instance); | 2537 EnsureRenderViewInitialized(rvh, instance); |
2534 } else { | 2538 } else { |
2535 // Create a RenderFrameProxyHost in the given SiteInstance if none | 2539 // Create a RenderFrameProxyHost in the given SiteInstance if none |
2536 // exists. Since an opener can point to a subframe, do this on the root | 2540 // exists. Since an opener can point to a subframe, do this on the root |
2537 // frame of the current opener's frame tree. | 2541 // frame of the current opener's frame tree. |
2538 frame_tree->root()->render_manager()->CreateRenderFrameProxy(instance); | 2542 frame_tree->root()->render_manager()->CreateRenderFrameProxy(instance); |
2539 } | 2543 } |
2540 } | 2544 } |
2541 } | 2545 } |
2542 | 2546 |
2543 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2547 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstanceImpl* instance) { |
2544 if (!frame_tree_node_->opener()) | 2548 if (!frame_tree_node_->opener()) |
2545 return MSG_ROUTING_NONE; | 2549 return MSG_ROUTING_NONE; |
2546 | 2550 |
2547 return frame_tree_node_->opener() | 2551 return frame_tree_node_->opener() |
2548 ->render_manager() | 2552 ->render_manager() |
2549 ->GetRoutingIdForSiteInstance(instance); | 2553 ->GetRoutingIdForSiteInstance(instance); |
2550 } | 2554 } |
2551 | 2555 |
2552 void RenderFrameHostManager::SendPageMessage(IPC::Message* msg) { | 2556 void RenderFrameHostManager::SendPageMessage(IPC::Message* msg) { |
2553 DCHECK(IPC_MESSAGE_CLASS(*msg) == PageMsgStart); | 2557 DCHECK(IPC_MESSAGE_CLASS(*msg) == PageMsgStart); |
(...skipping 21 matching lines...) Expand all Loading... |
2575 } else if (pending_render_frame_host_) { | 2579 } else if (pending_render_frame_host_) { |
2576 send_msg(pending_render_frame_host_.get(), | 2580 send_msg(pending_render_frame_host_.get(), |
2577 pending_render_frame_host_->GetRoutingID(), msg); | 2581 pending_render_frame_host_->GetRoutingID(), msg); |
2578 } | 2582 } |
2579 | 2583 |
2580 msg->set_routing_id(render_frame_host_->GetRoutingID()); | 2584 msg->set_routing_id(render_frame_host_->GetRoutingID()); |
2581 render_frame_host_->Send(msg); | 2585 render_frame_host_->Send(msg); |
2582 } | 2586 } |
2583 | 2587 |
2584 } // namespace content | 2588 } // namespace content |
OLD | NEW |