OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/frame_host/render_frame_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "content/browser/child_process_security_policy_impl.h" | 13 #include "content/browser/child_process_security_policy_impl.h" |
14 #include "content/browser/devtools/render_view_devtools_agent_host.h" | 14 #include "content/browser/devtools/render_view_devtools_agent_host.h" |
15 #include "content/browser/frame_host/cross_site_transferring_request.h" | 15 #include "content/browser/frame_host/cross_site_transferring_request.h" |
16 #include "content/browser/frame_host/debug_urls.h" | 16 #include "content/browser/frame_host/debug_urls.h" |
17 #include "content/browser/frame_host/interstitial_page_impl.h" | 17 #include "content/browser/frame_host/interstitial_page_impl.h" |
18 #include "content/browser/frame_host/navigation_before_commit_info.h" | |
18 #include "content/browser/frame_host/navigation_controller_impl.h" | 19 #include "content/browser/frame_host/navigation_controller_impl.h" |
19 #include "content/browser/frame_host/navigation_entry_impl.h" | 20 #include "content/browser/frame_host/navigation_entry_impl.h" |
20 #include "content/browser/frame_host/navigation_request.h" | 21 #include "content/browser/frame_host/navigation_request.h" |
21 #include "content/browser/frame_host/navigation_request_info.h" | 22 #include "content/browser/frame_host/navigation_request_info.h" |
22 #include "content/browser/frame_host/navigator.h" | 23 #include "content/browser/frame_host/navigator.h" |
23 #include "content/browser/frame_host/render_frame_host_factory.h" | 24 #include "content/browser/frame_host/render_frame_host_factory.h" |
24 #include "content/browser/frame_host/render_frame_host_impl.h" | 25 #include "content/browser/frame_host/render_frame_host_impl.h" |
25 #include "content/browser/frame_host/render_frame_proxy_host.h" | 26 #include "content/browser/frame_host/render_frame_proxy_host.h" |
26 #include "content/browser/renderer_host/render_process_host_impl.h" | 27 #include "content/browser/renderer_host/render_process_host_impl.h" |
27 #include "content/browser/renderer_host/render_view_host_factory.h" | 28 #include "content/browser/renderer_host/render_view_host_factory.h" |
28 #include "content/browser/renderer_host/render_view_host_impl.h" | 29 #include "content/browser/renderer_host/render_view_host_impl.h" |
29 #include "content/browser/site_instance_impl.h" | 30 #include "content/browser/site_instance_impl.h" |
30 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 31 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
31 #include "content/browser/webui/web_ui_impl.h" | 32 #include "content/browser/webui/web_ui_impl.h" |
32 #include "content/common/view_messages.h" | 33 #include "content/common/view_messages.h" |
33 #include "content/public/browser/content_browser_client.h" | 34 #include "content/public/browser/content_browser_client.h" |
34 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
35 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
36 #include "content/public/browser/render_widget_host_iterator.h" | 37 #include "content/public/browser/render_widget_host_iterator.h" |
37 #include "content/public/browser/render_widget_host_view.h" | 38 #include "content/public/browser/render_widget_host_view.h" |
38 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
39 #include "content/public/browser/web_ui_controller.h" | 40 #include "content/public/browser/web_ui_controller.h" |
40 #include "content/public/common/content_switches.h" | 41 #include "content/public/common/content_switches.h" |
42 #include "content/public/common/referrer.h" | |
41 #include "content/public/common/url_constants.h" | 43 #include "content/public/common/url_constants.h" |
44 #include "net/base/load_flags.h" | |
42 | 45 |
43 namespace content { | 46 namespace content { |
44 | 47 |
48 namespace { | |
49 | |
50 // PlzNavigate | |
51 // Simulates a renderer response to a navigation request when there is no live | |
52 // renderer. | |
53 FrameHostMsg_BeginNavigation_Params BeginNavigationFromNavigate( | |
54 const FrameMsg_Navigate_Params& navigate_params) { | |
55 FrameHostMsg_BeginNavigation_Params begin_navigation_params; | |
56 begin_navigation_params.method = navigate_params.is_post ? "POST" : "GET"; | |
57 begin_navigation_params.url = navigate_params.url; | |
58 begin_navigation_params.referrer = | |
59 Referrer(navigate_params.referrer.url, navigate_params.referrer.policy); | |
60 | |
61 // TODO(clamy): This should be modified to take into account caching policy | |
62 // requirements (eg for POST reloads). | |
63 begin_navigation_params.load_flags = | |
64 net::LOAD_NORMAL | net::LOAD_ENABLE_LOAD_TIMING; | |
65 | |
66 // TODO(clamy): Post data from the browser should be put in the request body. | |
67 | |
68 begin_navigation_params.has_user_gesture = false; | |
69 begin_navigation_params.transition_type = navigate_params.transition; | |
70 begin_navigation_params.should_replace_current_entry = | |
71 navigate_params.should_replace_current_entry; | |
72 begin_navigation_params.allow_download = | |
73 navigate_params.allow_download; | |
74 return begin_navigation_params; | |
75 } | |
76 | |
77 } // namespace | |
78 | |
45 RenderFrameHostManager::PendingNavigationParams::PendingNavigationParams( | 79 RenderFrameHostManager::PendingNavigationParams::PendingNavigationParams( |
46 const GlobalRequestID& global_request_id, | 80 const GlobalRequestID& global_request_id, |
47 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request, | 81 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request, |
48 const std::vector<GURL>& transfer_url_chain, | 82 const std::vector<GURL>& transfer_url_chain, |
49 Referrer referrer, | 83 Referrer referrer, |
50 PageTransition page_transition, | 84 PageTransition page_transition, |
51 int render_frame_id, | 85 int render_frame_id, |
52 bool should_replace_current_entry) | 86 bool should_replace_current_entry) |
53 : global_request_id(global_request_id), | 87 : global_request_id(global_request_id), |
54 cross_site_transferring_request(cross_site_transferring_request.Pass()), | 88 cross_site_transferring_request(cross_site_transferring_request.Pass()), |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 RFHPendingDeleteMap::iterator iter = | 590 RFHPendingDeleteMap::iterator iter = |
557 pending_delete_hosts_.find(site_instance_id); | 591 pending_delete_hosts_.find(site_instance_id); |
558 if (iter != pending_delete_hosts_.end() && iter->second.get() == rfh) | 592 if (iter != pending_delete_hosts_.end() && iter->second.get() == rfh) |
559 pending_delete_hosts_.erase(site_instance_id); | 593 pending_delete_hosts_.erase(site_instance_id); |
560 } | 594 } |
561 | 595 |
562 void RenderFrameHostManager::ResetProxyHosts() { | 596 void RenderFrameHostManager::ResetProxyHosts() { |
563 STLDeleteValues(&proxy_hosts_); | 597 STLDeleteValues(&proxy_hosts_); |
564 } | 598 } |
565 | 599 |
600 // PlzNavigate | |
601 bool RenderFrameHostManager::RequestNavigation( | |
602 const NavigationEntryImpl& entry, | |
603 const FrameMsg_Navigate_Params& navigate_params) { | |
604 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | |
605 switches::kEnableBrowserSideNavigation)); | |
606 // TODO(clamy): replace RenderViewHost::IsRenderViewLive by | |
607 // RenderFrameHost::IsLive. | |
608 if (render_frame_host_->render_view_host()->IsRenderViewLive()) | |
609 // TODO(clamy): send a RequestNavigation IPC. | |
610 return true; | |
611 | |
612 // The navigation request is sent directly to the IO thread. | |
613 OnBeginNavigation(BeginNavigationFromNavigate(navigate_params)); | |
614 return true; | |
615 } | |
616 | |
617 // PlzNavigate | |
566 void RenderFrameHostManager::OnBeginNavigation( | 618 void RenderFrameHostManager::OnBeginNavigation( |
567 const FrameHostMsg_BeginNavigation_Params& params) { | 619 const FrameHostMsg_BeginNavigation_Params& params) { |
620 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | |
621 switches::kEnableBrowserSideNavigation)); | |
568 // TODO(clamy): Check if navigations are blocked and if so, return | 622 // TODO(clamy): Check if navigations are blocked and if so, return |
569 // immediately. | 623 // immediately. |
570 NavigationRequestInfo info(params); | 624 NavigationRequestInfo info(params); |
571 | 625 |
572 info.first_party_for_cookies = frame_tree_node_->IsMainFrame() ? | 626 info.first_party_for_cookies = frame_tree_node_->IsMainFrame() ? |
573 params.url : frame_tree_node_->frame_tree()->root()->current_url(); | 627 params.url : frame_tree_node_->frame_tree()->root()->current_url(); |
574 info.is_main_frame = frame_tree_node_->IsMainFrame(); | 628 info.is_main_frame = frame_tree_node_->IsMainFrame(); |
575 info.parent_is_main_frame = !frame_tree_node_->parent() ? | 629 info.parent_is_main_frame = !frame_tree_node_->parent() ? |
576 false : frame_tree_node_->parent()->IsMainFrame(); | 630 false : frame_tree_node_->parent()->IsMainFrame(); |
577 info.is_showing = GetRenderWidgetHostView()->IsShowing(); | 631 info.is_showing = GetRenderWidgetHostView()->IsShowing(); |
578 | 632 |
579 navigation_request_.reset( | 633 // TODO(clamy): Check if the current RFH should be initialized (in case it has |
580 new NavigationRequest(info, frame_tree_node_->frame_tree_node_id())); | 634 // crashed) not to display a sad tab while navigating. |
635 // TODO(clamy): Spawn a speculative renderer process if we do not have one to | |
636 // use for the navigation. | |
637 navigation_request_.reset(new NavigationRequest( | |
638 info, frame_tree_node_->frame_tree_node_id())); | |
581 navigation_request_->BeginNavigation(params.request_body); | 639 navigation_request_->BeginNavigation(params.request_body); |
582 // TODO(clamy): If we have no live RenderFrameHost to handle the request (eg | 640 } |
583 // cross-site navigation) spawn one speculatively here and keep track of it. | 641 |
642 // PlzNavigate | |
643 void RenderFrameHostManager::CommitNavigation( | |
644 const NavigationBeforeCommitInfo& info) { | |
645 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | |
646 switches::kEnableBrowserSideNavigation)); | |
647 // Pick the right RenderFrameHost to commit the navigation. | |
648 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | |
649 // TODO(clamy): Store the site instance, if the navigation is view source mode | |
Charlie Reis
2014/08/15 06:13:47
Why will we need to do this?
clamy
2014/08/18 10:02:36
We may need to store some of them when we get the
| |
650 // and if it is a restore. | |
651 SiteInstance* new_instance = GetSiteInstanceForNavigation( | |
652 info.navigation_url, | |
653 NULL, | |
654 navigation_request_->info().navigation_params.transition_type, | |
655 false, | |
656 false); | |
657 DCHECK(!pending_render_frame_host_.get()); | |
658 | |
659 // TODO(clamy): Update how pending WebUI objects are handled. | |
660 if (current_instance != new_instance) { | |
661 CreateRenderFrameHostForNewSiteInstance( | |
662 current_instance, new_instance, frame_tree_node_->IsMainFrame()); | |
663 DCHECK(pending_render_frame_host_.get()); | |
664 // TODO(clamy): Wait until the navigation has committed before swapping | |
665 // renderers. | |
666 scoped_ptr<RenderFrameHostImpl> old_render_frame_host = | |
667 SetRenderFrameHost(pending_render_frame_host_.Pass()); | |
668 if (frame_tree_node_->IsMainFrame()) | |
669 render_frame_host_->render_view_host()->AttachToFrameTree(); | |
670 } | |
671 | |
672 frame_tree_node_->navigator()->CommitNavigation( | |
673 render_frame_host_.get(), info); | |
584 } | 674 } |
585 | 675 |
586 void RenderFrameHostManager::Observe( | 676 void RenderFrameHostManager::Observe( |
587 int type, | 677 int type, |
588 const NotificationSource& source, | 678 const NotificationSource& source, |
589 const NotificationDetails& details) { | 679 const NotificationDetails& details) { |
590 switch (type) { | 680 switch (type) { |
591 case NOTIFICATION_RENDERER_PROCESS_CLOSED: | 681 case NOTIFICATION_RENDERER_PROCESS_CLOSED: |
592 case NOTIFICATION_RENDERER_PROCESS_CLOSING: | 682 case NOTIFICATION_RENDERER_PROCESS_CLOSING: |
593 RendererProcessClosing( | 683 RendererProcessClosing( |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
709 const NavigationEntryImpl* new_entry) const { | 799 const NavigationEntryImpl* new_entry) const { |
710 NavigationControllerImpl& controller = | 800 NavigationControllerImpl& controller = |
711 delegate_->GetControllerForRenderManager(); | 801 delegate_->GetControllerForRenderManager(); |
712 return current_entry && web_ui_.get() && | 802 return current_entry && web_ui_.get() && |
713 (WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( | 803 (WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( |
714 controller.GetBrowserContext(), current_entry->GetURL()) == | 804 controller.GetBrowserContext(), current_entry->GetURL()) == |
715 WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( | 805 WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( |
716 controller.GetBrowserContext(), new_entry->GetURL())); | 806 controller.GetBrowserContext(), new_entry->GetURL())); |
717 } | 807 } |
718 | 808 |
809 SiteInstance* RenderFrameHostManager::GetSiteInstanceForNavigation( | |
810 const GURL& dest_url, | |
811 SiteInstance* dest_instance, | |
812 PageTransition dest_transition, | |
813 bool dest_is_restore, | |
814 bool dest_is_view_source_mode) { | |
815 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | |
816 SiteInstance* new_instance = current_instance; | |
817 | |
818 // We do not currently swap processes for navigations in webview tag guests. | |
819 bool is_guest_scheme = current_instance->GetSiteURL().SchemeIs(kGuestScheme); | |
820 | |
821 // Determine if we need a new BrowsingInstance for this entry. If true, this | |
822 // implies that it will get a new SiteInstance (and likely process), and that | |
823 // other tabs in the current BrowsingInstance will be unable to script it. | |
824 // This is used for cases that require a process swap even in the | |
825 // process-per-tab model, such as WebUI pages. | |
826 // TODO(clamy): Remove the dependency on the current entry. | |
827 const NavigationEntry* current_entry = | |
828 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | |
829 BrowserContext* browser_context = | |
830 delegate_->GetControllerForRenderManager().GetBrowserContext(); | |
831 const GURL& current_effective_url = current_entry ? | |
832 SiteInstanceImpl::GetEffectiveURL(browser_context, | |
833 current_entry->GetURL()) : | |
834 render_frame_host_->GetSiteInstance()->GetSiteURL(); | |
835 bool current_is_view_source_mode = current_entry ? | |
836 current_entry->IsViewSourceMode() : dest_is_view_source_mode; | |
837 bool force_swap = !is_guest_scheme && | |
838 ShouldSwapBrowsingInstancesForNavigation( | |
839 current_effective_url, | |
840 current_is_view_source_mode, | |
841 dest_instance, | |
842 SiteInstanceImpl::GetEffectiveURL(browser_context, dest_url), | |
843 dest_is_view_source_mode); | |
844 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) { | |
845 new_instance = GetSiteInstanceForURL( | |
846 dest_url, | |
847 dest_instance, | |
848 dest_transition, | |
849 dest_is_restore, | |
850 dest_is_view_source_mode, | |
851 current_instance, | |
852 force_swap); | |
853 } | |
854 | |
855 // If force_swap is true, we must use a different SiteInstance. If we didn't, | |
856 // we would have two RenderFrameHosts in the same SiteInstance and the same | |
857 // frame, resulting in page_id conflicts for their NavigationEntries. | |
858 if (force_swap) | |
859 CHECK_NE(new_instance, current_instance); | |
860 return new_instance; | |
861 } | |
862 | |
719 SiteInstance* RenderFrameHostManager::GetSiteInstanceForURL( | 863 SiteInstance* RenderFrameHostManager::GetSiteInstanceForURL( |
720 const GURL& dest_url, | 864 const GURL& dest_url, |
721 SiteInstance* dest_instance, | 865 SiteInstance* dest_instance, |
722 PageTransition dest_transition, | 866 PageTransition dest_transition, |
723 bool dest_is_restore, | 867 bool dest_is_restore, |
724 bool dest_is_view_source_mode, | 868 bool dest_is_view_source_mode, |
725 SiteInstance* current_instance, | 869 SiteInstance* current_instance, |
726 bool force_browsing_instance_swap) { | 870 bool force_browsing_instance_swap) { |
727 NavigationControllerImpl& controller = | 871 NavigationControllerImpl& controller = |
728 delegate_->GetControllerForRenderManager(); | 872 delegate_->GetControllerForRenderManager(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
877 } | 1021 } |
878 | 1022 |
879 // Start the new renderer in a new SiteInstance, but in the current | 1023 // Start the new renderer in a new SiteInstance, but in the current |
880 // BrowsingInstance. It is important to immediately give this new | 1024 // BrowsingInstance. It is important to immediately give this new |
881 // SiteInstance to a RenderViewHost (if it is different than our current | 1025 // SiteInstance to a RenderViewHost (if it is different than our current |
882 // SiteInstance), so that it is ref counted. This will happen in | 1026 // SiteInstance), so that it is ref counted. This will happen in |
883 // CreateRenderView. | 1027 // CreateRenderView. |
884 return current_instance->GetRelatedSiteInstance(dest_url); | 1028 return current_instance->GetRelatedSiteInstance(dest_url); |
885 } | 1029 } |
886 | 1030 |
1031 void RenderFrameHostManager::CreateRenderFrameHostForNewSiteInstance( | |
1032 SiteInstance* old_instance, | |
1033 SiteInstance* new_instance, | |
1034 bool is_main_frame) { | |
1035 // Ensure that we have created RFHs for the new RFH's opener chain if | |
1036 // we are staying in the same BrowsingInstance. This allows the new RFH | |
1037 // to send cross-process script calls to its opener(s). | |
1038 int opener_route_id = MSG_ROUTING_NONE; | |
1039 if (new_instance->IsRelatedSiteInstance(old_instance)) { | |
1040 opener_route_id = | |
1041 delegate_->CreateOpenerRenderViewsForRenderManager(new_instance); | |
1042 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
1043 switches::kSitePerProcess)) { | |
1044 // Ensure that the frame tree has RenderFrameProxyHosts for the new | |
1045 // SiteInstance in all nodes except the current one. | |
1046 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( | |
1047 frame_tree_node_, new_instance); | |
1048 } | |
1049 } | |
1050 | |
1051 // Create a non-swapped-out RFH with the given opener. | |
1052 int route_id = CreateRenderFrame( | |
1053 new_instance, opener_route_id, false, is_main_frame, | |
1054 delegate_->IsHidden()); | |
1055 if (route_id == MSG_ROUTING_NONE) { | |
1056 pending_render_frame_host_.reset(); | |
1057 return; | |
1058 } | |
1059 } | |
1060 | |
887 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost( | 1061 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrameHost( |
888 SiteInstance* site_instance, | 1062 SiteInstance* site_instance, |
889 int view_routing_id, | 1063 int view_routing_id, |
890 int frame_routing_id, | 1064 int frame_routing_id, |
891 bool swapped_out, | 1065 bool swapped_out, |
892 bool hidden) { | 1066 bool hidden) { |
893 if (frame_routing_id == MSG_ROUTING_NONE) | 1067 if (frame_routing_id == MSG_ROUTING_NONE) |
894 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); | 1068 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); |
895 | 1069 |
896 // Create a RVH for main frames, or find the existing one for subframes. | 1070 // Create a RVH for main frames, or find the existing one for subframes. |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1303 const NavigationEntryImpl& entry) { | 1477 const NavigationEntryImpl& entry) { |
1304 // If we are currently navigating cross-process, we want to get back to normal | 1478 // If we are currently navigating cross-process, we want to get back to normal |
1305 // and then navigate as usual. | 1479 // and then navigate as usual. |
1306 if (cross_navigation_pending_) { | 1480 if (cross_navigation_pending_) { |
1307 if (pending_render_frame_host_) | 1481 if (pending_render_frame_host_) |
1308 CancelPending(); | 1482 CancelPending(); |
1309 cross_navigation_pending_ = false; | 1483 cross_navigation_pending_ = false; |
1310 } | 1484 } |
1311 | 1485 |
1312 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 1486 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
1313 scoped_refptr<SiteInstance> new_instance = current_instance; | 1487 scoped_refptr<SiteInstance> new_instance = |
1488 GetSiteInstanceForNavigation( | |
1489 entry.GetURL(), | |
1490 entry.site_instance(), | |
1491 entry.GetTransitionType(), | |
1492 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, | |
1493 entry.IsViewSourceMode()); | |
1314 | 1494 |
1315 // We do not currently swap processes for navigations in webview tag guests. | |
1316 bool is_guest_scheme = current_instance->GetSiteURL().SchemeIs(kGuestScheme); | |
1317 | |
1318 // Determine if we need a new BrowsingInstance for this entry. If true, this | |
1319 // implies that it will get a new SiteInstance (and likely process), and that | |
1320 // other tabs in the current BrowsingInstance will be unable to script it. | |
1321 // This is used for cases that require a process swap even in the | |
1322 // process-per-tab model, such as WebUI pages. | |
1323 const NavigationEntry* current_entry = | 1495 const NavigationEntry* current_entry = |
1324 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 1496 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
1325 BrowserContext* browser_context = | |
1326 delegate_->GetControllerForRenderManager().GetBrowserContext(); | |
1327 const GURL& current_effective_url = current_entry ? | |
1328 SiteInstanceImpl::GetEffectiveURL(browser_context, | |
1329 current_entry->GetURL()) : | |
1330 render_frame_host_->GetSiteInstance()->GetSiteURL(); | |
1331 bool current_is_view_source_mode = current_entry ? | |
1332 current_entry->IsViewSourceMode() : entry.IsViewSourceMode(); | |
1333 bool force_swap = !is_guest_scheme && | |
1334 ShouldSwapBrowsingInstancesForNavigation( | |
1335 current_effective_url, | |
1336 current_is_view_source_mode, | |
1337 entry.site_instance(), | |
1338 SiteInstanceImpl::GetEffectiveURL(browser_context, entry.GetURL()), | |
1339 entry.IsViewSourceMode()); | |
1340 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) { | |
1341 new_instance = GetSiteInstanceForURL( | |
1342 entry.GetURL(), | |
1343 entry.site_instance(), | |
1344 entry.GetTransitionType(), | |
1345 entry.restore_type() != NavigationEntryImpl::RESTORE_NONE, | |
1346 entry.IsViewSourceMode(), | |
1347 current_instance, | |
1348 force_swap); | |
1349 } | |
1350 | |
1351 // If force_swap is true, we must use a different SiteInstance. If we didn't, | |
1352 // we would have two RenderFrameHosts in the same SiteInstance and the same | |
1353 // frame, resulting in page_id conflicts for their NavigationEntries. | |
1354 if (force_swap) | |
1355 CHECK_NE(new_instance, current_instance); | |
1356 | 1497 |
1357 if (new_instance != current_instance) { | 1498 if (new_instance != current_instance) { |
1358 // New SiteInstance: create a pending RFH to navigate. | 1499 // New SiteInstance: create a pending RFH to navigate. |
1359 DCHECK(!cross_navigation_pending_); | 1500 DCHECK(!cross_navigation_pending_); |
1360 | 1501 |
1361 // This will possibly create (set to NULL) a Web UI object for the pending | 1502 // This will possibly create (set to NULL) a Web UI object for the pending |
1362 // page. We'll use this later to give the page special access. This must | 1503 // page. We'll use this later to give the page special access. This must |
1363 // happen before the new renderer is created below so it will get bindings. | 1504 // happen before the new renderer is created below so it will get bindings. |
1364 // It must also happen after the above conditional call to CancelPending(), | 1505 // It must also happen after the above conditional call to CancelPending(), |
1365 // otherwise CancelPending may clear the pending_web_ui_ and the page will | 1506 // otherwise CancelPending may clear the pending_web_ui_ and the page will |
1366 // not have its bindings set appropriately. | 1507 // not have its bindings set appropriately. |
1367 SetPendingWebUI(entry); | 1508 SetPendingWebUI(entry); |
1368 | 1509 CreateRenderFrameHostForNewSiteInstance( |
1369 // Ensure that we have created RFHs for the new RFH's opener chain if | 1510 current_instance, new_instance, frame_tree_node_->IsMainFrame()); |
1370 // we are staying in the same BrowsingInstance. This allows the pending RFH | 1511 if (!pending_render_frame_host_.get()) { |
1371 // to send cross-process script calls to its opener(s). | 1512 return NULL; |
1372 int opener_route_id = MSG_ROUTING_NONE; | |
1373 if (new_instance->IsRelatedSiteInstance(current_instance)) { | |
1374 opener_route_id = | |
1375 delegate_->CreateOpenerRenderViewsForRenderManager(new_instance); | |
1376 | |
1377 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
1378 switches::kSitePerProcess)) { | |
1379 // Ensure that the frame tree has RenderFrameProxyHosts for the new | |
1380 // SiteInstance in all nodes except the current one. | |
1381 frame_tree_node_->frame_tree()->CreateProxiesForSiteInstance( | |
1382 frame_tree_node_, new_instance); | |
1383 } | |
1384 } | 1513 } |
1385 | 1514 |
1386 // Create a non-swapped-out pending RFH with the given opener and navigate | |
1387 // it. | |
1388 int route_id = CreateRenderFrame(new_instance, | |
1389 opener_route_id, | |
1390 false, | |
1391 frame_tree_node_->IsMainFrame(), | |
1392 delegate_->IsHidden()); | |
1393 if (route_id == MSG_ROUTING_NONE) | |
1394 return NULL; | |
1395 | |
1396 // Check if our current RFH is live before we set up a transition. | 1515 // Check if our current RFH is live before we set up a transition. |
1397 if (!render_frame_host_->render_view_host()->IsRenderViewLive()) { | 1516 if (!render_frame_host_->render_view_host()->IsRenderViewLive()) { |
1398 if (!cross_navigation_pending_) { | 1517 if (!cross_navigation_pending_) { |
1399 // The current RFH is not live. There's no reason to sit around with a | 1518 // The current RFH is not live. There's no reason to sit around with a |
1400 // sad tab or a newly created RFH while we wait for the pending RFH to | 1519 // sad tab or a newly created RFH while we wait for the pending RFH to |
1401 // navigate. Just switch to the pending RFH now and go back to non | 1520 // navigate. Just switch to the pending RFH now and go back to non |
1402 // cross-navigating (Note that we don't care about on{before}unload | 1521 // cross-navigating (Note that we don't care about on{before}unload |
1403 // handlers if the current RFH isn't live.) | 1522 // handlers if the current RFH isn't live.) |
1404 CommitPending(); | 1523 CommitPending(); |
1405 return render_frame_host_.get(); | 1524 return render_frame_host_.get(); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1601 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1720 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1602 SiteInstance* instance) { | 1721 SiteInstance* instance) { |
1603 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1722 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1604 if (iter != proxy_hosts_.end()) { | 1723 if (iter != proxy_hosts_.end()) { |
1605 delete iter->second; | 1724 delete iter->second; |
1606 proxy_hosts_.erase(iter); | 1725 proxy_hosts_.erase(iter); |
1607 } | 1726 } |
1608 } | 1727 } |
1609 | 1728 |
1610 } // namespace content | 1729 } // namespace content |
OLD | NEW |