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

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

Issue 2632633006: Implement NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE. (Closed)
Patch Set: ... and without breaking stuff. Created 3 years, 8 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 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 "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/appcache/appcache_navigation_handle.h" 10 #include "content/browser/appcache/appcache_navigation_handle.h"
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 668 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
669 result == NavigationThrottle::CANCEL) { 669 result == NavigationThrottle::CANCEL) {
670 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 670 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
671 OnRequestFailed(false, net::ERR_ABORTED); 671 OnRequestFailed(false, net::ERR_ABORTED);
672 672
673 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 673 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
674 // destroyed the NavigationRequest. 674 // destroyed the NavigationRequest.
675 return; 675 return;
676 } 676 }
677 677
678 if (result == NavigationThrottle::BLOCK_REQUEST) { 678 if (result == NavigationThrottle::BLOCK_REQUEST ||
679 result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE) {
679 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT); 680 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
680 681
681 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 682 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
682 // destroyed the NavigationRequest. 683 // destroyed the NavigationRequest.
683 return; 684 return;
684 } 685 }
685 686
686 // Use the SiteInstance of the navigating RenderFrameHost to get access to 687 // Use the SiteInstance of the navigating RenderFrameHost to get access to
687 // the StoragePartition. Using the url of the navigation will result in a 688 // the StoragePartition. Using the url of the navigation will result in a
688 // wrong StoragePartition being picked when a WebView is navigating. 689 // wrong StoragePartition being picked when a WebView is navigating.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 } 764 }
764 765
765 void NavigationRequest::OnRedirectChecksComplete( 766 void NavigationRequest::OnRedirectChecksComplete(
766 NavigationThrottle::ThrottleCheckResult result) { 767 NavigationThrottle::ThrottleCheckResult result) {
767 DCHECK(result != NavigationThrottle::DEFER); 768 DCHECK(result != NavigationThrottle::DEFER);
768 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); 769 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE);
769 770
770 // Abort the request if needed. This will destroy the NavigationRequest. 771 // Abort the request if needed. This will destroy the NavigationRequest.
771 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 772 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
772 result == NavigationThrottle::CANCEL) { 773 result == NavigationThrottle::CANCEL) {
773 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 774 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE if needed.
774 OnRequestFailed(false, net::ERR_ABORTED); 775 OnRequestFailed(false, net::ERR_ABORTED);
775 776
776 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 777 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
777 // destroyed the NavigationRequest. 778 // destroyed the NavigationRequest.
778 return; 779 return;
779 } 780 }
780 781
781 if (result == NavigationThrottle::BLOCK_REQUEST) { 782 if (result == NavigationThrottle::BLOCK_REQUEST ||
783 result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE) {
782 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT); 784 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
783
784 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 785 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
785 // destroyed the NavigationRequest. 786 // destroyed the NavigationRequest.
786 return; 787 return;
787 } 788 }
788 789
789 loader_->FollowRedirect(); 790 loader_->FollowRedirect();
790 } 791 }
791 792
792 void NavigationRequest::OnWillProcessResponseChecksComplete( 793 void NavigationRequest::OnWillProcessResponseChecksComplete(
793 NavigationThrottle::ThrottleCheckResult result) { 794 NavigationThrottle::ThrottleCheckResult result) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 841 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
841 842
842 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 843 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
843 common_params_, request_params_, 844 common_params_, request_params_,
844 is_view_source_); 845 is_view_source_);
845 846
846 frame_tree_node_->ResetNavigationRequest(true, true); 847 frame_tree_node_->ResetNavigationRequest(true, true);
847 } 848 }
848 849
849 } // namespace content 850 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698