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_controller_impl.h" | 18 #include "content/browser/frame_host/navigation_controller_impl.h" |
19 #include "content/browser/frame_host/navigation_entry_impl.h" | 19 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 20 #include "content/browser/frame_host/navigation_request.h" |
20 #include "content/browser/frame_host/navigator.h" | 21 #include "content/browser/frame_host/navigator.h" |
21 #include "content/browser/frame_host/render_frame_host_factory.h" | 22 #include "content/browser/frame_host/render_frame_host_factory.h" |
22 #include "content/browser/frame_host/render_frame_host_impl.h" | 23 #include "content/browser/frame_host/render_frame_host_impl.h" |
23 #include "content/browser/frame_host/render_frame_proxy_host.h" | 24 #include "content/browser/frame_host/render_frame_proxy_host.h" |
24 #include "content/browser/renderer_host/render_process_host_impl.h" | 25 #include "content/browser/renderer_host/render_process_host_impl.h" |
25 #include "content/browser/renderer_host/render_view_host_factory.h" | 26 #include "content/browser/renderer_host/render_view_host_factory.h" |
26 #include "content/browser/renderer_host/render_view_host_impl.h" | 27 #include "content/browser/renderer_host/render_view_host_impl.h" |
27 #include "content/browser/site_instance_impl.h" | 28 #include "content/browser/site_instance_impl.h" |
28 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 29 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
29 #include "content/browser/webui/web_ui_impl.h" | 30 #include "content/browser/webui/web_ui_impl.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 } | 644 } |
644 } | 645 } |
645 return false; | 646 return false; |
646 } | 647 } |
647 | 648 |
648 void RenderFrameHostManager::ResetProxyHosts() { | 649 void RenderFrameHostManager::ResetProxyHosts() { |
649 STLDeleteValues(&proxy_hosts_); | 650 STLDeleteValues(&proxy_hosts_); |
650 } | 651 } |
651 | 652 |
652 // PlzNavigate | 653 // PlzNavigate |
653 void RenderFrameHostManager::BeginNavigation( | 654 void RenderFrameHostManager::BeginNavigation(const NavigationRequest& request) { |
654 const CommonNavigationParams& common_params) { | |
655 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 655 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
656 switches::kEnableBrowserSideNavigation)); | 656 switches::kEnableBrowserSideNavigation)); |
657 // Clean up any state in case there's an ongoing navigation. | 657 // Clean up any state in case there's an ongoing navigation. |
658 // TODO(carlosk): remove this cleanup here once we properly cancel ongoing | 658 // TODO(carlosk): remove this cleanup here once we properly cancel ongoing |
659 // navigations. | 659 // navigations. |
660 CleanUpNavigation(); | 660 CleanUpNavigation(); |
661 | 661 |
662 RenderFrameHostImpl* dest_rfh = | 662 RenderFrameHostImpl* dest_rfh = GetFrameHostForNavigation(request); |
663 GetFrameHostForNavigation(common_params.url, common_params.transition); | |
664 DCHECK(dest_rfh); | 663 DCHECK(dest_rfh); |
665 } | 664 } |
666 | 665 |
667 // PlzNavigate | 666 // PlzNavigate |
668 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( | 667 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( |
669 const GURL& url, | 668 const NavigationRequest& request) { |
670 ui::PageTransition transition) { | |
671 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 669 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
672 switches::kEnableBrowserSideNavigation)); | 670 switches::kEnableBrowserSideNavigation)); |
673 | 671 |
674 SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance(); | 672 SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance(); |
675 | 673 |
676 // TODO(carlosk): Replace the default values with the right ones for | |
677 // source_instance, dest_instance, dest_is_restore, dest_is_view_source_mode. | |
678 scoped_refptr<SiteInstance> dest_site_instance = GetSiteInstanceForNavigation( | 674 scoped_refptr<SiteInstance> dest_site_instance = GetSiteInstanceForNavigation( |
679 url, nullptr, nullptr, transition, false, false); | 675 request.common_params().url, request.source_site_instance(), |
| 676 request.dest_site_instance(), request.common_params().transition, |
| 677 request.restore_type() != NavigationEntryImpl::RESTORE_NONE, |
| 678 request.is_view_source()); |
680 // The appropriate RenderFrameHost to commit the navigation. | 679 // The appropriate RenderFrameHost to commit the navigation. |
681 RenderFrameHostImpl* navigation_rfh = nullptr; | 680 RenderFrameHostImpl* navigation_rfh = nullptr; |
682 | 681 |
683 // TODO(carlosk): do not swap processes for renderer initiated navigations | 682 // TODO(carlosk): do not swap processes for renderer initiated navigations |
684 // (see crbug.com/440266). | 683 // (see crbug.com/440266). |
685 if (current_site_instance == dest_site_instance.get() || | 684 if (current_site_instance == dest_site_instance.get() || |
686 (!frame_tree_node_->IsMainFrame() && | 685 (!frame_tree_node_->IsMainFrame() && |
687 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 686 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
688 switches::kSitePerProcess))) { | 687 switches::kSitePerProcess))) { |
689 // Reuse the current RFH if its SiteInstance matches the the navigation's | 688 // Reuse the current RFH if its SiteInstance matches the the navigation's |
(...skipping 13 matching lines...) Expand all Loading... |
703 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame()); | 702 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame()); |
704 } | 703 } |
705 | 704 |
706 // If the SiteInstance for the final URL doesn't match the one from the | 705 // If the SiteInstance for the final URL doesn't match the one from the |
707 // speculatively created RenderFrameHost, create a new RenderFrameHost using | 706 // speculatively created RenderFrameHost, create a new RenderFrameHost using |
708 // this new SiteInstance. | 707 // this new SiteInstance. |
709 if (!speculative_render_frame_host_ || | 708 if (!speculative_render_frame_host_ || |
710 speculative_render_frame_host_->GetSiteInstance() != | 709 speculative_render_frame_host_->GetSiteInstance() != |
711 dest_site_instance.get()) { | 710 dest_site_instance.get()) { |
712 CleanUpNavigation(); | 711 CleanUpNavigation(); |
713 // TODO(carlosk): Replace the binding value with the right one. | |
714 bool success = CreateSpeculativeRenderFrameHost( | 712 bool success = CreateSpeculativeRenderFrameHost( |
715 url, current_site_instance, dest_site_instance.get(), | 713 request.common_params().url, current_site_instance, |
716 NavigationEntryImpl::kInvalidBindings); | 714 dest_site_instance.get(), request.bindings()); |
717 DCHECK(success); | 715 DCHECK(success); |
718 } | 716 } |
719 DCHECK(speculative_render_frame_host_); | 717 DCHECK(speculative_render_frame_host_); |
720 navigation_rfh = speculative_render_frame_host_.get(); | 718 navigation_rfh = speculative_render_frame_host_.get(); |
721 } | 719 } |
722 DCHECK(navigation_rfh && | 720 DCHECK(navigation_rfh && |
723 (navigation_rfh == render_frame_host_.get() || | 721 (navigation_rfh == render_frame_host_.get() || |
724 navigation_rfh == speculative_render_frame_host_.get())); | 722 navigation_rfh == speculative_render_frame_host_.get())); |
725 | 723 |
726 // If the RenderFrame that needs to navigate is not live (its process was just | 724 // If the RenderFrame that needs to navigate is not live (its process was just |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1864 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1867 SiteInstance* instance) { | 1865 SiteInstance* instance) { |
1868 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1866 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1869 if (iter != proxy_hosts_.end()) { | 1867 if (iter != proxy_hosts_.end()) { |
1870 delete iter->second; | 1868 delete iter->second; |
1871 proxy_hosts_.erase(iter); | 1869 proxy_hosts_.erase(iter); |
1872 } | 1870 } |
1873 } | 1871 } |
1874 | 1872 |
1875 } // namespace content | 1873 } // namespace content |
OLD | NEW |