Chromium Code Reviews| 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(NavigationRequest* request) { |
|
nasko
2015/01/16 15:03:24
It doesn't seem we modify the request at all here,
clamy
2015/01/16 16:39:02
+1. It'd be good if we avoided passing a pointer t
carlosk
2015/01/19 15:02:52
Yes, my bad on this. It's a const reference now.
| |
| 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 NavigationRequest* request) { |
|
nasko
2015/01/16 15:03:24
Same comment about const reference.
carlosk
2015/01/19 15:02:52
Done.
| |
| 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->is_restore(), request->is_view_source()); | |
| 680 // The appropriate RenderFrameHost to commit the navigation. | 678 // The appropriate RenderFrameHost to commit the navigation. |
| 681 RenderFrameHostImpl* navigation_rfh = nullptr; | 679 RenderFrameHostImpl* navigation_rfh = nullptr; |
| 682 | 680 |
| 683 // TODO(carlosk): do not swap processes for renderer initiated navigations | 681 // TODO(carlosk): do not swap processes for renderer initiated navigations |
| 684 // (see crbug.com/440266). | 682 // (see crbug.com/440266). |
| 685 if (current_site_instance == dest_site_instance.get() || | 683 if (current_site_instance == dest_site_instance.get() || |
| 686 (!frame_tree_node_->IsMainFrame() && | 684 (!frame_tree_node_->IsMainFrame() && |
| 687 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 685 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 688 switches::kSitePerProcess))) { | 686 switches::kSitePerProcess))) { |
| 689 // Reuse the current RFH if its SiteInstance matches the the navigation's | 687 // 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()); | 701 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame()); |
| 704 } | 702 } |
| 705 | 703 |
| 706 // If the SiteInstance for the final URL doesn't match the one from the | 704 // If the SiteInstance for the final URL doesn't match the one from the |
| 707 // speculatively created RenderFrameHost, create a new RenderFrameHost using | 705 // speculatively created RenderFrameHost, create a new RenderFrameHost using |
| 708 // this new SiteInstance. | 706 // this new SiteInstance. |
| 709 if (!speculative_render_frame_host_ || | 707 if (!speculative_render_frame_host_ || |
| 710 speculative_render_frame_host_->GetSiteInstance() != | 708 speculative_render_frame_host_->GetSiteInstance() != |
| 711 dest_site_instance.get()) { | 709 dest_site_instance.get()) { |
| 712 CleanUpNavigation(); | 710 CleanUpNavigation(); |
| 713 // TODO(carlosk): Replace the binding value with the right one. | |
| 714 bool success = CreateSpeculativeRenderFrameHost( | 711 bool success = CreateSpeculativeRenderFrameHost( |
| 715 url, current_site_instance, dest_site_instance.get(), | 712 request->common_params().url, current_site_instance, |
| 716 NavigationEntryImpl::kInvalidBindings); | 713 dest_site_instance.get(), request->bindings()); |
| 717 DCHECK(success); | 714 DCHECK(success); |
| 718 } | 715 } |
| 719 DCHECK(speculative_render_frame_host_); | 716 DCHECK(speculative_render_frame_host_); |
| 720 navigation_rfh = speculative_render_frame_host_.get(); | 717 navigation_rfh = speculative_render_frame_host_.get(); |
| 721 } | 718 } |
| 722 DCHECK(navigation_rfh && | 719 DCHECK(navigation_rfh && |
| 723 (navigation_rfh == render_frame_host_.get() || | 720 (navigation_rfh == render_frame_host_.get() || |
| 724 navigation_rfh == speculative_render_frame_host_.get())); | 721 navigation_rfh == speculative_render_frame_host_.get())); |
| 725 | 722 |
| 726 // If the RenderFrame that needs to navigate is not live (its process was just | 723 // 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( | 1863 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
| 1867 SiteInstance* instance) { | 1864 SiteInstance* instance) { |
| 1868 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1865 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
| 1869 if (iter != proxy_hosts_.end()) { | 1866 if (iter != proxy_hosts_.end()) { |
| 1870 delete iter->second; | 1867 delete iter->second; |
| 1871 proxy_hosts_.erase(iter); | 1868 proxy_hosts_.erase(iter); |
| 1872 } | 1869 } |
| 1873 } | 1870 } |
| 1874 | 1871 |
| 1875 } // namespace content | 1872 } // namespace content |
| OLD | NEW |