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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 DCHECK(state_ == STARTED); | 379 DCHECK(state_ == STARTED); |
| 380 state_ = RESPONSE_STARTED; | 380 state_ = RESPONSE_STARTED; |
| 381 | 381 |
| 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); | 382 DCHECK(response); |
| 385 if (response->head.headers.get() && | |
| 386 (response->head.headers->response_code() == 204 || | |
| 387 response->head.headers->response_code() == 205)) { | |
|
clamy
2016/11/21 16:57:14
If the issue is just the error code in the Navigat
yzshen1
2016/11/21 17:52:50
At least MetricsWebContentsObserver::DidFinishNavi
| |
| 388 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( | |
| 389 navigation_handle_.get()); | |
| 390 frame_tree_node_->ResetNavigationRequest(false); | |
| 391 return; | |
| 392 } | |
| 393 | 383 |
| 394 // Update the service worker params of the request params. | 384 // Update the service worker params of the request params. |
| 395 bool did_create_service_worker_host = | 385 bool did_create_service_worker_host = |
| 396 navigation_handle_->service_worker_handle() && | 386 navigation_handle_->service_worker_handle() && |
| 397 navigation_handle_->service_worker_handle() | 387 navigation_handle_->service_worker_handle() |
| 398 ->service_worker_provider_host_id() != | 388 ->service_worker_provider_host_id() != |
| 399 kInvalidServiceWorkerProviderId; | 389 kInvalidServiceWorkerProviderId; |
| 400 request_params_.service_worker_provider_id = | 390 request_params_.service_worker_provider_id = |
| 401 did_create_service_worker_host | 391 did_create_service_worker_host |
| 402 ? navigation_handle_->service_worker_handle() | 392 ? navigation_handle_->service_worker_handle() |
| (...skipping 158 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 |