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 <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/browser/frame_host/render_frame_host_factory.h" | 24 #include "content/browser/frame_host/render_frame_host_factory.h" |
25 #include "content/browser/frame_host/render_frame_host_impl.h" | 25 #include "content/browser/frame_host/render_frame_host_impl.h" |
26 #include "content/browser/frame_host/render_frame_proxy_host.h" | 26 #include "content/browser/frame_host/render_frame_proxy_host.h" |
27 #include "content/browser/renderer_host/render_process_host_impl.h" | 27 #include "content/browser/renderer_host/render_process_host_impl.h" |
28 #include "content/browser/renderer_host/render_view_host_factory.h" | 28 #include "content/browser/renderer_host/render_view_host_factory.h" |
29 #include "content/browser/renderer_host/render_view_host_impl.h" | 29 #include "content/browser/renderer_host/render_view_host_impl.h" |
30 #include "content/browser/site_instance_impl.h" | 30 #include "content/browser/site_instance_impl.h" |
31 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 31 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
32 #include "content/browser/webui/web_ui_impl.h" | 32 #include "content/browser/webui/web_ui_impl.h" |
33 #include "content/common/frame_messages.h" | 33 #include "content/common/frame_messages.h" |
| 34 #include "content/common/site_isolation_policy.h" |
34 #include "content/common/view_messages.h" | 35 #include "content/common/view_messages.h" |
35 #include "content/public/browser/content_browser_client.h" | 36 #include "content/public/browser/content_browser_client.h" |
36 #include "content/public/browser/render_process_host_observer.h" | 37 #include "content/public/browser/render_process_host_observer.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 // A helper class to hold all frame proxies and register as a | 49 // A helper class to hold all frame proxies and register as a |
48 // RenderProcessHostObserver for them. | 50 // RenderProcessHostObserver for them. |
49 class RenderFrameHostManager::RenderFrameProxyHostMap | 51 class RenderFrameHostManager::RenderFrameProxyHostMap |
50 : public RenderProcessHostObserver { | 52 : public RenderProcessHostObserver { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 163 } |
162 | 164 |
163 // static | 165 // static |
164 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { | 166 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { |
165 node->render_manager()->pending_delete_hosts_.clear(); | 167 node->render_manager()->pending_delete_hosts_.clear(); |
166 return true; | 168 return true; |
167 } | 169 } |
168 | 170 |
169 // static | 171 // static |
170 bool RenderFrameHostManager::IsSwappedOutStateForbidden() { | 172 bool RenderFrameHostManager::IsSwappedOutStateForbidden() { |
171 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 173 return SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
172 switches::kSitePerProcess); | |
173 } | 174 } |
174 | 175 |
175 RenderFrameHostManager::RenderFrameHostManager( | 176 RenderFrameHostManager::RenderFrameHostManager( |
176 FrameTreeNode* frame_tree_node, | 177 FrameTreeNode* frame_tree_node, |
177 RenderFrameHostDelegate* render_frame_delegate, | 178 RenderFrameHostDelegate* render_frame_delegate, |
178 RenderViewHostDelegate* render_view_delegate, | 179 RenderViewHostDelegate* render_view_delegate, |
179 RenderWidgetHostDelegate* render_widget_delegate, | 180 RenderWidgetHostDelegate* render_widget_delegate, |
180 Delegate* delegate) | 181 Delegate* delegate) |
181 : frame_tree_node_(frame_tree_node), | 182 : frame_tree_node_(frame_tree_node), |
182 delegate_(delegate), | 183 delegate_(delegate), |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 // swap are sent to the browser via the OpenURL IPC and are afterwards treated | 902 // swap are sent to the browser via the OpenURL IPC and are afterwards treated |
902 // as browser-initiated navigations. NavigationRequests marked as | 903 // as browser-initiated navigations. NavigationRequests marked as |
903 // renderer-initiated are created by receiving a BeginNavigation IPC, and will | 904 // renderer-initiated are created by receiving a BeginNavigation IPC, and will |
904 // then proceed in the same renderer that sent the IPC due to the condition | 905 // then proceed in the same renderer that sent the IPC due to the condition |
905 // below. | 906 // below. |
906 // Subframe navigations will use the current renderer, unless | 907 // Subframe navigations will use the current renderer, unless |
907 // --site-per-process is enabled. | 908 // --site-per-process is enabled. |
908 // TODO(carlosk): Have renderer-initated main frame navigations swap processes | 909 // TODO(carlosk): Have renderer-initated main frame navigations swap processes |
909 // if needed when it no longer breaks OAuth popups (see | 910 // if needed when it no longer breaks OAuth popups (see |
910 // https://crbug.com/440266). | 911 // https://crbug.com/440266). |
911 bool site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
912 switches::kSitePerProcess); | |
913 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 912 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
914 if (current_site_instance == dest_site_instance.get() || | 913 if (current_site_instance == dest_site_instance.get() || |
915 (!request.browser_initiated() && is_main_frame) || | 914 (!request.browser_initiated() && is_main_frame) || |
916 (!is_main_frame && !site_per_process)) { | 915 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() && |
| 916 !current_site_instance->RequiresDedicatedProcess())) { |
917 // Reuse the current RFH if its SiteInstance matches the the navigation's | 917 // Reuse the current RFH if its SiteInstance matches the the navigation's |
918 // or if this is a subframe navigation. We only swap RFHs for subframes when | 918 // or if this is a subframe navigation. We only swap RFHs for subframes when |
919 // --site-per-process is enabled. | 919 // --site-per-process is enabled. |
920 CleanUpNavigation(); | 920 CleanUpNavigation(); |
921 navigation_rfh = render_frame_host_.get(); | 921 navigation_rfh = render_frame_host_.get(); |
922 | 922 |
923 // As SiteInstances are the same, check if the WebUI should be reused. | 923 // As SiteInstances are the same, check if the WebUI should be reused. |
924 const NavigationEntry* current_navigation_entry = | 924 const NavigationEntry* current_navigation_entry = |
925 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 925 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
926 should_reuse_web_ui_ = ShouldReuseWebUI(current_navigation_entry, | 926 should_reuse_web_ui_ = ShouldReuseWebUI(current_navigation_entry, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 void RenderFrameHostManager::OnDidStopLoading() { | 1019 void RenderFrameHostManager::OnDidStopLoading() { |
1020 for (const auto& pair : *proxy_hosts_) { | 1020 for (const auto& pair : *proxy_hosts_) { |
1021 pair.second->Send(new FrameMsg_DidStopLoading(pair.second->GetRoutingID())); | 1021 pair.second->Send(new FrameMsg_DidStopLoading(pair.second->GetRoutingID())); |
1022 } | 1022 } |
1023 } | 1023 } |
1024 | 1024 |
1025 void RenderFrameHostManager::OnDidUpdateName(const std::string& name) { | 1025 void RenderFrameHostManager::OnDidUpdateName(const std::string& name) { |
1026 // The window.name message may be sent outside of --site-per-process when | 1026 // The window.name message may be sent outside of --site-per-process when |
1027 // report_frame_name_changes renderer preference is set (used by | 1027 // report_frame_name_changes renderer preference is set (used by |
1028 // WebView). Don't send the update to proxies in those cases. | 1028 // WebView). Don't send the update to proxies in those cases. |
1029 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1029 // TODO(nick,nasko): Should this be IsSwappedOutStateForbidden, to match |
1030 switches::kSitePerProcess)) | 1030 // OnDidUpdateOrigin? |
| 1031 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
1031 return; | 1032 return; |
1032 | 1033 |
1033 for (const auto& pair : *proxy_hosts_) { | 1034 for (const auto& pair : *proxy_hosts_) { |
1034 pair.second->Send( | 1035 pair.second->Send( |
1035 new FrameMsg_DidUpdateName(pair.second->GetRoutingID(), name)); | 1036 new FrameMsg_DidUpdateName(pair.second->GetRoutingID(), name)); |
1036 } | 1037 } |
1037 } | 1038 } |
1038 | 1039 |
1039 void RenderFrameHostManager::OnDidUpdateOrigin(const url::Origin& origin) { | 1040 void RenderFrameHostManager::OnDidUpdateOrigin(const url::Origin& origin) { |
1040 if (!IsSwappedOutStateForbidden()) | 1041 if (!IsSwappedOutStateForbidden()) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 FrameTreeNode* node) { | 1086 FrameTreeNode* node) { |
1086 RenderFrameProxyHost* proxy = | 1087 RenderFrameProxyHost* proxy = |
1087 node->render_manager()->proxy_hosts_->Get(site_instance_id); | 1088 node->render_manager()->proxy_hosts_->Get(site_instance_id); |
1088 if (proxy) | 1089 if (proxy) |
1089 proxy->set_render_frame_proxy_created(false); | 1090 proxy->set_render_frame_proxy_created(false); |
1090 | 1091 |
1091 return true; | 1092 return true; |
1092 } | 1093 } |
1093 | 1094 |
1094 bool RenderFrameHostManager::ShouldTransitionCrossSite() { | 1095 bool RenderFrameHostManager::ShouldTransitionCrossSite() { |
1095 // True for --site-per-process, which overrides both kSingleProcess and | 1096 // The logic below is weaker than "are all sites isolated" -- it asks instead, |
1096 // kProcessPerTab. | 1097 // "is any site isolated". That's appropriate here since we're just trying to |
1097 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1098 // figure out if we're in any kind of site isolated mode, and in which case, |
1098 switches::kSitePerProcess)) | 1099 // we ignore the kSingleProcess and kProcessPerTab settings. |
| 1100 // |
| 1101 // TODO(nick): Move all handling of kSingleProcess/kProcessPerTab into |
| 1102 // SiteIsolationPolicy so we have a consistent behavior around the interaction |
| 1103 // of the process model flags. |
| 1104 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
1099 return true; | 1105 return true; |
1100 | 1106 |
1101 // False in the single-process mode, as it makes RVHs to accumulate | 1107 // False in the single-process mode, as it makes RVHs to accumulate |
1102 // in swapped_out_hosts_. | 1108 // in swapped_out_hosts_. |
1103 // True if we are using process-per-site-instance (default) or | 1109 // True if we are using process-per-site-instance (default) or |
1104 // process-per-site (kProcessPerSite). | 1110 // process-per-site (kProcessPerSite). |
| 1111 // TODO(nick): Move handling of kSingleProcess and kProcessPerTab into |
| 1112 // SiteIsolationPolicy. |
1105 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1113 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1106 switches::kSingleProcess) && | 1114 switches::kSingleProcess) && |
1107 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1115 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1108 switches::kProcessPerTab); | 1116 switches::kProcessPerTab); |
1109 } | 1117 } |
1110 | 1118 |
1111 bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( | 1119 bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation( |
1112 const GURL& current_effective_url, | 1120 const GURL& current_effective_url, |
1113 bool current_is_view_source_mode, | 1121 bool current_is_view_source_mode, |
1114 SiteInstance* new_site_instance, | 1122 SiteInstance* new_site_instance, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 | 1447 |
1440 const GURL& RenderFrameHostManager::GetCurrentURLForSiteInstance( | 1448 const GURL& RenderFrameHostManager::GetCurrentURLForSiteInstance( |
1441 SiteInstance* current_instance, NavigationEntry* current_entry) { | 1449 SiteInstance* current_instance, NavigationEntry* current_entry) { |
1442 // If this is a subframe that is potentially out of process from its parent, | 1450 // If this is a subframe that is potentially out of process from its parent, |
1443 // don't consider using current_entry's url for SiteInstance selection, since | 1451 // don't consider using current_entry's url for SiteInstance selection, since |
1444 // current_entry's url is for the main frame and may be in a different site | 1452 // current_entry's url is for the main frame and may be in a different site |
1445 // than this frame. | 1453 // than this frame. |
1446 // TODO(creis): Remove this when we can check the FrameNavigationEntry's url. | 1454 // TODO(creis): Remove this when we can check the FrameNavigationEntry's url. |
1447 // See http://crbug.com/369654 | 1455 // See http://crbug.com/369654 |
1448 if (!frame_tree_node_->IsMainFrame() && | 1456 if (!frame_tree_node_->IsMainFrame() && |
1449 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1457 SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
1450 switches::kSitePerProcess)) | |
1451 return frame_tree_node_->current_url(); | 1458 return frame_tree_node_->current_url(); |
1452 | 1459 |
1453 // If there is no last non-interstitial entry (and current_instance already | 1460 // If there is no last non-interstitial entry (and current_instance already |
1454 // has a site), then we must have been opened from another tab. We want | 1461 // has a site), then we must have been opened from another tab. We want |
1455 // to compare against the URL of the page that opened us, but we can't | 1462 // to compare against the URL of the page that opened us, but we can't |
1456 // get to it directly. The best we can do is check against the site of | 1463 // get to it directly. The best we can do is check against the site of |
1457 // the SiteInstance. This will be correct when we intercept links and | 1464 // the SiteInstance. This will be correct when we intercept links and |
1458 // script-based navigations, but for now, it could place some pages in a | 1465 // script-based navigations, but for now, it could place some pages in a |
1459 // new process unnecessarily. We should only hit this case if a page tries | 1466 // new process unnecessarily. We should only hit this case if a page tries |
1460 // to open a new tab to an interstitial-inducing URL, and then navigates | 1467 // 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... |
1494 new_instance, pending_web_ui(), create_render_frame_flags, nullptr); | 1501 new_instance, pending_web_ui(), create_render_frame_flags, nullptr); |
1495 } | 1502 } |
1496 | 1503 |
1497 void RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( | 1504 void RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( |
1498 SiteInstance* old_instance, | 1505 SiteInstance* old_instance, |
1499 SiteInstance* new_instance, | 1506 SiteInstance* new_instance, |
1500 int* create_render_frame_flags) { | 1507 int* create_render_frame_flags) { |
1501 // Only create opener proxies if they are in the same BrowsingInstance. | 1508 // Only create opener proxies if they are in the same BrowsingInstance. |
1502 if (new_instance->IsRelatedSiteInstance(old_instance)) | 1509 if (new_instance->IsRelatedSiteInstance(old_instance)) |
1503 CreateOpenerProxiesIfNeeded(new_instance); | 1510 CreateOpenerProxiesIfNeeded(new_instance); |
1504 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1511 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
1505 switches::kSitePerProcess)) { | |
1506 // Ensure that the frame tree has RenderFrameProxyHosts for the new | 1512 // Ensure that the frame tree has RenderFrameProxyHosts for the new |
1507 // SiteInstance in all nodes except the current one. We do this for all | 1513 // SiteInstance in all nodes except the current one. We do this for all |
1508 // frames in the tree, whether they are in the same BrowsingInstance or not. | 1514 // frames in the tree, whether they are in the same BrowsingInstance or not. |
1509 // We will still check whether two frames are in the same BrowsingInstance | 1515 // We will still check whether two frames are in the same BrowsingInstance |
1510 // before we allow them to interact (e.g., postMessage). | 1516 // before we allow them to interact (e.g., postMessage). |
1511 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( | 1517 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( |
1512 frame_tree_node_, new_instance); | 1518 frame_tree_node_, new_instance); |
1513 // RenderFrames in different processes from their parent RenderFrames | 1519 // RenderFrames in different processes from their parent RenderFrames |
1514 // in the frame tree require RenderWidgets for rendering and processing | 1520 // in the frame tree require RenderWidgets for rendering and processing |
1515 // input events. | 1521 // input events. |
1516 if (frame_tree_node_->parent() && | 1522 if (frame_tree_node_->parent() && |
1517 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance() != | 1523 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance() != |
1518 new_instance) | 1524 new_instance) |
1519 *create_render_frame_flags |= CREATE_RF_NEEDS_RENDER_WIDGET_HOST; | 1525 *create_render_frame_flags |= CREATE_RF_NEEDS_RENDER_WIDGET_HOST; |
1520 } | 1526 } |
1521 } | 1527 } |
1522 | 1528 |
1523 void RenderFrameHostManager::CreateProxiesForNewNamedFrame() { | 1529 void RenderFrameHostManager::CreateProxiesForNewNamedFrame() { |
1524 // TODO(alexmos): use SiteIsolationPolicy::AreCrossProcessFramesPossible once | 1530 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
1525 // https://codereview.chromium.org/1208143002/ lands. | |
1526 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1527 switches::kSitePerProcess)) | |
1528 return; | 1531 return; |
1529 | 1532 |
1530 DCHECK(!frame_tree_node_->frame_name().empty()); | 1533 DCHECK(!frame_tree_node_->frame_name().empty()); |
1531 | 1534 |
1532 // If this is a top-level frame, create proxies for this node in the | 1535 // If this is a top-level frame, create proxies for this node in the |
1533 // SiteInstances of its opener's ancestors, which are allowed to discover | 1536 // SiteInstances of its opener's ancestors, which are allowed to discover |
1534 // this frame by name (see https://crbug.com/511474 and part 4 of | 1537 // this frame by name (see https://crbug.com/511474 and part 4 of |
1535 // https://html.spec.whatwg.org/#the-rules-for-choosing-a-browsing-context- | 1538 // https://html.spec.whatwg.org/#the-rules-for-choosing-a-browsing-context- |
1536 // given-a-browsing-context-name). | 1539 // given-a-browsing-context-name). |
1537 FrameTreeNode* opener = frame_tree_node_->opener(); | 1540 FrameTreeNode* opener = frame_tree_node_->opener(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 return true; | 1627 return true; |
1625 } | 1628 } |
1626 | 1629 |
1627 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( | 1630 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( |
1628 SiteInstance* instance, | 1631 SiteInstance* instance, |
1629 WebUIImpl* web_ui, | 1632 WebUIImpl* web_ui, |
1630 int flags, | 1633 int flags, |
1631 int* view_routing_id_ptr) { | 1634 int* view_routing_id_ptr) { |
1632 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); | 1635 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); |
1633 bool swapped_out_forbidden = IsSwappedOutStateForbidden(); | 1636 bool swapped_out_forbidden = IsSwappedOutStateForbidden(); |
1634 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1635 switches::kSitePerProcess); | |
1636 | 1637 |
1637 CHECK(instance); | 1638 CHECK(instance); |
1638 CHECK_IMPLIES(swapped_out_forbidden, !swapped_out); | 1639 CHECK_IMPLIES(swapped_out_forbidden, !swapped_out); |
1639 CHECK_IMPLIES(!is_site_per_process, frame_tree_node_->IsMainFrame()); | 1640 CHECK_IMPLIES(!SiteIsolationPolicy::AreCrossProcessFramesPossible(), |
| 1641 frame_tree_node_->IsMainFrame()); |
1640 | 1642 |
1641 // Swapped out views should always be hidden. | 1643 // Swapped out views should always be hidden. |
1642 DCHECK_IMPLIES(swapped_out, (flags & CREATE_RF_HIDDEN)); | 1644 DCHECK_IMPLIES(swapped_out, (flags & CREATE_RF_HIDDEN)); |
1643 | 1645 |
1644 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 1646 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
1645 bool success = true; | 1647 bool success = true; |
1646 if (view_routing_id_ptr) | 1648 if (view_routing_id_ptr) |
1647 *view_routing_id_ptr = MSG_ROUTING_NONE; | 1649 *view_routing_id_ptr = MSG_ROUTING_NONE; |
1648 | 1650 |
1649 // We are creating a pending, speculative or swapped out RFH here. We should | 1651 // 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... |
1807 if (!proxy) | 1809 if (!proxy) |
1808 return; | 1810 return; |
1809 | 1811 |
1810 InitRenderView(render_view_host, proxy->GetRoutingID(), false); | 1812 InitRenderView(render_view_host, proxy->GetRoutingID(), false); |
1811 proxy->set_render_frame_proxy_created(true); | 1813 proxy->set_render_frame_proxy_created(true); |
1812 } | 1814 } |
1813 | 1815 |
1814 void RenderFrameHostManager::CreateOuterDelegateProxy( | 1816 void RenderFrameHostManager::CreateOuterDelegateProxy( |
1815 SiteInstance* outer_contents_site_instance, | 1817 SiteInstance* outer_contents_site_instance, |
1816 RenderFrameHostImpl* render_frame_host) { | 1818 RenderFrameHostImpl* render_frame_host) { |
1817 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1819 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); |
1818 switches::kSitePerProcess)); | |
1819 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | 1820 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
1820 outer_contents_site_instance, nullptr, frame_tree_node_); | 1821 outer_contents_site_instance, nullptr, frame_tree_node_); |
1821 proxy_hosts_->Add(outer_contents_site_instance->GetId(), | 1822 proxy_hosts_->Add(outer_contents_site_instance->GetId(), |
1822 make_scoped_ptr(proxy)); | 1823 make_scoped_ptr(proxy)); |
1823 | 1824 |
1824 // Swap the outer WebContents's frame with the proxy to inner WebContents. | 1825 // Swap the outer WebContents's frame with the proxy to inner WebContents. |
1825 // | 1826 // |
1826 // We are in the outer WebContents, and its FrameTree would never see | 1827 // We are in the outer WebContents, and its FrameTree would never see |
1827 // a load start for any of its inner WebContents. Eventually, that also makes | 1828 // a load start for any of its inner WebContents. Eventually, that also makes |
1828 // the FrameTree never see the matching load stop. Therefore, we always pass | 1829 // the FrameTree never see the matching load stop. Therefore, we always pass |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2078 // In the --site-per-process case, old subframe RFHs are not kept alive inside | 2079 // In the --site-per-process case, old subframe RFHs are not kept alive inside |
2079 // the proxy. | 2080 // the proxy. |
2080 SwapOutOldFrame(old_render_frame_host.Pass()); | 2081 SwapOutOldFrame(old_render_frame_host.Pass()); |
2081 | 2082 |
2082 if (RenderFrameHostManager::IsSwappedOutStateForbidden()) { | 2083 if (RenderFrameHostManager::IsSwappedOutStateForbidden()) { |
2083 // Since the new RenderFrameHost is now committed, there must be no proxies | 2084 // Since the new RenderFrameHost is now committed, there must be no proxies |
2084 // for its SiteInstance. Delete any existing ones. | 2085 // for its SiteInstance. Delete any existing ones. |
2085 proxy_hosts_->Remove(render_frame_host_->GetSiteInstance()->GetId()); | 2086 proxy_hosts_->Remove(render_frame_host_->GetSiteInstance()->GetId()); |
2086 } | 2087 } |
2087 | 2088 |
2088 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2089 // If this is a subframe, it should have a CrossProcessFrameConnector |
2089 switches::kSitePerProcess)) { | 2090 // created already. Use it to link the new RFH's view to the proxy that |
2090 // If this is a subframe, it should have a CrossProcessFrameConnector | 2091 // belongs to the parent frame's SiteInstance. If this navigation causes |
2091 // created already. Use it to link the new RFH's view to the proxy that | 2092 // an out-of-process frame to return to the same process as its parent, the |
2092 // belongs to the parent frame's SiteInstance. If this navigation causes | 2093 // proxy would have been removed from proxy_hosts_ above. |
2093 // an out-of-process frame to return to the same process as its parent, the | 2094 // Note: We do this after swapping out the old RFH because that may create |
2094 // proxy would have been removed from proxy_hosts_ above. | 2095 // the proxy we're looking for. |
2095 // Note: We do this after swapping out the old RFH because that may create | 2096 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent(); |
2096 // the proxy we're looking for. | 2097 if (proxy_to_parent) { |
2097 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent(); | 2098 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
2098 if (proxy_to_parent) | 2099 proxy_to_parent->SetChildRWHView(render_frame_host_->GetView()); |
2099 proxy_to_parent->SetChildRWHView(render_frame_host_->GetView()); | |
2100 } | 2100 } |
2101 | 2101 |
2102 // After all is done, there must never be a proxy in the list which has the | 2102 // After all is done, there must never be a proxy in the list which has the |
2103 // same SiteInstance as the current RenderFrameHost. | 2103 // same SiteInstance as the current RenderFrameHost. |
2104 CHECK(!proxy_hosts_->Get(render_frame_host_->GetSiteInstance()->GetId())); | 2104 CHECK(!proxy_hosts_->Get(render_frame_host_->GetSiteInstance()->GetId())); |
2105 } | 2105 } |
2106 | 2106 |
2107 void RenderFrameHostManager::ShutdownProxiesIfLastActiveFrameInSiteInstance( | 2107 void RenderFrameHostManager::ShutdownProxiesIfLastActiveFrameInSiteInstance( |
2108 RenderFrameHostImpl* render_frame_host) { | 2108 RenderFrameHostImpl* render_frame_host) { |
2109 if (!render_frame_host) | 2109 if (!render_frame_host) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 SiteInstance* source_instance, | 2149 SiteInstance* source_instance, |
2150 SiteInstance* dest_instance, | 2150 SiteInstance* dest_instance, |
2151 ui::PageTransition transition, | 2151 ui::PageTransition transition, |
2152 bool dest_is_restore, | 2152 bool dest_is_restore, |
2153 bool dest_is_view_source_mode, | 2153 bool dest_is_view_source_mode, |
2154 const GlobalRequestID& transferred_request_id, | 2154 const GlobalRequestID& transferred_request_id, |
2155 int bindings) { | 2155 int bindings) { |
2156 // Don't swap for subframes unless we are in --site-per-process. We can get | 2156 // Don't swap for subframes unless we are in --site-per-process. We can get |
2157 // here in tests for subframes (e.g., NavigateFrameToURL). | 2157 // here in tests for subframes (e.g., NavigateFrameToURL). |
2158 if (!frame_tree_node_->IsMainFrame() && | 2158 if (!frame_tree_node_->IsMainFrame() && |
2159 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 2159 !SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
2160 switches::kSitePerProcess)) | |
2161 return render_frame_host_.get(); | 2160 return render_frame_host_.get(); |
| 2161 } |
2162 | 2162 |
2163 // If we are currently navigating cross-process, we want to get back to normal | 2163 // If we are currently navigating cross-process, we want to get back to normal |
2164 // and then navigate as usual. | 2164 // and then navigate as usual. |
2165 if (pending_render_frame_host_) | 2165 if (pending_render_frame_host_) |
2166 CancelPending(); | 2166 CancelPending(); |
2167 | 2167 |
2168 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 2168 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
2169 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 2169 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
2170 dest_url, source_instance, dest_instance, nullptr, transition, | 2170 dest_url, source_instance, dest_instance, nullptr, transition, |
2171 dest_is_restore, dest_is_view_source_mode); | 2171 dest_is_restore, dest_is_view_source_mode); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2436 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2436 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
2437 if (!frame_tree_node_->opener()) | 2437 if (!frame_tree_node_->opener()) |
2438 return MSG_ROUTING_NONE; | 2438 return MSG_ROUTING_NONE; |
2439 | 2439 |
2440 return frame_tree_node_->opener() | 2440 return frame_tree_node_->opener() |
2441 ->render_manager() | 2441 ->render_manager() |
2442 ->GetRoutingIdForSiteInstance(instance); | 2442 ->GetRoutingIdForSiteInstance(instance); |
2443 } | 2443 } |
2444 | 2444 |
2445 } // namespace content | 2445 } // namespace content |
OLD | NEW |