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..d207628b2ac37d21ae80d2f7eac2efdfaa2f60a7 100644 |
| --- a/content/browser/frame_host/navigation_request.cc |
| +++ b/content/browser/frame_host/navigation_request.cc |
| @@ -233,7 +233,7 @@ 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); |
| NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
| common_params_.url); |
| @@ -259,6 +259,25 @@ void NavigationRequest::TransferNavigationHandleOwnership( |
| render_frame_host->SetNavigationHandle(std::move(navigation_handle_)); |
| } |
| +StoragePartition* NavigationRequest::GetStoragePartitionForNavigation() { |
| + // 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); |
|
Charlie Reis
2016/05/23 17:26:40
DCHECK_NE?
clamy
2016/05/25 14:30:11
Done.
Charlie Reis
2016/05/25 21:38:02
Wasn't fixed, but I don't think we should add this
|
| + 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,7 +337,7 @@ 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); |
| NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
| common_params_.url); |
| @@ -453,24 +472,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); |
| } |