Chromium Code Reviews| 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..5e2134e5ec5e6a7df132feeb4b1296e7f1a121ee 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; |
| - if (IsSelfReferentialURL()) { |
| + // Notify each throttle of the request. |
| + NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| + if (!IsSelfReferentialURL()) { |
|
nasko
2017/03/01 18:12:43
nit: It is easier to read the positive statement,
clamy
2017/03/02 12:43:17
Done.
|
| + result = CheckWillRedirectRequest(); |
| + } else { |
| state_ = CANCELING; |
| - RunCompleteCallback(NavigationThrottle::CANCEL); |
| - return; |
| + result = NavigationThrottle::CANCEL; |
| } |
| - // 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(); |
| } |