Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/navigation_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 9 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 base::Unretained(this))); | 226 base::Unretained(this))); |
| 227 return; | 227 return; |
| 228 } | 228 } |
| 229 | 229 |
| 230 // There is no need to make a network request for this navigation, so commit | 230 // There is no need to make a network request for this navigation, so commit |
| 231 // it immediately. | 231 // it immediately. |
| 232 state_ = RESPONSE_STARTED; | 232 state_ = RESPONSE_STARTED; |
| 233 | 233 |
| 234 // Select an appropriate RenderFrameHost. | 234 // Select an appropriate RenderFrameHost. |
| 235 RenderFrameHostImpl* render_frame_host = | 235 RenderFrameHostImpl* render_frame_host = |
| 236 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); | 236 frame_tree_node_->render_manager()->GetFrameHostForNavigation(this); |
| 237 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, | 237 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
| 238 common_params_.url); | 238 common_params_.url); |
| 239 | 239 |
| 240 // Inform the NavigationHandle that the navigation will commit. | 240 // Inform the NavigationHandle that the navigation will commit. |
| 241 navigation_handle_->ReadyToCommitNavigation(render_frame_host); | 241 navigation_handle_->ReadyToCommitNavigation(render_frame_host); |
| 242 | 242 |
| 243 CommitNavigation(); | 243 CommitNavigation(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { | 246 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { |
| 247 // TODO(nasko): Update the NavigationHandle creation to ensure that the | 247 // TODO(nasko): Update the NavigationHandle creation to ensure that the |
| 248 // proper values are specified for is_synchronous and is_srcdoc. | 248 // proper values are specified for is_synchronous and is_srcdoc. |
| 249 navigation_handle_ = NavigationHandleImpl::Create( | 249 navigation_handle_ = NavigationHandleImpl::Create( |
| 250 common_params_.url, frame_tree_node_, | 250 common_params_.url, frame_tree_node_, |
| 251 !browser_initiated_, | 251 !browser_initiated_, |
| 252 false, // is_synchronous | 252 false, // is_synchronous |
| 253 false, // is_srcdoc | 253 false, // is_srcdoc |
| 254 common_params_.navigation_start, pending_nav_entry_id); | 254 common_params_.navigation_start, pending_nav_entry_id); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void NavigationRequest::TransferNavigationHandleOwnership( | 257 void NavigationRequest::TransferNavigationHandleOwnership( |
| 258 RenderFrameHostImpl* render_frame_host) { | 258 RenderFrameHostImpl* render_frame_host) { |
| 259 render_frame_host->SetNavigationHandle(std::move(navigation_handle_)); | 259 render_frame_host->SetNavigationHandle(std::move(navigation_handle_)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 StoragePartition* NavigationRequest::GetStoragePartitionForNavigation() { | |
| 263 // Use the SiteInstance of the navigating RenderFrameHost to get access to | |
| 264 // the StoragePartition. Using the url of the navigation will result in a | |
| 265 // wrong StoragePartition being picked when a WebView is navigating. | |
| 266 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
| |
| 267 SiteInstance* navigation_site_instance = | |
| 268 associated_site_instance_type_ == AssociatedSiteInstanceType::CURRENT | |
| 269 ? frame_tree_node_->current_frame_host()->GetSiteInstance() | |
| 270 : frame_tree_node_->render_manager() | |
| 271 ->speculative_frame_host() | |
| 272 ->GetSiteInstance(); | |
| 273 DCHECK(navigation_site_instance); | |
| 274 | |
| 275 BrowserContext* browser_context = | |
| 276 frame_tree_node_->navigator()->GetController()->GetBrowserContext(); | |
| 277 return BrowserContext::GetStoragePartition(browser_context, | |
| 278 navigation_site_instance); | |
| 279 } | |
| 280 | |
| 262 void NavigationRequest::OnRequestRedirected( | 281 void NavigationRequest::OnRequestRedirected( |
| 263 const net::RedirectInfo& redirect_info, | 282 const net::RedirectInfo& redirect_info, |
| 264 const scoped_refptr<ResourceResponse>& response) { | 283 const scoped_refptr<ResourceResponse>& response) { |
| 265 // If the navigation is no longer a POST, the POST data should be reset. | 284 // If the navigation is no longer a POST, the POST data should be reset. |
| 266 if (redirect_info.new_method != "POST") | 285 if (redirect_info.new_method != "POST") |
| 267 post_data_ = nullptr; | 286 post_data_ = nullptr; |
| 268 | 287 |
| 269 common_params_.url = redirect_info.new_url; | 288 common_params_.url = redirect_info.new_url; |
| 270 common_params_.method = redirect_info.new_method; | 289 common_params_.method = redirect_info.new_method; |
| 271 common_params_.referrer.url = GURL(redirect_info.new_referrer); | 290 common_params_.referrer.url = GURL(redirect_info.new_referrer); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 } | 330 } |
| 312 | 331 |
| 313 // Update the lofi state of the request. | 332 // Update the lofi state of the request. |
| 314 if (response->head.is_using_lofi) | 333 if (response->head.is_using_lofi) |
| 315 common_params_.lofi_state = LOFI_ON; | 334 common_params_.lofi_state = LOFI_ON; |
| 316 else | 335 else |
| 317 common_params_.lofi_state = LOFI_OFF; | 336 common_params_.lofi_state = LOFI_OFF; |
| 318 | 337 |
| 319 // Select an appropriate renderer to commit the navigation. | 338 // Select an appropriate renderer to commit the navigation. |
| 320 RenderFrameHostImpl* render_frame_host = | 339 RenderFrameHostImpl* render_frame_host = |
| 321 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); | 340 frame_tree_node_->render_manager()->GetFrameHostForNavigation(this); |
| 322 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, | 341 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
| 323 common_params_.url); | 342 common_params_.url); |
| 324 | 343 |
| 325 // For renderer-initiated navigations that are set to commit in a different | 344 // For renderer-initiated navigations that are set to commit in a different |
| 326 // renderer, allow the embedder to cancel the transfer. | 345 // renderer, allow the embedder to cancel the transfer. |
| 327 if (!browser_initiated_ && | 346 if (!browser_initiated_ && |
| 328 render_frame_host != frame_tree_node_->current_frame_host() && | 347 render_frame_host != frame_tree_node_->current_frame_host() && |
| 329 !frame_tree_node_->navigator() | 348 !frame_tree_node_->navigator() |
| 330 ->GetDelegate() | 349 ->GetDelegate() |
| 331 ->ShouldTransferNavigation()) { | 350 ->ShouldTransferNavigation()) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 | 465 |
| 447 void NavigationRequest::InitializeServiceWorkerHandleIfNeeded() { | 466 void NavigationRequest::InitializeServiceWorkerHandleIfNeeded() { |
| 448 // Only initialize the ServiceWorkerNavigationHandle if it can be created for | 467 // Only initialize the ServiceWorkerNavigationHandle if it can be created for |
| 449 // this frame. | 468 // this frame. |
| 450 bool can_create_service_worker = | 469 bool can_create_service_worker = |
| 451 (frame_tree_node_->pending_sandbox_flags() & | 470 (frame_tree_node_->pending_sandbox_flags() & |
| 452 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin; | 471 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin; |
| 453 if (!can_create_service_worker) | 472 if (!can_create_service_worker) |
| 454 return; | 473 return; |
| 455 | 474 |
| 456 // Use the SiteInstance of the navigating RenderFrameHost to get access to | |
| 457 // the StoragePartition. Using the url of the navigation will result in a | |
| 458 // wrong StoragePartition being picked when a WebView is navigating. | |
| 459 RenderFrameHostImpl* navigating_frame_host = | |
| 460 frame_tree_node_->render_manager()->speculative_frame_host(); | |
| 461 if (!navigating_frame_host) | |
| 462 navigating_frame_host = frame_tree_node_->current_frame_host(); | |
| 463 DCHECK(navigating_frame_host); | |
| 464 | |
| 465 BrowserContext* browser_context = | |
| 466 frame_tree_node_->navigator()->GetController()->GetBrowserContext(); | |
| 467 StoragePartition* partition = BrowserContext::GetStoragePartition( | |
| 468 browser_context, navigating_frame_host->GetSiteInstance()); | |
| 469 DCHECK(partition); | |
| 470 | |
| 471 ServiceWorkerContextWrapper* service_worker_context = | 475 ServiceWorkerContextWrapper* service_worker_context = |
| 472 static_cast<ServiceWorkerContextWrapper*>( | 476 static_cast<ServiceWorkerContextWrapper*>( |
| 473 partition->GetServiceWorkerContext()); | 477 GetStoragePartitionForNavigation()->GetServiceWorkerContext()); |
| 474 navigation_handle_->InitServiceWorkerHandle(service_worker_context); | 478 navigation_handle_->InitServiceWorkerHandle(service_worker_context); |
| 475 } | 479 } |
| 476 | 480 |
| 477 } // namespace content | 481 } // namespace content |
| OLD | NEW |