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/logging.h" | 10 #include "base/logging.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "content/browser/frame_host/render_frame_host_factory.h" | 23 #include "content/browser/frame_host/render_frame_host_factory.h" |
24 #include "content/browser/frame_host/render_frame_host_impl.h" | 24 #include "content/browser/frame_host/render_frame_host_impl.h" |
25 #include "content/browser/frame_host/render_frame_proxy_host.h" | 25 #include "content/browser/frame_host/render_frame_proxy_host.h" |
26 #include "content/browser/renderer_host/render_process_host_impl.h" | 26 #include "content/browser/renderer_host/render_process_host_impl.h" |
27 #include "content/browser/renderer_host/render_view_host_factory.h" | 27 #include "content/browser/renderer_host/render_view_host_factory.h" |
28 #include "content/browser/renderer_host/render_view_host_impl.h" | 28 #include "content/browser/renderer_host/render_view_host_impl.h" |
29 #include "content/browser/site_instance_impl.h" | 29 #include "content/browser/site_instance_impl.h" |
30 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 30 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
31 #include "content/browser/webui/web_ui_impl.h" | 31 #include "content/browser/webui/web_ui_impl.h" |
32 #include "content/common/frame_messages.h" | 32 #include "content/common/frame_messages.h" |
| 33 #include "content/common/site_isolation_policy.h" |
33 #include "content/common/view_messages.h" | 34 #include "content/common/view_messages.h" |
34 #include "content/public/browser/content_browser_client.h" | 35 #include "content/public/browser/content_browser_client.h" |
35 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_types.h" | 37 #include "content/public/browser/notification_types.h" |
37 #include "content/public/browser/render_widget_host_iterator.h" | 38 #include "content/public/browser/render_widget_host_iterator.h" |
38 #include "content/public/browser/render_widget_host_view.h" | 39 #include "content/public/browser/render_widget_host_view.h" |
39 #include "content/public/browser/user_metrics.h" | 40 #include "content/public/browser/user_metrics.h" |
40 #include "content/public/browser/web_ui_controller.h" | 41 #include "content/public/browser/web_ui_controller.h" |
| 42 #include "content/public/common/browser_plugin_guest_mode.h" |
41 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
42 #include "content/public/common/referrer.h" | 44 #include "content/public/common/referrer.h" |
43 #include "content/public/common/url_constants.h" | 45 #include "content/public/common/url_constants.h" |
44 | 46 |
45 namespace content { | 47 namespace content { |
46 | 48 |
47 // static | 49 // static |
48 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { | 50 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { |
49 node->render_manager()->pending_delete_hosts_.clear(); | 51 node->render_manager()->pending_delete_hosts_.clear(); |
50 return true; | 52 return true; |
51 } | 53 } |
52 | 54 |
53 // static | 55 // static |
54 bool RenderFrameHostManager::IsSwappedOutStateForbidden() { | 56 bool RenderFrameHostManager::IsSwappedOutStateForbidden() { |
55 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 57 return SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
56 switches::kSitePerProcess); | |
57 } | 58 } |
58 | 59 |
59 RenderFrameHostManager::RenderFrameHostManager( | 60 RenderFrameHostManager::RenderFrameHostManager( |
60 FrameTreeNode* frame_tree_node, | 61 FrameTreeNode* frame_tree_node, |
61 RenderFrameHostDelegate* render_frame_delegate, | 62 RenderFrameHostDelegate* render_frame_delegate, |
62 RenderViewHostDelegate* render_view_delegate, | 63 RenderViewHostDelegate* render_view_delegate, |
63 RenderWidgetHostDelegate* render_widget_delegate, | 64 RenderWidgetHostDelegate* render_widget_delegate, |
64 Delegate* delegate) | 65 Delegate* delegate) |
65 : frame_tree_node_(frame_tree_node), | 66 : frame_tree_node_(frame_tree_node), |
66 delegate_(delegate), | 67 delegate_(delegate), |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 // swap are sent to the browser via the OpenURL IPC and are afterwards treated | 805 // swap are sent to the browser via the OpenURL IPC and are afterwards treated |
805 // as browser-initiated navigations. NavigationRequests marked as | 806 // as browser-initiated navigations. NavigationRequests marked as |
806 // renderer-initiated are created by receiving a BeginNavigation IPC, and will | 807 // renderer-initiated are created by receiving a BeginNavigation IPC, and will |
807 // then proceed in the same renderer that sent the IPC due to the condition | 808 // then proceed in the same renderer that sent the IPC due to the condition |
808 // below. | 809 // below. |
809 // Subframe navigations will use the current renderer, unless | 810 // Subframe navigations will use the current renderer, unless |
810 // --site-per-process is enabled. | 811 // --site-per-process is enabled. |
811 // TODO(carlosk): Have renderer-initated main frame navigations swap processes | 812 // TODO(carlosk): Have renderer-initated main frame navigations swap processes |
812 // if needed when it no longer breaks OAuth popups (see | 813 // if needed when it no longer breaks OAuth popups (see |
813 // https://crbug.com/440266). | 814 // https://crbug.com/440266). |
814 bool site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
815 switches::kSitePerProcess); | |
816 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 815 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
817 if (current_site_instance == dest_site_instance.get() || | 816 if (current_site_instance == dest_site_instance.get() || |
818 (!request.browser_initiated() && is_main_frame) || | 817 (!request.browser_initiated() && is_main_frame) || |
819 (!is_main_frame && !site_per_process)) { | 818 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() && |
| 819 !current_site_instance->RequiresDedicatedProcess())) { |
820 // Reuse the current RFH if its SiteInstance matches the the navigation's | 820 // Reuse the current RFH if its SiteInstance matches the the navigation's |
821 // or if this is a subframe navigation. We only swap RFHs for subframes when | 821 // or if this is a subframe navigation. We only swap RFHs for subframes when |
822 // --site-per-process is enabled. | 822 // --site-per-process is enabled. |
823 CleanUpNavigation(); | 823 CleanUpNavigation(); |
824 navigation_rfh = render_frame_host_.get(); | 824 navigation_rfh = render_frame_host_.get(); |
825 | 825 |
826 // As SiteInstances are the same, check if the WebUI should be reused. | 826 // As SiteInstances are the same, check if the WebUI should be reused. |
827 const NavigationEntry* current_navigation_entry = | 827 const NavigationEntry* current_navigation_entry = |
828 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 828 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
829 should_reuse_web_ui_ = ShouldReuseWebUI(current_navigation_entry, | 829 should_reuse_web_ui_ = ShouldReuseWebUI(current_navigation_entry, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 void RenderFrameHostManager::OnDidStopLoading() { | 922 void RenderFrameHostManager::OnDidStopLoading() { |
923 for (const auto& pair : proxy_hosts_) { | 923 for (const auto& pair : proxy_hosts_) { |
924 pair.second->Send(new FrameMsg_DidStopLoading(pair.second->GetRoutingID())); | 924 pair.second->Send(new FrameMsg_DidStopLoading(pair.second->GetRoutingID())); |
925 } | 925 } |
926 } | 926 } |
927 | 927 |
928 void RenderFrameHostManager::OnDidUpdateName(const std::string& name) { | 928 void RenderFrameHostManager::OnDidUpdateName(const std::string& name) { |
929 // The window.name message may be sent outside of --site-per-process when | 929 // The window.name message may be sent outside of --site-per-process when |
930 // report_frame_name_changes renderer preference is set (used by | 930 // report_frame_name_changes renderer preference is set (used by |
931 // WebView). Don't send the update to proxies in those cases. | 931 // WebView). Don't send the update to proxies in those cases. |
932 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 932 // TODO(nick,nasko): Should this be IsSwappedOutStateForbidden, to match |
933 switches::kSitePerProcess)) | 933 // OnDidUpdateOrigin? |
| 934 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
934 return; | 935 return; |
935 | 936 |
936 for (const auto& pair : proxy_hosts_) { | 937 for (const auto& pair : proxy_hosts_) { |
937 pair.second->Send( | 938 pair.second->Send( |
938 new FrameMsg_DidUpdateName(pair.second->GetRoutingID(), name)); | 939 new FrameMsg_DidUpdateName(pair.second->GetRoutingID(), name)); |
939 } | 940 } |
940 } | 941 } |
941 | 942 |
942 void RenderFrameHostManager::OnDidUpdateOrigin( | 943 void RenderFrameHostManager::OnDidUpdateOrigin( |
943 const url::DeprecatedSerializedOrigin& origin) { | 944 const url::DeprecatedSerializedOrigin& origin) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 FrameTreeNode* node) { | 1008 FrameTreeNode* node) { |
1008 RenderFrameProxyHostMap::iterator iter = | 1009 RenderFrameProxyHostMap::iterator iter = |
1009 node->render_manager()->proxy_hosts_.find(site_instance_id); | 1010 node->render_manager()->proxy_hosts_.find(site_instance_id); |
1010 if (iter != node->render_manager()->proxy_hosts_.end()) | 1011 if (iter != node->render_manager()->proxy_hosts_.end()) |
1011 iter->second->set_render_frame_proxy_created(false); | 1012 iter->second->set_render_frame_proxy_created(false); |
1012 | 1013 |
1013 return true; | 1014 return true; |
1014 } | 1015 } |
1015 | 1016 |
1016 bool RenderFrameHostManager::ShouldTransitionCrossSite() { | 1017 bool RenderFrameHostManager::ShouldTransitionCrossSite() { |
1017 // True for --site-per-process, which overrides both kSingleProcess and | 1018 // The logic below is weaker than "are all sites isolated" -- it asks instead, |
1018 // kProcessPerTab. | 1019 // "is any site isolated". That's appropriate here since we're just trying to |
1019 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1020 // figure out if we're in any kind of site isolated mode, and in which case, |
1020 switches::kSitePerProcess)) | 1021 // we ignore the kSingleProcess and kProcessPerTab settings. |
| 1022 // |
| 1023 // TODO(nick): Move all handling of kSingleProcess/kProcessPerTab into |
| 1024 // SiteIsolationPolicy so we have a consistent behavior around the interaction |
| 1025 // of the process model flags. |
| 1026 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
1021 return true; | 1027 return true; |
1022 | 1028 |
1023 // False in the single-process mode, as it makes RVHs to accumulate | 1029 // False in the single-process mode, as it makes RVHs to accumulate |
1024 // in swapped_out_hosts_. | 1030 // in swapped_out_hosts_. |
1025 // True if we are using process-per-site-instance (default) or | 1031 // True if we are using process-per-site-instance (default) or |
1026 // process-per-site (kProcessPerSite). | 1032 // process-per-site (kProcessPerSite). |
| 1033 // TODO(nick): Move handling of kSingleProcess and kProcessPerTab into |
| 1034 // SiteIsolationPolicy. |
1027 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1035 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1028 switches::kSingleProcess) && | 1036 switches::kSingleProcess) && |
1029 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1037 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1030 switches::kProcessPerTab); | 1038 switches::kProcessPerTab); |
1031 } | 1039 } |
1032 | 1040 |
1033 bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( | 1041 bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( |
1034 const GURL& current_effective_url, | 1042 const GURL& current_effective_url, |
1035 bool current_is_view_source_mode, | 1043 bool current_is_view_source_mode, |
1036 SiteInstance* new_site_instance, | 1044 SiteInstance* new_site_instance, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 | 1369 |
1362 const GURL& RenderFrameHostManager::GetCurrentURLForSiteInstance( | 1370 const GURL& RenderFrameHostManager::GetCurrentURLForSiteInstance( |
1363 SiteInstance* current_instance, NavigationEntry* current_entry) { | 1371 SiteInstance* current_instance, NavigationEntry* current_entry) { |
1364 // If this is a subframe that is potentially out of process from its parent, | 1372 // If this is a subframe that is potentially out of process from its parent, |
1365 // don't consider using current_entry's url for SiteInstance selection, since | 1373 // don't consider using current_entry's url for SiteInstance selection, since |
1366 // current_entry's url is for the main frame and may be in a different site | 1374 // current_entry's url is for the main frame and may be in a different site |
1367 // than this frame. | 1375 // than this frame. |
1368 // TODO(creis): Remove this when we can check the FrameNavigationEntry's url. | 1376 // TODO(creis): Remove this when we can check the FrameNavigationEntry's url. |
1369 // See http://crbug.com/369654 | 1377 // See http://crbug.com/369654 |
1370 if (!frame_tree_node_->IsMainFrame() && | 1378 if (!frame_tree_node_->IsMainFrame() && |
1371 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1379 SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
1372 switches::kSitePerProcess)) | |
1373 return frame_tree_node_->current_url(); | 1380 return frame_tree_node_->current_url(); |
1374 | 1381 |
1375 // If there is no last non-interstitial entry (and current_instance already | 1382 // If there is no last non-interstitial entry (and current_instance already |
1376 // has a site), then we must have been opened from another tab. We want | 1383 // has a site), then we must have been opened from another tab. We want |
1377 // to compare against the URL of the page that opened us, but we can't | 1384 // to compare against the URL of the page that opened us, but we can't |
1378 // get to it directly. The best we can do is check against the site of | 1385 // get to it directly. The best we can do is check against the site of |
1379 // the SiteInstance. This will be correct when we intercept links and | 1386 // the SiteInstance. This will be correct when we intercept links and |
1380 // script-based navigations, but for now, it could place some pages in a | 1387 // script-based navigations, but for now, it could place some pages in a |
1381 // new process unnecessarily. We should only hit this case if a page tries | 1388 // new process unnecessarily. We should only hit this case if a page tries |
1382 // to open a new tab to an interstitial-inducing URL, and then navigates | 1389 // to open a new tab to an interstitial-inducing URL, and then navigates |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 new_instance, pending_web_ui(), create_render_frame_flags, nullptr); | 1423 new_instance, pending_web_ui(), create_render_frame_flags, nullptr); |
1417 } | 1424 } |
1418 | 1425 |
1419 void RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( | 1426 void RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( |
1420 SiteInstance* old_instance, | 1427 SiteInstance* old_instance, |
1421 SiteInstance* new_instance, | 1428 SiteInstance* new_instance, |
1422 int* create_render_frame_flags) { | 1429 int* create_render_frame_flags) { |
1423 // Only create opener proxies if they are in the same BrowsingInstance. | 1430 // Only create opener proxies if they are in the same BrowsingInstance. |
1424 if (new_instance->IsRelatedSiteInstance(old_instance)) | 1431 if (new_instance->IsRelatedSiteInstance(old_instance)) |
1425 CreateOpenerProxiesIfNeeded(new_instance); | 1432 CreateOpenerProxiesIfNeeded(new_instance); |
1426 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1433 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
1427 switches::kSitePerProcess)) { | |
1428 // Ensure that the frame tree has RenderFrameProxyHosts for the new | 1434 // Ensure that the frame tree has RenderFrameProxyHosts for the new |
1429 // SiteInstance in all nodes except the current one. We do this for all | 1435 // SiteInstance in all nodes except the current one. We do this for all |
1430 // frames in the tree, whether they are in the same BrowsingInstance or not. | 1436 // frames in the tree, whether they are in the same BrowsingInstance or not. |
1431 // We will still check whether two frames are in the same BrowsingInstance | 1437 // We will still check whether two frames are in the same BrowsingInstance |
1432 // before we allow them to interact (e.g., postMessage). | 1438 // before we allow them to interact (e.g., postMessage). |
1433 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( | 1439 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( |
1434 frame_tree_node_, new_instance); | 1440 frame_tree_node_, new_instance); |
1435 // RenderFrames in different processes from their parent RenderFrames | 1441 // RenderFrames in different processes from their parent RenderFrames |
1436 // in the frame tree require RenderWidgets for rendering and processing | 1442 // in the frame tree require RenderWidgets for rendering and processing |
1437 // input events. | 1443 // input events. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 return true; | 1521 return true; |
1516 } | 1522 } |
1517 | 1523 |
1518 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( | 1524 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( |
1519 SiteInstance* instance, | 1525 SiteInstance* instance, |
1520 WebUIImpl* web_ui, | 1526 WebUIImpl* web_ui, |
1521 int flags, | 1527 int flags, |
1522 int* view_routing_id_ptr) { | 1528 int* view_routing_id_ptr) { |
1523 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); | 1529 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); |
1524 bool swapped_out_forbidden = IsSwappedOutStateForbidden(); | 1530 bool swapped_out_forbidden = IsSwappedOutStateForbidden(); |
1525 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1526 switches::kSitePerProcess); | |
1527 | 1531 |
1528 CHECK(instance); | 1532 CHECK(instance); |
1529 CHECK_IMPLIES(swapped_out_forbidden, !swapped_out); | 1533 CHECK_IMPLIES(swapped_out_forbidden, !swapped_out); |
1530 CHECK_IMPLIES(!is_site_per_process, frame_tree_node_->IsMainFrame()); | 1534 CHECK_IMPLIES(!SiteIsolationPolicy::AreCrossProcessFramesPossible(), |
| 1535 frame_tree_node_->IsMainFrame()); |
1531 | 1536 |
1532 // Swapped out views should always be hidden. | 1537 // Swapped out views should always be hidden. |
1533 DCHECK_IMPLIES(swapped_out, (flags & CREATE_RF_HIDDEN)); | 1538 DCHECK_IMPLIES(swapped_out, (flags & CREATE_RF_HIDDEN)); |
1534 | 1539 |
1535 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 1540 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
1536 bool success = true; | 1541 bool success = true; |
1537 if (view_routing_id_ptr) | 1542 if (view_routing_id_ptr) |
1538 *view_routing_id_ptr = MSG_ROUTING_NONE; | 1543 *view_routing_id_ptr = MSG_ROUTING_NONE; |
1539 | 1544 |
1540 // We are creating a pending, speculative or swapped out RFH here. We should | 1545 // We are creating a pending, speculative or swapped out RFH here. We should |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 if (!proxy) | 1703 if (!proxy) |
1699 return; | 1704 return; |
1700 | 1705 |
1701 InitRenderView(render_view_host, proxy->GetRoutingID(), false); | 1706 InitRenderView(render_view_host, proxy->GetRoutingID(), false); |
1702 proxy->set_render_frame_proxy_created(true); | 1707 proxy->set_render_frame_proxy_created(true); |
1703 } | 1708 } |
1704 | 1709 |
1705 void RenderFrameHostManager::CreateOuterDelegateProxy( | 1710 void RenderFrameHostManager::CreateOuterDelegateProxy( |
1706 SiteInstance* outer_contents_site_instance, | 1711 SiteInstance* outer_contents_site_instance, |
1707 RenderFrameHostImpl* render_frame_host) { | 1712 RenderFrameHostImpl* render_frame_host) { |
1708 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1713 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); |
1709 switches::kSitePerProcess)); | |
1710 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | 1714 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
1711 outer_contents_site_instance, nullptr, frame_tree_node_); | 1715 outer_contents_site_instance, nullptr, frame_tree_node_); |
1712 proxy_hosts_[outer_contents_site_instance->GetId()] = proxy; | 1716 proxy_hosts_[outer_contents_site_instance->GetId()] = proxy; |
1713 | 1717 |
1714 // Swap the outer WebContents's frame with the proxy to inner WebContents. | 1718 // Swap the outer WebContents's frame with the proxy to inner WebContents. |
1715 // | 1719 // |
1716 // We are in the outer WebContents, and its FrameTree would never see | 1720 // We are in the outer WebContents, and its FrameTree would never see |
1717 // a load start for any of its inner WebContents. Eventually, that also makes | 1721 // a load start for any of its inner WebContents. Eventually, that also makes |
1718 // the FrameTree never see the matching load stop. Therefore, we always pass | 1722 // the FrameTree never see the matching load stop. Therefore, we always pass |
1719 // false to |is_loading| below. | 1723 // false to |is_loading| below. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 // Since the new RenderFrameHost is now committed, there must be no proxies | 1977 // Since the new RenderFrameHost is now committed, there must be no proxies |
1974 // for its SiteInstance. Delete any existing ones. | 1978 // for its SiteInstance. Delete any existing ones. |
1975 RenderFrameProxyHostMap::iterator iter = | 1979 RenderFrameProxyHostMap::iterator iter = |
1976 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()); | 1980 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()); |
1977 if (iter != proxy_hosts_.end()) { | 1981 if (iter != proxy_hosts_.end()) { |
1978 delete iter->second; | 1982 delete iter->second; |
1979 proxy_hosts_.erase(iter); | 1983 proxy_hosts_.erase(iter); |
1980 } | 1984 } |
1981 } | 1985 } |
1982 | 1986 |
1983 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1987 // If this is a subframe, it should have a CrossProcessFrameConnector |
1984 switches::kSitePerProcess)) { | 1988 // created already. Use it to link the new RFH's view to the proxy that |
1985 // If this is a subframe, it should have a CrossProcessFrameConnector | 1989 // belongs to the parent frame's SiteInstance. If this navigation causes |
1986 // created already. Use it to link the new RFH's view to the proxy that | 1990 // an out-of-process frame to return to the same process as its parent, the |
1987 // belongs to the parent frame's SiteInstance. If this navigation causes | 1991 // proxy would have been removed from proxy_hosts_ above. |
1988 // an out-of-process frame to return to the same process as its parent, the | 1992 // Note: We do this after swapping out the old RFH because that may create |
1989 // proxy would have been removed from proxy_hosts_ above. | 1993 // the proxy we're looking for. |
1990 // Note: We do this after swapping out the old RFH because that may create | 1994 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent(); |
1991 // the proxy we're looking for. | 1995 if (proxy_to_parent) { |
1992 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent(); | 1996 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
1993 if (proxy_to_parent) | 1997 proxy_to_parent->SetChildRWHView(render_frame_host_->GetView()); |
1994 proxy_to_parent->SetChildRWHView(render_frame_host_->GetView()); | |
1995 } | 1998 } |
1996 | 1999 |
1997 // After all is done, there must never be a proxy in the list which has the | 2000 // After all is done, there must never be a proxy in the list which has the |
1998 // same SiteInstance as the current RenderFrameHost. | 2001 // same SiteInstance as the current RenderFrameHost. |
1999 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == | 2002 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == |
2000 proxy_hosts_.end()); | 2003 proxy_hosts_.end()); |
2001 } | 2004 } |
2002 | 2005 |
2003 void RenderFrameHostManager::ShutdownProxiesIfLastActiveFrameInSiteInstance( | 2006 void RenderFrameHostManager::ShutdownProxiesIfLastActiveFrameInSiteInstance( |
2004 RenderFrameHostImpl* render_frame_host) { | 2007 RenderFrameHostImpl* render_frame_host) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 SiteInstance* source_instance, | 2048 SiteInstance* source_instance, |
2046 SiteInstance* dest_instance, | 2049 SiteInstance* dest_instance, |
2047 ui::PageTransition transition, | 2050 ui::PageTransition transition, |
2048 bool dest_is_restore, | 2051 bool dest_is_restore, |
2049 bool dest_is_view_source_mode, | 2052 bool dest_is_view_source_mode, |
2050 const GlobalRequestID& transferred_request_id, | 2053 const GlobalRequestID& transferred_request_id, |
2051 int bindings) { | 2054 int bindings) { |
2052 // Don't swap for subframes unless we are in --site-per-process. We can get | 2055 // Don't swap for subframes unless we are in --site-per-process. We can get |
2053 // here in tests for subframes (e.g., NavigateFrameToURL). | 2056 // here in tests for subframes (e.g., NavigateFrameToURL). |
2054 if (!frame_tree_node_->IsMainFrame() && | 2057 if (!frame_tree_node_->IsMainFrame() && |
2055 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 2058 !SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
2056 switches::kSitePerProcess)) | |
2057 return render_frame_host_.get(); | 2059 return render_frame_host_.get(); |
| 2060 } |
2058 | 2061 |
2059 // If we are currently navigating cross-process, we want to get back to normal | 2062 // If we are currently navigating cross-process, we want to get back to normal |
2060 // and then navigate as usual. | 2063 // and then navigate as usual. |
2061 if (pending_render_frame_host_) | 2064 if (pending_render_frame_host_) |
2062 CancelPending(); | 2065 CancelPending(); |
2063 | 2066 |
2064 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 2067 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
2065 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 2068 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
2066 dest_url, source_instance, dest_instance, nullptr, transition, | 2069 dest_url, source_instance, dest_instance, nullptr, transition, |
2067 dest_is_restore, dest_is_view_source_mode); | 2070 dest_is_restore, dest_is_view_source_mode); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2339 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2342 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
2340 if (!frame_tree_node_->opener()) | 2343 if (!frame_tree_node_->opener()) |
2341 return MSG_ROUTING_NONE; | 2344 return MSG_ROUTING_NONE; |
2342 | 2345 |
2343 return frame_tree_node_->opener() | 2346 return frame_tree_node_->opener() |
2344 ->render_manager() | 2347 ->render_manager() |
2345 ->GetRoutingIdForSiteInstance(instance); | 2348 ->GetRoutingIdForSiteInstance(instance); |
2346 } | 2349 } |
2347 | 2350 |
2348 } // namespace content | 2351 } // namespace content |
OLD | NEW |