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 22 matching lines...) Expand all Loading... | |
33 #include "content/common/view_messages.h" | 33 #include "content/common/view_messages.h" |
34 #include "content/public/browser/content_browser_client.h" | 34 #include "content/public/browser/content_browser_client.h" |
35 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
37 #include "content/public/browser/render_widget_host_iterator.h" | 37 #include "content/public/browser/render_widget_host_iterator.h" |
38 #include "content/public/browser/render_widget_host_view.h" | 38 #include "content/public/browser/render_widget_host_view.h" |
39 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
40 #include "content/public/browser/web_ui_controller.h" | 40 #include "content/public/browser/web_ui_controller.h" |
41 #include "content/public/common/content_switches.h" | 41 #include "content/public/common/content_switches.h" |
42 #include "content/public/common/referrer.h" | 42 #include "content/public/common/referrer.h" |
43 #include "content/public/common/site_isolation_policy.h" | |
43 #include "content/public/common/url_constants.h" | 44 #include "content/public/common/url_constants.h" |
44 | 45 |
45 namespace content { | 46 namespace content { |
46 | 47 |
47 // static | 48 // static |
48 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { | 49 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { |
49 node->render_manager()->pending_delete_hosts_.clear(); | 50 node->render_manager()->pending_delete_hosts_.clear(); |
50 return true; | 51 return true; |
51 } | 52 } |
52 | 53 |
53 // static | 54 // static |
54 bool RenderFrameHostManager::IsSwappedOutStateForbidden() { | 55 bool RenderFrameHostManager::IsSwappedOutStateForbidden() { |
55 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 56 return SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
56 switches::kSitePerProcess); | |
57 } | 57 } |
58 | 58 |
59 RenderFrameHostManager::RenderFrameHostManager( | 59 RenderFrameHostManager::RenderFrameHostManager( |
60 FrameTreeNode* frame_tree_node, | 60 FrameTreeNode* frame_tree_node, |
61 RenderFrameHostDelegate* render_frame_delegate, | 61 RenderFrameHostDelegate* render_frame_delegate, |
62 RenderViewHostDelegate* render_view_delegate, | 62 RenderViewHostDelegate* render_view_delegate, |
63 RenderWidgetHostDelegate* render_widget_delegate, | 63 RenderWidgetHostDelegate* render_widget_delegate, |
64 Delegate* delegate) | 64 Delegate* delegate) |
65 : frame_tree_node_(frame_tree_node), | 65 : frame_tree_node_(frame_tree_node), |
66 delegate_(delegate), | 66 delegate_(delegate), |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 // swap are sent to the browser via the OpenURL IPC and are afterwards treated | 795 // swap are sent to the browser via the OpenURL IPC and are afterwards treated |
796 // as browser-initiated navigations. NavigationRequests marked as | 796 // as browser-initiated navigations. NavigationRequests marked as |
797 // renderer-initiated are created by receiving a BeginNavigation IPC, and will | 797 // renderer-initiated are created by receiving a BeginNavigation IPC, and will |
798 // then proceed in the same renderer that sent the IPC due to the condition | 798 // then proceed in the same renderer that sent the IPC due to the condition |
799 // below. | 799 // below. |
800 // Subframe navigations will use the current renderer, unless | 800 // Subframe navigations will use the current renderer, unless |
801 // --site-per-process is enabled. | 801 // --site-per-process is enabled. |
802 // TODO(carlosk): Have renderer-initated main frame navigations swap processes | 802 // TODO(carlosk): Have renderer-initated main frame navigations swap processes |
803 // if needed when it no longer breaks OAuth popups (see | 803 // if needed when it no longer breaks OAuth popups (see |
804 // https://crbug.com/440266). | 804 // https://crbug.com/440266). |
805 bool site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
806 switches::kSitePerProcess); | |
807 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 805 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
808 if (current_site_instance == dest_site_instance.get() || | 806 if (current_site_instance == dest_site_instance.get() || |
809 (!request.browser_initiated() && is_main_frame) || | 807 (!request.browser_initiated() && is_main_frame) || |
810 (!is_main_frame && !site_per_process)) { | 808 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() && |
809 !current_site_instance->RequiresDedicatedProcess())) { | |
811 // Reuse the current RFH if its SiteInstance matches the the navigation's | 810 // Reuse the current RFH if its SiteInstance matches the the navigation's |
812 // or if this is a subframe navigation. We only swap RFHs for subframes when | 811 // or if this is a subframe navigation. We only swap RFHs for subframes when |
813 // --site-per-process is enabled. | 812 // --site-per-process is enabled. |
814 CleanUpNavigation(); | 813 CleanUpNavigation(); |
815 navigation_rfh = render_frame_host_.get(); | 814 navigation_rfh = render_frame_host_.get(); |
816 | 815 |
817 // As SiteInstances are the same, check if the WebUI should be reused. | 816 // As SiteInstances are the same, check if the WebUI should be reused. |
818 const NavigationEntry* current_navigation_entry = | 817 const NavigationEntry* current_navigation_entry = |
819 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 818 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
820 should_reuse_web_ui_ = ShouldReuseWebUI(current_navigation_entry, | 819 should_reuse_web_ui_ = ShouldReuseWebUI(current_navigation_entry, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
914 void RenderFrameHostManager::OnDidStopLoading() { | 913 void RenderFrameHostManager::OnDidStopLoading() { |
915 for (const auto& pair : proxy_hosts_) { | 914 for (const auto& pair : proxy_hosts_) { |
916 pair.second->Send(new FrameMsg_DidStopLoading(pair.second->GetRoutingID())); | 915 pair.second->Send(new FrameMsg_DidStopLoading(pair.second->GetRoutingID())); |
917 } | 916 } |
918 } | 917 } |
919 | 918 |
920 void RenderFrameHostManager::OnDidUpdateName(const std::string& name) { | 919 void RenderFrameHostManager::OnDidUpdateName(const std::string& name) { |
921 // The window.name message may be sent outside of --site-per-process when | 920 // The window.name message may be sent outside of --site-per-process when |
922 // report_frame_name_changes renderer preference is set (used by | 921 // report_frame_name_changes renderer preference is set (used by |
923 // WebView). Don't send the update to proxies in those cases. | 922 // WebView). Don't send the update to proxies in those cases. |
924 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 923 // TODO(nick,nasko): Should this be IsSwappedOutStateForbidden, to match |
Charlie Reis
2015/07/13 22:13:14
That sounds reasonable to me.
ncarter (slow)
2015/07/20 17:45:46
Acknowledged.
| |
925 switches::kSitePerProcess)) | 924 // OnDidUpdateOrigin? |
925 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) | |
926 return; | 926 return; |
927 | 927 |
928 for (const auto& pair : proxy_hosts_) { | 928 for (const auto& pair : proxy_hosts_) { |
929 pair.second->Send( | 929 pair.second->Send( |
930 new FrameMsg_DidUpdateName(pair.second->GetRoutingID(), name)); | 930 new FrameMsg_DidUpdateName(pair.second->GetRoutingID(), name)); |
931 } | 931 } |
932 } | 932 } |
933 | 933 |
934 void RenderFrameHostManager::OnDidUpdateOrigin(const url::Origin& origin) { | 934 void RenderFrameHostManager::OnDidUpdateOrigin(const url::Origin& origin) { |
935 if (!IsSwappedOutStateForbidden()) | 935 if (!IsSwappedOutStateForbidden()) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
998 FrameTreeNode* node) { | 998 FrameTreeNode* node) { |
999 RenderFrameProxyHostMap::iterator iter = | 999 RenderFrameProxyHostMap::iterator iter = |
1000 node->render_manager()->proxy_hosts_.find(site_instance_id); | 1000 node->render_manager()->proxy_hosts_.find(site_instance_id); |
1001 if (iter != node->render_manager()->proxy_hosts_.end()) | 1001 if (iter != node->render_manager()->proxy_hosts_.end()) |
1002 iter->second->set_render_frame_proxy_created(false); | 1002 iter->second->set_render_frame_proxy_created(false); |
1003 | 1003 |
1004 return true; | 1004 return true; |
1005 } | 1005 } |
1006 | 1006 |
1007 bool RenderFrameHostManager::ShouldTransitionCrossSite() { | 1007 bool RenderFrameHostManager::ShouldTransitionCrossSite() { |
1008 // True for --site-per-process, which overrides both kSingleProcess and | 1008 // The logic below is weaker than "are all sites isolated" -- it asks instead, |
1009 // kProcessPerTab. | 1009 // "is any site isolated". That's appropriate here since we're just trying to |
1010 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1010 // figure out if we're in any kind of site isolated mode, and in which case, |
1011 switches::kSitePerProcess)) | 1011 // we ignore the kSingleProcess and kProcessPerTab settings. |
1012 // | |
1013 // TODO(nick): Move all handling of kSingleProcess/kProcessPerTab into | |
1014 // SiteIsolationPolicy so we have a consistent behavior around the interaction | |
1015 // of the process model flags. | |
1016 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) | |
1012 return true; | 1017 return true; |
1013 | 1018 |
1014 // False in the single-process mode, as it makes RVHs to accumulate | 1019 // False in the single-process mode, as it makes RVHs to accumulate |
1015 // in swapped_out_hosts_. | 1020 // in swapped_out_hosts_. |
1016 // True if we are using process-per-site-instance (default) or | 1021 // True if we are using process-per-site-instance (default) or |
1017 // process-per-site (kProcessPerSite). | 1022 // process-per-site (kProcessPerSite). |
1023 // TODO(nick): Move handling of kSingleProcess and kProcessPerTab into | |
1024 // SiteIsolationPolicy. | |
1018 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1025 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1019 switches::kSingleProcess) && | 1026 switches::kSingleProcess) && |
1020 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1027 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1021 switches::kProcessPerTab); | 1028 switches::kProcessPerTab); |
1022 } | 1029 } |
1023 | 1030 |
1024 bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( | 1031 bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( |
1025 const GURL& current_effective_url, | 1032 const GURL& current_effective_url, |
1026 bool current_is_view_source_mode, | 1033 bool current_is_view_source_mode, |
1027 SiteInstance* new_site_instance, | 1034 SiteInstance* new_site_instance, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1352 | 1359 |
1353 const GURL& RenderFrameHostManager::GetCurrentURLForSiteInstance( | 1360 const GURL& RenderFrameHostManager::GetCurrentURLForSiteInstance( |
1354 SiteInstance* current_instance, NavigationEntry* current_entry) { | 1361 SiteInstance* current_instance, NavigationEntry* current_entry) { |
1355 // If this is a subframe that is potentially out of process from its parent, | 1362 // If this is a subframe that is potentially out of process from its parent, |
1356 // don't consider using current_entry's url for SiteInstance selection, since | 1363 // don't consider using current_entry's url for SiteInstance selection, since |
1357 // current_entry's url is for the main frame and may be in a different site | 1364 // current_entry's url is for the main frame and may be in a different site |
1358 // than this frame. | 1365 // than this frame. |
1359 // TODO(creis): Remove this when we can check the FrameNavigationEntry's url. | 1366 // TODO(creis): Remove this when we can check the FrameNavigationEntry's url. |
1360 // See http://crbug.com/369654 | 1367 // See http://crbug.com/369654 |
1361 if (!frame_tree_node_->IsMainFrame() && | 1368 if (!frame_tree_node_->IsMainFrame() && |
1362 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1369 SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
1363 switches::kSitePerProcess)) | |
1364 return frame_tree_node_->current_url(); | 1370 return frame_tree_node_->current_url(); |
1365 | 1371 |
1366 // If there is no last non-interstitial entry (and current_instance already | 1372 // If there is no last non-interstitial entry (and current_instance already |
1367 // has a site), then we must have been opened from another tab. We want | 1373 // has a site), then we must have been opened from another tab. We want |
1368 // to compare against the URL of the page that opened us, but we can't | 1374 // to compare against the URL of the page that opened us, but we can't |
1369 // get to it directly. The best we can do is check against the site of | 1375 // get to it directly. The best we can do is check against the site of |
1370 // the SiteInstance. This will be correct when we intercept links and | 1376 // the SiteInstance. This will be correct when we intercept links and |
1371 // script-based navigations, but for now, it could place some pages in a | 1377 // script-based navigations, but for now, it could place some pages in a |
1372 // new process unnecessarily. We should only hit this case if a page tries | 1378 // new process unnecessarily. We should only hit this case if a page tries |
1373 // to open a new tab to an interstitial-inducing URL, and then navigates | 1379 // to open a new tab to an interstitial-inducing URL, and then navigates |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1409 } | 1415 } |
1410 | 1416 |
1411 int RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( | 1417 int RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( |
1412 SiteInstance* old_instance, | 1418 SiteInstance* old_instance, |
1413 SiteInstance* new_instance, | 1419 SiteInstance* new_instance, |
1414 int* create_render_frame_flags) { | 1420 int* create_render_frame_flags) { |
1415 int opener_route_id = MSG_ROUTING_NONE; | 1421 int opener_route_id = MSG_ROUTING_NONE; |
1416 // Only create opener proxies if they are in the same BrowsingInstance. | 1422 // Only create opener proxies if they are in the same BrowsingInstance. |
1417 if (new_instance->IsRelatedSiteInstance(old_instance)) | 1423 if (new_instance->IsRelatedSiteInstance(old_instance)) |
1418 opener_route_id = CreateOpenerProxiesIfNeeded(new_instance); | 1424 opener_route_id = CreateOpenerProxiesIfNeeded(new_instance); |
1419 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1425 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
1420 switches::kSitePerProcess)) { | |
1421 // Ensure that the frame tree has RenderFrameProxyHosts for the new | 1426 // Ensure that the frame tree has RenderFrameProxyHosts for the new |
1422 // SiteInstance in all nodes except the current one. We do this for all | 1427 // SiteInstance in all nodes except the current one. We do this for all |
1423 // frames in the tree, whether they are in the same BrowsingInstance or not. | 1428 // frames in the tree, whether they are in the same BrowsingInstance or not. |
1424 // We will still check whether two frames are in the same BrowsingInstance | 1429 // We will still check whether two frames are in the same BrowsingInstance |
1425 // before we allow them to interact (e.g., postMessage). | 1430 // before we allow them to interact (e.g., postMessage). |
1426 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( | 1431 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( |
1427 frame_tree_node_, new_instance); | 1432 frame_tree_node_, new_instance); |
1428 // RenderFrames in different processes from their parent RenderFrames | 1433 // RenderFrames in different processes from their parent RenderFrames |
1429 // in the frame tree require RenderWidgets for rendering and processing | 1434 // in the frame tree require RenderWidgets for rendering and processing |
1430 // input events. | 1435 // input events. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1510 } | 1515 } |
1511 | 1516 |
1512 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( | 1517 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( |
1513 SiteInstance* instance, | 1518 SiteInstance* instance, |
1514 WebUIImpl* web_ui, | 1519 WebUIImpl* web_ui, |
1515 int opener_route_id, | 1520 int opener_route_id, |
1516 int flags, | 1521 int flags, |
1517 int* view_routing_id_ptr) { | 1522 int* view_routing_id_ptr) { |
1518 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); | 1523 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); |
1519 bool swapped_out_forbidden = IsSwappedOutStateForbidden(); | 1524 bool swapped_out_forbidden = IsSwappedOutStateForbidden(); |
1520 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1521 switches::kSitePerProcess); | |
1522 | 1525 |
1523 CHECK(instance); | 1526 CHECK(instance); |
1524 CHECK_IMPLIES(swapped_out_forbidden, !swapped_out); | 1527 CHECK_IMPLIES(swapped_out_forbidden, !swapped_out); |
1525 CHECK_IMPLIES(!is_site_per_process, frame_tree_node_->IsMainFrame()); | 1528 CHECK_IMPLIES(!SiteIsolationPolicy::AreCrossProcessFramesPossible(), |
1529 frame_tree_node_->IsMainFrame()); | |
1526 | 1530 |
1527 // Swapped out views should always be hidden. | 1531 // Swapped out views should always be hidden. |
1528 DCHECK_IMPLIES(swapped_out, (flags & CREATE_RF_HIDDEN)); | 1532 DCHECK_IMPLIES(swapped_out, (flags & CREATE_RF_HIDDEN)); |
1529 | 1533 |
1530 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 1534 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
1531 bool success = true; | 1535 bool success = true; |
1532 if (view_routing_id_ptr) | 1536 if (view_routing_id_ptr) |
1533 *view_routing_id_ptr = MSG_ROUTING_NONE; | 1537 *view_routing_id_ptr = MSG_ROUTING_NONE; |
1534 | 1538 |
1535 // We are creating a pending, speculative or swapped out RFH here. We should | 1539 // We are creating a pending, speculative or swapped out RFH here. We should |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1696 return; | 1700 return; |
1697 | 1701 |
1698 InitRenderView(render_view_host, opener_route_id, proxy->GetRoutingID(), | 1702 InitRenderView(render_view_host, opener_route_id, proxy->GetRoutingID(), |
1699 false); | 1703 false); |
1700 proxy->set_render_frame_proxy_created(true); | 1704 proxy->set_render_frame_proxy_created(true); |
1701 } | 1705 } |
1702 | 1706 |
1703 void RenderFrameHostManager::CreateOuterDelegateProxy( | 1707 void RenderFrameHostManager::CreateOuterDelegateProxy( |
1704 SiteInstance* outer_contents_site_instance, | 1708 SiteInstance* outer_contents_site_instance, |
1705 RenderFrameHostImpl* render_frame_host) { | 1709 RenderFrameHostImpl* render_frame_host) { |
1706 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1710 CHECK(SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames()); |
1707 switches::kSitePerProcess)); | |
1708 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | 1711 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
1709 outer_contents_site_instance, nullptr, frame_tree_node_); | 1712 outer_contents_site_instance, nullptr, frame_tree_node_); |
1710 proxy_hosts_[outer_contents_site_instance->GetId()] = proxy; | 1713 proxy_hosts_[outer_contents_site_instance->GetId()] = proxy; |
1711 | 1714 |
1712 // Swap the outer WebContents's frame with the proxy to inner WebContents. | 1715 // Swap the outer WebContents's frame with the proxy to inner WebContents. |
1713 // | 1716 // |
1714 // We are in the outer WebContents, and its FrameTree would never see | 1717 // We are in the outer WebContents, and its FrameTree would never see |
1715 // a load start for any of its inner WebContents. Eventually, that also makes | 1718 // a load start for any of its inner WebContents. Eventually, that also makes |
1716 // the FrameTree never see the matching load stop. Therefore, we always pass | 1719 // the FrameTree never see the matching load stop. Therefore, we always pass |
1717 // false to |is_loading| below. | 1720 // false to |is_loading| below. |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1965 // Since the new RenderFrameHost is now committed, there must be no proxies | 1968 // Since the new RenderFrameHost is now committed, there must be no proxies |
1966 // for its SiteInstance. Delete any existing ones. | 1969 // for its SiteInstance. Delete any existing ones. |
1967 RenderFrameProxyHostMap::iterator iter = | 1970 RenderFrameProxyHostMap::iterator iter = |
1968 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()); | 1971 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()); |
1969 if (iter != proxy_hosts_.end()) { | 1972 if (iter != proxy_hosts_.end()) { |
1970 delete iter->second; | 1973 delete iter->second; |
1971 proxy_hosts_.erase(iter); | 1974 proxy_hosts_.erase(iter); |
1972 } | 1975 } |
1973 } | 1976 } |
1974 | 1977 |
1975 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1978 // If this is a subframe, it should have a CrossProcessFrameConnector |
1976 switches::kSitePerProcess)) { | 1979 // created already. Use it to link the new RFH's view to the proxy that |
1977 // If this is a subframe, it should have a CrossProcessFrameConnector | 1980 // belongs to the parent frame's SiteInstance. If this navigation causes |
1978 // created already. Use it to link the new RFH's view to the proxy that | 1981 // an out-of-process frame to return to the same process as its parent, the |
1979 // belongs to the parent frame's SiteInstance. If this navigation causes | 1982 // proxy would have been removed from proxy_hosts_ above. |
1980 // an out-of-process frame to return to the same process as its parent, the | 1983 // Note: We do this after swapping out the old RFH because that may create |
1981 // proxy would have been removed from proxy_hosts_ above. | 1984 // the proxy we're looking for. |
1982 // Note: We do this after swapping out the old RFH because that may create | 1985 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent(); |
1983 // the proxy we're looking for. | 1986 if (proxy_to_parent) { |
1984 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent(); | 1987 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
1985 if (proxy_to_parent) | 1988 proxy_to_parent->SetChildRWHView(render_frame_host_->GetView()); |
1986 proxy_to_parent->SetChildRWHView(render_frame_host_->GetView()); | |
1987 } | 1989 } |
1988 | 1990 |
1989 // After all is done, there must never be a proxy in the list which has the | 1991 // After all is done, there must never be a proxy in the list which has the |
1990 // same SiteInstance as the current RenderFrameHost. | 1992 // same SiteInstance as the current RenderFrameHost. |
1991 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == | 1993 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == |
1992 proxy_hosts_.end()); | 1994 proxy_hosts_.end()); |
1993 } | 1995 } |
1994 | 1996 |
1995 void RenderFrameHostManager::ShutdownProxiesIfLastActiveFrameInSiteInstance( | 1997 void RenderFrameHostManager::ShutdownProxiesIfLastActiveFrameInSiteInstance( |
1996 RenderFrameHostImpl* render_frame_host) { | 1998 RenderFrameHostImpl* render_frame_host) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2037 SiteInstance* source_instance, | 2039 SiteInstance* source_instance, |
2038 SiteInstance* dest_instance, | 2040 SiteInstance* dest_instance, |
2039 ui::PageTransition transition, | 2041 ui::PageTransition transition, |
2040 bool dest_is_restore, | 2042 bool dest_is_restore, |
2041 bool dest_is_view_source_mode, | 2043 bool dest_is_view_source_mode, |
2042 const GlobalRequestID& transferred_request_id, | 2044 const GlobalRequestID& transferred_request_id, |
2043 int bindings) { | 2045 int bindings) { |
2044 // Don't swap for subframes unless we are in --site-per-process. We can get | 2046 // Don't swap for subframes unless we are in --site-per-process. We can get |
2045 // here in tests for subframes (e.g., NavigateFrameToURL). | 2047 // here in tests for subframes (e.g., NavigateFrameToURL). |
2046 if (!frame_tree_node_->IsMainFrame() && | 2048 if (!frame_tree_node_->IsMainFrame() && |
2047 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 2049 !SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
2048 switches::kSitePerProcess)) | |
2049 return render_frame_host_.get(); | 2050 return render_frame_host_.get(); |
2051 } | |
2050 | 2052 |
2051 // If we are currently navigating cross-process, we want to get back to normal | 2053 // If we are currently navigating cross-process, we want to get back to normal |
2052 // and then navigate as usual. | 2054 // and then navigate as usual. |
2053 if (pending_render_frame_host_) | 2055 if (pending_render_frame_host_) |
2054 CancelPending(); | 2056 CancelPending(); |
2055 | 2057 |
2056 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 2058 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
2057 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 2059 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
2058 dest_url, source_instance, dest_instance, nullptr, transition, | 2060 dest_url, source_instance, dest_instance, nullptr, transition, |
2059 dest_is_restore, dest_is_view_source_mode); | 2061 dest_is_restore, dest_is_view_source_mode); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2299 // If any of the RenderViews (current, pending, or swapped out) for this | 2301 // If any of the RenderViews (current, pending, or swapped out) for this |
2300 // FrameTree has the same SiteInstance, use it. If such a RenderView exists, | 2302 // FrameTree has the same SiteInstance, use it. If such a RenderView exists, |
2301 // that implies that proxies for all nodes in the tree should also exist | 2303 // that implies that proxies for all nodes in the tree should also exist |
2302 // (when in site-per-process mode), so it is safe to exit early. | 2304 // (when in site-per-process mode), so it is safe to exit early. |
2303 FrameTree* frame_tree = frame_tree_node_->frame_tree(); | 2305 FrameTree* frame_tree = frame_tree_node_->frame_tree(); |
2304 RenderViewHostImpl* rvh = frame_tree->GetRenderViewHost(instance); | 2306 RenderViewHostImpl* rvh = frame_tree->GetRenderViewHost(instance); |
2305 if (rvh && rvh->IsRenderViewLive()) | 2307 if (rvh && rvh->IsRenderViewLive()) |
2306 return rvh->GetRoutingID(); | 2308 return rvh->GetRoutingID(); |
2307 | 2309 |
2308 int render_view_routing_id = MSG_ROUTING_NONE; | 2310 int render_view_routing_id = MSG_ROUTING_NONE; |
2309 if (RenderFrameHostManager::IsSwappedOutStateForbidden()) { | 2311 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
2310 // Ensure that all the nodes in the opener's frame tree have | 2312 // Ensure that all the nodes in the opener's frame tree have |
2311 // RenderFrameProxyHosts for the new SiteInstance. | 2313 // RenderFrameProxyHosts for the new SiteInstance. |
2312 frame_tree->CreateProxiesForSiteInstance(nullptr, instance); | 2314 frame_tree->CreateProxiesForSiteInstance(nullptr, instance); |
2313 rvh = frame_tree->GetRenderViewHost(instance); | 2315 rvh = frame_tree->GetRenderViewHost(instance); |
2314 render_view_routing_id = rvh->GetRoutingID(); | 2316 render_view_routing_id = rvh->GetRoutingID(); |
2315 } else if (rvh && !rvh->IsRenderViewLive()) { | 2317 } else if (rvh && !rvh->IsRenderViewLive()) { |
2316 EnsureRenderViewInitialized(rvh, instance); | 2318 EnsureRenderViewInitialized(rvh, instance); |
2317 render_view_routing_id = rvh->GetRoutingID(); | 2319 render_view_routing_id = rvh->GetRoutingID(); |
2318 } else { | 2320 } else { |
2319 // Create a swapped out RenderView in the given SiteInstance if none exists, | 2321 // Create a swapped out RenderView in the given SiteInstance if none exists, |
2320 // setting its opener to the given route_id. Since the opener can point to | 2322 // setting its opener to the given route_id. Since the opener can point to |
2321 // a subframe, do this on the root frame of the opener's frame tree. | 2323 // a subframe, do this on the root frame of the opener's frame tree. |
2322 // Return the new view's route_id. | 2324 // Return the new view's route_id. |
2323 frame_tree->root()->render_manager()-> | 2325 frame_tree->root()->render_manager()-> |
2324 CreateRenderFrame(instance, nullptr, opener_route_id, | 2326 CreateRenderFrame(instance, nullptr, opener_route_id, |
2325 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION | | 2327 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION | |
2326 CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, | 2328 CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, |
2327 &render_view_routing_id); | 2329 &render_view_routing_id); |
2328 } | 2330 } |
2329 return render_view_routing_id; | 2331 return render_view_routing_id; |
2330 } | 2332 } |
2331 | 2333 |
2332 } // namespace content | 2334 } // namespace content |
OLD | NEW |