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/child_process_security_policy_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
| 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 common_params_.url, common_params_.method, common_params_.referrer.url, | 368 common_params_.url, common_params_.method, common_params_.referrer.url, |
| 369 false, response->head.headers, response->head.connection_info, | 369 false, response->head.headers, response->head.connection_info, |
| 370 base::Bind(&NavigationRequest::OnRedirectChecksComplete, | 370 base::Bind(&NavigationRequest::OnRedirectChecksComplete, |
| 371 base::Unretained(this))); | 371 base::Unretained(this))); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void NavigationRequest::OnResponseStarted( | 374 void NavigationRequest::OnResponseStarted( |
| 375 const scoped_refptr<ResourceResponse>& response, | 375 const scoped_refptr<ResourceResponse>& response, |
| 376 std::unique_ptr<StreamHandle> body, | 376 std::unique_ptr<StreamHandle> body, |
| 377 const SSLStatus& ssl_status, | 377 const SSLStatus& ssl_status, |
| 378 std::unique_ptr<NavigationData> navigation_data) { | 378 std::unique_ptr<NavigationData> navigation_data, |
| 379 bool is_download) { | |
| 379 DCHECK(state_ == STARTED); | 380 DCHECK(state_ == STARTED); |
| 380 state_ = RESPONSE_STARTED; | 381 state_ = RESPONSE_STARTED; |
| 381 | 382 |
| 382 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | |
| 383 // commit; they leave the frame showing the previous page. | |
| 384 DCHECK(response); | 383 DCHECK(response); |
| 385 if (response->head.headers.get() && | |
| 386 (response->head.headers->response_code() == 204 || | |
| 387 response->head.headers->response_code() == 205)) { | |
| 388 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( | |
| 389 navigation_handle_.get()); | |
| 390 frame_tree_node_->ResetNavigationRequest(false); | |
| 391 return; | |
| 392 } | |
| 393 | 384 |
| 394 // Update the service worker params of the request params. | 385 // Update the service worker params of the request params. |
| 395 bool did_create_service_worker_host = | 386 bool did_create_service_worker_host = |
| 396 navigation_handle_->service_worker_handle() && | 387 navigation_handle_->service_worker_handle() && |
| 397 navigation_handle_->service_worker_handle() | 388 navigation_handle_->service_worker_handle() |
| 398 ->service_worker_provider_host_id() != | 389 ->service_worker_provider_host_id() != |
| 399 kInvalidServiceWorkerProviderId; | 390 kInvalidServiceWorkerProviderId; |
| 400 request_params_.service_worker_provider_id = | 391 request_params_.service_worker_provider_id = |
| 401 did_create_service_worker_host | 392 did_create_service_worker_host |
| 402 ? navigation_handle_->service_worker_handle() | 393 ? navigation_handle_->service_worker_handle() |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 426 } | 417 } |
| 427 | 418 |
| 428 if (navigation_data) | 419 if (navigation_data) |
| 429 navigation_handle_->set_navigation_data(std::move(navigation_data)); | 420 navigation_handle_->set_navigation_data(std::move(navigation_data)); |
| 430 | 421 |
| 431 // Store the response and the StreamHandle until checks have been processed. | 422 // Store the response and the StreamHandle until checks have been processed. |
| 432 response_ = response; | 423 response_ = response; |
| 433 body_ = std::move(body); | 424 body_ = std::move(body); |
| 434 | 425 |
| 435 // Check if the navigation should be allowed to proceed. | 426 // Check if the navigation should be allowed to proceed. |
| 436 // TODO(clamy): pass the right values for request_id, is_download and | 427 // TODO(clamy): pass the right values for request_id and is_stream. |
| 437 // is_stream. | |
| 438 navigation_handle_->WillProcessResponse( | 428 navigation_handle_->WillProcessResponse( |
| 439 render_frame_host, response->head.headers.get(), | 429 render_frame_host, response->head.headers.get(), |
| 440 response->head.connection_info, ssl_status, GlobalRequestID(), | 430 response->head.connection_info, ssl_status, GlobalRequestID(), |
| 441 common_params_.should_replace_current_entry, false, false, | 431 common_params_.should_replace_current_entry, is_download, false, |
|
clamy
2016/11/25 10:46:00
Could we pass the values for is_stream and GlobalR
yzshen1
2016/11/28 22:03:59
Done.
| |
| 442 base::Closure(), | 432 base::Closure(), |
| 443 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, | 433 base::Bind(&NavigationRequest::OnWillProcessResponseChecksComplete, |
| 444 base::Unretained(this))); | 434 base::Unretained(this))); |
| 445 } | 435 } |
| 446 | 436 |
| 447 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, | 437 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, |
| 448 int net_error) { | 438 int net_error) { |
| 449 DCHECK(state_ == STARTED); | 439 DCHECK(state_ == STARTED); |
| 450 state_ = FAILED; | 440 state_ = FAILED; |
| 451 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); | 441 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 } | 551 } |
| 562 | 552 |
| 563 loader_->FollowRedirect(); | 553 loader_->FollowRedirect(); |
| 564 } | 554 } |
| 565 | 555 |
| 566 void NavigationRequest::OnWillProcessResponseChecksComplete( | 556 void NavigationRequest::OnWillProcessResponseChecksComplete( |
| 567 NavigationThrottle::ThrottleCheckResult result) { | 557 NavigationThrottle::ThrottleCheckResult result) { |
| 568 CHECK(result != NavigationThrottle::DEFER); | 558 CHECK(result != NavigationThrottle::DEFER); |
| 569 | 559 |
| 570 // Abort the request if needed. This will destroy the NavigationRequest. | 560 // Abort the request if needed. This will destroy the NavigationRequest. |
| 571 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 561 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { |
| 572 result == NavigationThrottle::CANCEL) { | 562 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( |
| 573 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 563 navigation_handle_.get()); |
| 574 frame_tree_node_->ResetNavigationRequest(false); | 564 frame_tree_node_->ResetNavigationRequest(false); |
| 575 return; | 565 return; |
| 576 } | 566 } |
| 567 if (result == NavigationThrottle::CANCEL) { | |
| 568 frame_tree_node_->ResetNavigationRequest(false); | |
| 569 return; | |
| 570 } | |
| 577 | 571 |
| 578 // Have the processing of the response resume in the network stack. | 572 // Have the processing of the response resume in the network stack. |
| 579 loader_->ProceedWithResponse(); | 573 loader_->ProceedWithResponse(); |
| 580 | 574 |
| 581 CommitNavigation(); | 575 CommitNavigation(); |
| 582 | 576 |
| 583 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused | 577 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused |
| 584 // the destruction of the NavigationRequest. | 578 // the destruction of the NavigationRequest. |
| 585 } | 579 } |
| 586 | 580 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 601 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 595 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
| 602 | 596 |
| 603 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 597 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
| 604 common_params_, request_params_, | 598 common_params_, request_params_, |
| 605 is_view_source_); | 599 is_view_source_); |
| 606 | 600 |
| 607 frame_tree_node_->ResetNavigationRequest(true); | 601 frame_tree_node_->ResetNavigationRequest(true); |
| 608 } | 602 } |
| 609 | 603 |
| 610 } // namespace content | 604 } // namespace content |
| OLD | NEW |