| 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 <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/debug/dump_without_crashing.h" | 9 #include "base/debug/dump_without_crashing.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 656 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
| 657 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); | 657 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
| 658 DCHECK(state_ != DEFERRING_START || next_index_ != 0); | 658 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
| 659 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 659 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 660 NavigationThrottle::ThrottleCheckResult result = | 660 NavigationThrottle::ThrottleCheckResult result = |
| 661 throttles_[i]->WillStartRequest(); | 661 throttles_[i]->WillStartRequest(); |
| 662 switch (result) { | 662 switch (result) { |
| 663 case NavigationThrottle::PROCEED: | 663 case NavigationThrottle::PROCEED: |
| 664 continue; | 664 continue; |
| 665 | 665 |
| 666 case NavigationThrottle::BLOCK_REQUEST: |
| 666 case NavigationThrottle::CANCEL: | 667 case NavigationThrottle::CANCEL: |
| 667 case NavigationThrottle::CANCEL_AND_IGNORE: | 668 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 668 case NavigationThrottle::BLOCK_REQUEST: | |
| 669 state_ = CANCELING; | 669 state_ = CANCELING; |
| 670 return result; | 670 return result; |
| 671 | 671 |
| 672 case NavigationThrottle::DEFER: | 672 case NavigationThrottle::DEFER: |
| 673 state_ = DEFERRING_START; | 673 state_ = DEFERRING_START; |
| 674 next_index_ = i + 1; | 674 next_index_ = i + 1; |
| 675 return result; | 675 return result; |
| 676 | 676 |
| 677 case NavigationThrottle::BLOCK_RESPONSE: | 677 case NavigationThrottle::BLOCK_RESPONSE: |
| 678 NOTREACHED(); | 678 NOTREACHED(); |
| 679 } | 679 } |
| 680 } | 680 } |
| 681 next_index_ = 0; | 681 next_index_ = 0; |
| 682 state_ = WILL_SEND_REQUEST; | 682 state_ = WILL_SEND_REQUEST; |
| 683 return NavigationThrottle::PROCEED; | 683 return NavigationThrottle::PROCEED; |
| 684 } | 684 } |
| 685 | 685 |
| 686 NavigationThrottle::ThrottleCheckResult | 686 NavigationThrottle::ThrottleCheckResult |
| 687 NavigationHandleImpl::CheckWillRedirectRequest() { | 687 NavigationHandleImpl::CheckWillRedirectRequest() { |
| 688 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); | 688 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); |
| 689 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); | 689 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); |
| 690 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); | 690 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); |
| 691 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 691 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 692 NavigationThrottle::ThrottleCheckResult result = | 692 NavigationThrottle::ThrottleCheckResult result = |
| 693 throttles_[i]->WillRedirectRequest(); | 693 throttles_[i]->WillRedirectRequest(); |
| 694 switch (result) { | 694 switch (result) { |
| 695 case NavigationThrottle::PROCEED: | 695 case NavigationThrottle::PROCEED: |
| 696 continue; | 696 continue; |
| 697 | 697 |
| 698 case NavigationThrottle::BLOCK_REQUEST: |
| 698 case NavigationThrottle::CANCEL: | 699 case NavigationThrottle::CANCEL: |
| 699 case NavigationThrottle::CANCEL_AND_IGNORE: | 700 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 700 state_ = CANCELING; | 701 state_ = CANCELING; |
| 701 return result; | 702 return result; |
| 702 | 703 |
| 703 case NavigationThrottle::DEFER: | 704 case NavigationThrottle::DEFER: |
| 704 state_ = DEFERRING_REDIRECT; | 705 state_ = DEFERRING_REDIRECT; |
| 705 next_index_ = i + 1; | 706 next_index_ = i + 1; |
| 706 return result; | 707 return result; |
| 707 | 708 |
| 708 case NavigationThrottle::BLOCK_REQUEST: | |
| 709 case NavigationThrottle::BLOCK_RESPONSE: | 709 case NavigationThrottle::BLOCK_RESPONSE: |
| 710 NOTREACHED(); | 710 NOTREACHED(); |
| 711 } | 711 } |
| 712 } | 712 } |
| 713 next_index_ = 0; | 713 next_index_ = 0; |
| 714 state_ = WILL_REDIRECT_REQUEST; | 714 state_ = WILL_REDIRECT_REQUEST; |
| 715 | 715 |
| 716 // Notify the delegate that a redirect was encountered and will be followed. | 716 // Notify the delegate that a redirect was encountered and will be followed. |
| 717 if (GetDelegate()) | 717 if (GetDelegate()) |
| 718 GetDelegate()->DidRedirectNavigation(this); | 718 GetDelegate()->DidRedirectNavigation(this); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 content::AncestorThrottle::MaybeCreateThrottleFor(this); | 883 content::AncestorThrottle::MaybeCreateThrottleFor(this); |
| 884 if (ancestor_throttle) | 884 if (ancestor_throttle) |
| 885 throttles_.push_back(std::move(ancestor_throttle)); | 885 throttles_.push_back(std::move(ancestor_throttle)); |
| 886 | 886 |
| 887 throttles_.insert(throttles_.begin(), | 887 throttles_.insert(throttles_.begin(), |
| 888 std::make_move_iterator(throttles_to_register.begin()), | 888 std::make_move_iterator(throttles_to_register.begin()), |
| 889 std::make_move_iterator(throttles_to_register.end())); | 889 std::make_move_iterator(throttles_to_register.end())); |
| 890 } | 890 } |
| 891 | 891 |
| 892 } // namespace content | 892 } // namespace content |
| OLD | NEW |