Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2698623006: PlzNavigate: add support for BLOCK_REQUEST during redirects (Closed)
Patch Set: Abandon support of BLOCK_REQUEST on redirect without PlzNavigate. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_handle_impl_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/appcache/appcache_navigation_handle.h" 10 #include "content/browser/appcache/appcache_navigation_handle.h"
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); 688 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START);
689 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); 689 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0);
690 DCHECK(state_ != DEFERRING_START || next_index_ != 0); 690 DCHECK(state_ != DEFERRING_START || 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]->WillStartRequest(); 693 throttles_[i]->WillStartRequest();
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 case NavigationThrottle::BLOCK_REQUEST:
701 state_ = CANCELING; 701 state_ = CANCELING;
702 return result; 702 return result;
703 703
704 case NavigationThrottle::DEFER: 704 case NavigationThrottle::DEFER:
705 state_ = DEFERRING_START; 705 state_ = DEFERRING_START;
706 next_index_ = i + 1; 706 next_index_ = i + 1;
707 return result; 707 return result;
708 708
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_SEND_REQUEST; 714 state_ = WILL_SEND_REQUEST;
715 return NavigationThrottle::PROCEED; 715 return NavigationThrottle::PROCEED;
716 } 716 }
717 717
718 NavigationThrottle::ThrottleCheckResult 718 NavigationThrottle::ThrottleCheckResult
719 NavigationHandleImpl::CheckWillRedirectRequest() { 719 NavigationHandleImpl::CheckWillRedirectRequest() {
720 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); 720 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT);
721 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); 721 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0);
722 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); 722 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0);
723 for (size_t i = next_index_; i < throttles_.size(); ++i) { 723 for (size_t i = next_index_; i < throttles_.size(); ++i) {
724 NavigationThrottle::ThrottleCheckResult result = 724 NavigationThrottle::ThrottleCheckResult result =
725 throttles_[i]->WillRedirectRequest(); 725 throttles_[i]->WillRedirectRequest();
726 switch (result) { 726 switch (result) {
727 case NavigationThrottle::PROCEED: 727 case NavigationThrottle::PROCEED:
728 continue; 728 continue;
729 729
730 case NavigationThrottle::BLOCK_REQUEST:
731 CHECK(IsBrowserSideNavigationEnabled())
732 << "BLOCK_REQUEST must not be used on redirect without PlzNavigate";
730 case NavigationThrottle::CANCEL: 733 case NavigationThrottle::CANCEL:
731 case NavigationThrottle::CANCEL_AND_IGNORE: 734 case NavigationThrottle::CANCEL_AND_IGNORE:
732 state_ = CANCELING; 735 state_ = CANCELING;
733 return result; 736 return result;
734 737
735 case NavigationThrottle::DEFER: 738 case NavigationThrottle::DEFER:
736 state_ = DEFERRING_REDIRECT; 739 state_ = DEFERRING_REDIRECT;
737 next_index_ = i + 1; 740 next_index_ = i + 1;
738 return result; 741 return result;
739 742
740 case NavigationThrottle::BLOCK_REQUEST:
741 case NavigationThrottle::BLOCK_RESPONSE: 743 case NavigationThrottle::BLOCK_RESPONSE:
742 NOTREACHED(); 744 NOTREACHED();
743 } 745 }
744 } 746 }
745 next_index_ = 0; 747 next_index_ = 0;
746 state_ = WILL_REDIRECT_REQUEST; 748 state_ = WILL_REDIRECT_REQUEST;
747 749
748 // Notify the delegate that a redirect was encountered and will be followed. 750 // Notify the delegate that a redirect was encountered and will be followed.
749 if (GetDelegate()) 751 if (GetDelegate())
750 GetDelegate()->DidRedirectNavigation(this); 752 GetDelegate()->DidRedirectNavigation(this);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 if (node->current_url().EqualsIgnoringRef(url_)) { 953 if (node->current_url().EqualsIgnoringRef(url_)) {
952 if (found_self_reference) 954 if (found_self_reference)
953 return true; 955 return true;
954 found_self_reference = true; 956 found_self_reference = true;
955 } 957 }
956 } 958 }
957 return false; 959 return false;
958 } 960 }
959 961
960 } // namespace content 962 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_handle_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698