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

Unified Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2729433003: PlzNavigate: add support for BLOCK_REQUEST during redirects (Closed)
Patch Set: Addressed nits Created 3 years, 10 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigation_handle_impl.cc
diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc
index ae93eee9f77a981de15ff9d82434a3fe7141a09b..7c62aa429f8cd250a2092f50d8745d0cd9cea10e 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -317,6 +317,18 @@ void NavigationHandleImpl::Resume() {
result = CheckWillStartRequest();
} else if (state_ == DEFERRING_REDIRECT) {
result = CheckWillRedirectRequest();
+ if (!IsBrowserSideNavigationEnabled() &&
+ result != NavigationThrottle::PROCEED &&
+ result != NavigationThrottle::DEFER) {
+ // The renderer will not be informed of the redirect, as the navigation
+ // will have been cancelled before sending the
+ // ResourceMsg_ReceivedRedirect IPC. Reset the URL of the NavigationHandle
+ // to the URL it had prior to the redirect, to match the commit of an
+ // error page.
+ redirect_chain_.pop_back();
+ DCHECK(!redirect_chain_.empty());
+ url_ = redirect_chain_.back();
+ }
} else {
result = CheckWillProcessResponse();
@@ -563,14 +575,27 @@ void NavigationHandleImpl::WillRedirectRequest(
state_ = WILL_REDIRECT_REQUEST;
complete_callback_ = callback;
+ // Notify each throttle of the request.
+ NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER;
if (IsSelfReferentialURL()) {
state_ = CANCELING;
- RunCompleteCallback(NavigationThrottle::CANCEL);
- return;
+ result = NavigationThrottle::CANCEL;
+ } else {
+ result = CheckWillRedirectRequest();
}
- // Notify each throttle of the request.
- NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest();
+ if (!IsBrowserSideNavigationEnabled() &&
+ result != NavigationThrottle::PROCEED &&
+ result != NavigationThrottle::DEFER) {
+ // The renderer will not be informed of the redirect, as the navigation
+ // will have been cancelled before sending the
+ // ResourceMsg_ReceivedRedirect IPC. Reset the URL of the NavigationHandle
+ // to the URL it had prior to the redirect, to match the commit of an
+ // error page.
+ redirect_chain_.pop_back();
+ DCHECK(!redirect_chain_.empty());
+ url_ = redirect_chain_.back();
+ }
// If the navigation is not deferred, run the callback.
if (result != NavigationThrottle::DEFER)
@@ -681,9 +706,9 @@ NavigationHandleImpl::CheckWillStartRequest() {
case NavigationThrottle::PROCEED:
continue;
+ case NavigationThrottle::BLOCK_REQUEST:
case NavigationThrottle::CANCEL:
case NavigationThrottle::CANCEL_AND_IGNORE:
- case NavigationThrottle::BLOCK_REQUEST:
state_ = CANCELING;
return result;
@@ -713,6 +738,7 @@ NavigationHandleImpl::CheckWillRedirectRequest() {
case NavigationThrottle::PROCEED:
continue;
+ case NavigationThrottle::BLOCK_REQUEST:
case NavigationThrottle::CANCEL:
case NavigationThrottle::CANCEL_AND_IGNORE:
state_ = CANCELING;
@@ -723,7 +749,6 @@ NavigationHandleImpl::CheckWillRedirectRequest() {
next_index_ = i + 1;
return result;
- case NavigationThrottle::BLOCK_REQUEST:
case NavigationThrottle::BLOCK_RESPONSE:
NOTREACHED();
}
« 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