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

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

Issue 2632633006: Implement NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE. (Closed)
Patch Set: Rebase. Created 3 years, 7 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
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 RunCompleteCallback(result); 364 RunCompleteCallback(result);
365 } 365 }
366 } 366 }
367 367
368 void NavigationHandleImpl::CancelDeferredNavigation( 368 void NavigationHandleImpl::CancelDeferredNavigation(
369 NavigationThrottle::ThrottleCheckResult result) { 369 NavigationThrottle::ThrottleCheckResult result) {
370 DCHECK(state_ == DEFERRING_START || 370 DCHECK(state_ == DEFERRING_START ||
371 state_ == DEFERRING_REDIRECT || 371 state_ == DEFERRING_REDIRECT ||
372 state_ == DEFERRING_RESPONSE); 372 state_ == DEFERRING_RESPONSE);
373 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || 373 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE ||
374 result == NavigationThrottle::CANCEL); 374 result == NavigationThrottle::CANCEL ||
375 result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
376 DCHECK(result != NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE ||
377 state_ == DEFERRING_START ||
378 (state_ == DEFERRING_REDIRECT && IsBrowserSideNavigationEnabled()));
379
380 if (result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE)
381 frame_tree_node_->SetCollapsed(true);
382
375 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, 383 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this,
376 "CancelDeferredNavigation"); 384 "CancelDeferredNavigation");
377 state_ = CANCELING; 385 state_ = CANCELING;
378 RunCompleteCallback(result); 386 RunCompleteCallback(result);
379 } 387 }
380 388
381 void NavigationHandleImpl::RegisterThrottleForTesting( 389 void NavigationHandleImpl::RegisterThrottleForTesting(
382 std::unique_ptr<NavigationThrottle> navigation_throttle) { 390 std::unique_ptr<NavigationThrottle> navigation_throttle) {
383 throttles_.push_back(std::move(navigation_throttle)); 391 throttles_.push_back(std::move(navigation_throttle));
384 } 392 }
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 // count it as an error page. 724 // count it as an error page.
717 if (params.base_url.spec() == kUnreachableWebDataURL || 725 if (params.base_url.spec() == kUnreachableWebDataURL ||
718 net_error_code_ != net::OK) { 726 net_error_code_ != net::OK) {
719 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, 727 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this,
720 "DidCommitNavigation: error page"); 728 "DidCommitNavigation: error page");
721 state_ = DID_COMMIT_ERROR_PAGE; 729 state_ = DID_COMMIT_ERROR_PAGE;
722 } else { 730 } else {
723 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, 731 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this,
724 "DidCommitNavigation"); 732 "DidCommitNavigation");
725 state_ = DID_COMMIT; 733 state_ = DID_COMMIT;
734
735 // Getting this far means that the navigation was not blocked, and neither
736 // is this the error page navigation following a blocked navigation. Ensure
737 // the frame owner element is no longer collapsed as a result of a prior
738 // navigation having been blocked with BLOCK_REQUEST_AND_COLLAPSE.
739 if (!frame_tree_node()->IsMainFrame()) {
740 // Collapsed frames show an error page with |kUnreachableWebDataURL|, so a
dcheng 2017/05/10 06:59:46 Nit: "show" seems like a slight misnomer, as the f
engedy 2017/05/15 13:35:51 Done.
741 // same-document navigation should not be possible.
742 DCHECK(!is_same_page_ || !frame_tree_node()->is_collapsed());
743 frame_tree_node()->SetCollapsed(false);
744 }
726 } 745 }
727 } 746 }
728 747
729 void NavigationHandleImpl::Transfer() { 748 void NavigationHandleImpl::Transfer() {
730 DCHECK(!IsBrowserSideNavigationEnabled()); 749 DCHECK(!IsBrowserSideNavigationEnabled());
731 // This is an actual transfer. Inform the NavigationResourceThrottle. This 750 // This is an actual transfer. Inform the NavigationResourceThrottle. This
732 // will allow to mark the URLRequest as transferring. When it is marked as 751 // will allow to mark the URLRequest as transferring. When it is marked as
733 // transferring, the URLRequest can no longer be cancelled by its original 752 // transferring, the URLRequest can no longer be cancelled by its original
734 // RenderFrame. Instead it will persist until being picked up by the transfer 753 // RenderFrame. Instead it will persist until being picked up by the transfer
735 // RenderFrame, even if the original RenderFrame is destroyed. 754 // RenderFrame, even if the original RenderFrame is destroyed.
(...skipping 12 matching lines...) Expand all
748 NavigationThrottle::ThrottleCheckResult result = 767 NavigationThrottle::ThrottleCheckResult result =
749 throttles_[i]->WillStartRequest(); 768 throttles_[i]->WillStartRequest();
750 TRACE_EVENT_ASYNC_STEP_INTO0( 769 TRACE_EVENT_ASYNC_STEP_INTO0(
751 "navigation", "NavigationHandle", this, 770 "navigation", "NavigationHandle", this,
752 base::StringPrintf("CheckWillStartRequest: %s: %d", 771 base::StringPrintf("CheckWillStartRequest: %s: %d",
753 throttles_[i]->GetNameForLogging(), result)); 772 throttles_[i]->GetNameForLogging(), result));
754 switch (result) { 773 switch (result) {
755 case NavigationThrottle::PROCEED: 774 case NavigationThrottle::PROCEED:
756 continue; 775 continue;
757 776
777 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE:
778 frame_tree_node_->SetCollapsed(true); // Fall through.
758 case NavigationThrottle::BLOCK_REQUEST: 779 case NavigationThrottle::BLOCK_REQUEST:
759 case NavigationThrottle::CANCEL: 780 case NavigationThrottle::CANCEL:
760 case NavigationThrottle::CANCEL_AND_IGNORE: 781 case NavigationThrottle::CANCEL_AND_IGNORE:
761 state_ = CANCELING; 782 state_ = CANCELING;
762 return result; 783 return result;
763 784
764 case NavigationThrottle::DEFER: 785 case NavigationThrottle::DEFER:
765 state_ = DEFERRING_START; 786 state_ = DEFERRING_START;
766 next_index_ = i + 1; 787 next_index_ = i + 1;
767 return result; 788 return result;
(...skipping 18 matching lines...) Expand all
786 NavigationThrottle::ThrottleCheckResult result = 807 NavigationThrottle::ThrottleCheckResult result =
787 throttles_[i]->WillRedirectRequest(); 808 throttles_[i]->WillRedirectRequest();
788 TRACE_EVENT_ASYNC_STEP_INTO0( 809 TRACE_EVENT_ASYNC_STEP_INTO0(
789 "navigation", "NavigationHandle", this, 810 "navigation", "NavigationHandle", this,
790 base::StringPrintf("CheckWillRedirectRequest: %s: %d", 811 base::StringPrintf("CheckWillRedirectRequest: %s: %d",
791 throttles_[i]->GetNameForLogging(), result)); 812 throttles_[i]->GetNameForLogging(), result));
792 switch (result) { 813 switch (result) {
793 case NavigationThrottle::PROCEED: 814 case NavigationThrottle::PROCEED:
794 continue; 815 continue;
795 816
817 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE:
818 frame_tree_node_->SetCollapsed(true); // Fall through.
796 case NavigationThrottle::BLOCK_REQUEST: 819 case NavigationThrottle::BLOCK_REQUEST:
797 CHECK(IsBrowserSideNavigationEnabled()) 820 CHECK(IsBrowserSideNavigationEnabled())
798 << "BLOCK_REQUEST must not be used on redirect without PlzNavigate"; 821 << "BLOCK_REQUEST and BLOCK_REQUEST_AND_COLLAPSE must not be used "
822 "on redirect without PlzNavigate";
799 case NavigationThrottle::CANCEL: 823 case NavigationThrottle::CANCEL:
800 case NavigationThrottle::CANCEL_AND_IGNORE: 824 case NavigationThrottle::CANCEL_AND_IGNORE:
801 state_ = CANCELING; 825 state_ = CANCELING;
802 return result; 826 return result;
803 827
804 case NavigationThrottle::DEFER: 828 case NavigationThrottle::DEFER:
805 state_ = DEFERRING_REDIRECT; 829 state_ = DEFERRING_REDIRECT;
806 next_index_ = i + 1; 830 next_index_ = i + 1;
807 return result; 831 return result;
808 832
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 case NavigationThrottle::BLOCK_RESPONSE: 866 case NavigationThrottle::BLOCK_RESPONSE:
843 state_ = CANCELING; 867 state_ = CANCELING;
844 return result; 868 return result;
845 869
846 case NavigationThrottle::DEFER: 870 case NavigationThrottle::DEFER:
847 state_ = DEFERRING_RESPONSE; 871 state_ = DEFERRING_RESPONSE;
848 next_index_ = i + 1; 872 next_index_ = i + 1;
849 return result; 873 return result;
850 874
851 case NavigationThrottle::BLOCK_REQUEST: 875 case NavigationThrottle::BLOCK_REQUEST:
876 case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE:
852 NOTREACHED(); 877 NOTREACHED();
853 } 878 }
854 } 879 }
855 next_index_ = 0; 880 next_index_ = 0;
856 state_ = WILL_PROCESS_RESPONSE; 881 state_ = WILL_PROCESS_RESPONSE;
857 882
858 return NavigationThrottle::PROCEED; 883 return NavigationThrottle::PROCEED;
859 } 884 }
860 885
861 bool NavigationHandleImpl::MaybeTransferAndProceed() { 886 bool NavigationHandleImpl::MaybeTransferAndProceed() {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 if (node->current_url().EqualsIgnoringRef(url_)) { 1072 if (node->current_url().EqualsIgnoringRef(url_)) {
1048 if (found_self_reference) 1073 if (found_self_reference)
1049 return true; 1074 return true;
1050 found_self_reference = true; 1075 found_self_reference = true;
1051 } 1076 }
1052 } 1077 }
1053 return false; 1078 return false;
1054 } 1079 }
1055 1080
1056 } // namespace content 1081 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698