Chromium Code Reviews| Index: content/browser/frame_host/navigation_request.cc |
| diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc |
| index b8ef2b115fbab3577b2e5ba6512eb91817b09bde..aa7898060fb6c071a2fe4f9a869441fba40ecbc5 100644 |
| --- a/content/browser/frame_host/navigation_request.cc |
| +++ b/content/browser/frame_host/navigation_request.cc |
| @@ -18,6 +18,7 @@ |
| #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| #include "content/browser/service_worker/service_worker_navigation_handle.h" |
| #include "content/browser/site_instance_impl.h" |
| +#include "content/browser/webui/web_ui_impl.h" |
| #include "content/common/resource_request_body.h" |
| #include "content/public/browser/browser_context.h" |
| #include "content/public/browser/navigation_controller.h" |
| @@ -233,9 +234,16 @@ void NavigationRequest::BeginNavigation() { |
| // Select an appropriate RenderFrameHost. |
| RenderFrameHostImpl* render_frame_host = |
| - frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); |
| + frame_tree_node_->render_manager()->GetFrameHostForNavigation(this); |
| + |
| + // Perform the appropriate checks for WebUIs. |
| NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
| common_params_.url); |
| + if (!WebUIImpl::RenderProcessAllowedForURL(render_frame_host->GetProcess(), |
| + common_params_.url)) { |
| + frame_tree_node_->ResetNavigationRequest(false); |
| + return; |
| + } |
| // Inform the NavigationHandle that the navigation will commit. |
| navigation_handle_->ReadyToCommitNavigation(render_frame_host); |
| @@ -259,6 +267,25 @@ void NavigationRequest::TransferNavigationHandleOwnership( |
| render_frame_host->SetNavigationHandle(std::move(navigation_handle_)); |
| } |
| +StoragePartition* NavigationRequest::GetStoragePartitionForNavigation() { |
|
Charlie Reis
2016/05/25 21:38:02
Is this needed anymore? If it's just cleanup, we
|
| + // Use the SiteInstance of the navigating RenderFrameHost to get access to |
| + // the StoragePartition. Using the url of the navigation will result in a |
| + // wrong StoragePartition being picked when a WebView is navigating. |
| + DCHECK(associated_site_instance_type_ != AssociatedSiteInstanceType::NONE); |
| + SiteInstance* navigation_site_instance = |
| + associated_site_instance_type_ == AssociatedSiteInstanceType::CURRENT |
| + ? frame_tree_node_->current_frame_host()->GetSiteInstance() |
| + : frame_tree_node_->render_manager() |
| + ->speculative_frame_host() |
| + ->GetSiteInstance(); |
| + DCHECK(navigation_site_instance); |
| + |
| + BrowserContext* browser_context = |
| + frame_tree_node_->navigator()->GetController()->GetBrowserContext(); |
| + return BrowserContext::GetStoragePartition(browser_context, |
| + navigation_site_instance); |
| +} |
| + |
| void NavigationRequest::OnRequestRedirected( |
| const net::RedirectInfo& redirect_info, |
| const scoped_refptr<ResourceResponse>& response) { |
| @@ -318,9 +345,16 @@ void NavigationRequest::OnResponseStarted( |
| // Select an appropriate renderer to commit the navigation. |
| RenderFrameHostImpl* render_frame_host = |
| - frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); |
| + frame_tree_node_->render_manager()->GetFrameHostForNavigation(this); |
| + |
| + // Perform the appropriate checks for WebUIs. |
| NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
| common_params_.url); |
| + if (!WebUIImpl::RenderProcessAllowedForURL(render_frame_host->GetProcess(), |
| + common_params_.url)) { |
| + frame_tree_node_->ResetNavigationRequest(false); |
| + return; |
| + } |
| // For renderer-initiated navigations that are set to commit in a different |
| // renderer, allow the embedder to cancel the transfer. |
| @@ -453,24 +487,9 @@ void NavigationRequest::InitializeServiceWorkerHandleIfNeeded() { |
| if (!can_create_service_worker) |
| return; |
| - // Use the SiteInstance of the navigating RenderFrameHost to get access to |
| - // the StoragePartition. Using the url of the navigation will result in a |
| - // wrong StoragePartition being picked when a WebView is navigating. |
| - RenderFrameHostImpl* navigating_frame_host = |
| - frame_tree_node_->render_manager()->speculative_frame_host(); |
| - if (!navigating_frame_host) |
| - navigating_frame_host = frame_tree_node_->current_frame_host(); |
| - DCHECK(navigating_frame_host); |
| - |
| - BrowserContext* browser_context = |
| - frame_tree_node_->navigator()->GetController()->GetBrowserContext(); |
| - StoragePartition* partition = BrowserContext::GetStoragePartition( |
| - browser_context, navigating_frame_host->GetSiteInstance()); |
| - DCHECK(partition); |
| - |
| ServiceWorkerContextWrapper* service_worker_context = |
| static_cast<ServiceWorkerContextWrapper*>( |
| - partition->GetServiceWorkerContext()); |
| + GetStoragePartitionForNavigation()->GetServiceWorkerContext()); |
| navigation_handle_->InitServiceWorkerHandle(service_worker_context); |
| } |