Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_handle_impl.h" | 5 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/dump_without_crashing.h" | 7 #include "base/debug/dump_without_crashing.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/browser/browsing_data/clear_site_data_throttle.h" | 9 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 GetDelegate()->DidRedirectNavigation(this); | 616 GetDelegate()->DidRedirectNavigation(this); |
| 617 | 617 |
| 618 return NavigationThrottle::PROCEED; | 618 return NavigationThrottle::PROCEED; |
| 619 } | 619 } |
| 620 | 620 |
| 621 NavigationThrottle::ThrottleCheckResult | 621 NavigationThrottle::ThrottleCheckResult |
| 622 NavigationHandleImpl::CheckWillProcessResponse() { | 622 NavigationHandleImpl::CheckWillProcessResponse() { |
| 623 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE); | 623 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE); |
| 624 DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0); | 624 DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0); |
| 625 DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0); | 625 DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0); |
| 626 | |
| 627 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | |
| 628 // commit; they leave the frame showing the previous page. | |
| 629 const bool is_204_205_response = | |
|
clamy
2016/11/25 10:46:00
I'm still not super happy about the code flow here
yzshen1
2016/11/28 22:03:59
Done.
clamy
2016/11/30 17:44:03
Yes this is something we could do as well. Let me
| |
| 630 response_headers_ && (response_headers_->response_code() == 204 || | |
| 631 response_headers_->response_code() == 205); | |
| 632 | |
| 633 // No need to cancel in non-PlzNavigate case. In that case, we will get | |
| 634 // DidFailProvisionalLoadWithError notification from the renderer to abort the | |
| 635 // navigation. | |
| 636 if (IsBrowserSideNavigationEnabled() && | |
| 637 (is_204_205_response || is_download_)) { | |
| 638 net_error_code_ = net::ERR_ABORTED; | |
| 639 state_ = CANCELING; | |
| 640 return NavigationThrottle::CANCEL_AND_IGNORE; | |
| 641 } | |
| 642 | |
| 626 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 643 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 627 NavigationThrottle::ThrottleCheckResult result = | 644 NavigationThrottle::ThrottleCheckResult result = |
| 628 throttles_[i]->WillProcessResponse(); | 645 throttles_[i]->WillProcessResponse(); |
| 629 switch (result) { | 646 switch (result) { |
| 630 case NavigationThrottle::PROCEED: | 647 case NavigationThrottle::PROCEED: |
| 631 continue; | 648 continue; |
| 632 | 649 |
| 633 case NavigationThrottle::CANCEL: | 650 case NavigationThrottle::CANCEL: |
| 634 case NavigationThrottle::CANCEL_AND_IGNORE: | 651 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 635 state_ = CANCELING; | 652 state_ = CANCELING; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 throttles_to_register.push_back(std::move(clear_site_data_throttle)); | 788 throttles_to_register.push_back(std::move(clear_site_data_throttle)); |
| 772 | 789 |
| 773 if (throttles_to_register.size() > 0) { | 790 if (throttles_to_register.size() > 0) { |
| 774 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), | 791 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), |
| 775 throttles_to_register.end()); | 792 throttles_to_register.end()); |
| 776 throttles_to_register.weak_clear(); | 793 throttles_to_register.weak_clear(); |
| 777 } | 794 } |
| 778 } | 795 } |
| 779 | 796 |
| 780 } // namespace content | 797 } // namespace content |
| OLD | NEW |