| 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 b1aace3597c5ecd773339efa3b2472beac3db8a7..ff96cba7b1330207420df98728a7691c52698633 100644
|
| --- a/content/browser/frame_host/navigation_handle_impl.cc
|
| +++ b/content/browser/frame_host/navigation_handle_impl.cc
|
| @@ -80,6 +80,14 @@ NavigationHandleImpl::NavigationHandleImpl(const GURL& url,
|
|
|
| NavigationHandleImpl::~NavigationHandleImpl() {
|
| GetDelegate()->DidFinishNavigation(this);
|
| +
|
| + // Cancel the navigation on the IO thread if the NavigationHandle is being
|
| + // destroyed in the middle of the NavigationThrottles checks.
|
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation) &&
|
| + !complete_callback_.is_null()) {
|
| + RunCompleteCallback(NavigationThrottle::CANCEL_AND_IGNORE);
|
| + }
|
| }
|
|
|
| NavigatorDelegate* NavigationHandleImpl::GetDelegate() const {
|
| @@ -160,7 +168,16 @@ void NavigationHandleImpl::Resume() {
|
| }
|
|
|
| if (result != NavigationThrottle::DEFER)
|
| - complete_callback_.Run(result);
|
| + RunCompleteCallback(result);
|
| +}
|
| +
|
| +void NavigationHandleImpl::CancelDeferredNavigation(
|
| + NavigationThrottle::ThrottleCheckResult result) {
|
| + DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT);
|
| + DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE ||
|
| + result == NavigationThrottle::CANCEL);
|
| + state_ = CANCELING;
|
| + RunCompleteCallback(result);
|
| }
|
|
|
| void NavigationHandleImpl::RegisterThrottleForTesting(
|
| @@ -235,7 +252,7 @@ void NavigationHandleImpl::WillStartRequest(
|
|
|
| // If the navigation is not deferred, run the callback.
|
| if (result != NavigationThrottle::DEFER)
|
| - callback.Run(result);
|
| + RunCompleteCallback(result);
|
| }
|
|
|
| void NavigationHandleImpl::WillRedirectRequest(
|
| @@ -259,7 +276,7 @@ void NavigationHandleImpl::WillRedirectRequest(
|
|
|
| // If the navigation is not deferred, run the callback.
|
| if (result != NavigationThrottle::DEFER)
|
| - callback.Run(result);
|
| + RunCompleteCallback(result);
|
| }
|
|
|
| void NavigationHandleImpl::DidRedirectNavigation(const GURL& new_url) {
|
| @@ -296,7 +313,9 @@ NavigationHandleImpl::CheckWillStartRequest() {
|
| case NavigationThrottle::PROCEED:
|
| continue;
|
|
|
| + case NavigationThrottle::CANCEL:
|
| case NavigationThrottle::CANCEL_AND_IGNORE:
|
| + state_ = CANCELING;
|
| return result;
|
|
|
| case NavigationThrottle::DEFER:
|
| @@ -325,7 +344,9 @@ NavigationHandleImpl::CheckWillRedirectRequest() {
|
| case NavigationThrottle::PROCEED:
|
| continue;
|
|
|
| + case NavigationThrottle::CANCEL:
|
| case NavigationThrottle::CANCEL_AND_IGNORE:
|
| + state_ = CANCELING;
|
| return result;
|
|
|
| case NavigationThrottle::DEFER:
|
| @@ -342,4 +363,13 @@ NavigationHandleImpl::CheckWillRedirectRequest() {
|
| return NavigationThrottle::PROCEED;
|
| }
|
|
|
| +void NavigationHandleImpl::RunCompleteCallback(
|
| + NavigationThrottle::ThrottleCheckResult result) {
|
| + DCHECK(result != NavigationThrottle::DEFER);
|
| + if (!complete_callback_.is_null())
|
| + complete_callback_.Run(result);
|
| +
|
| + complete_callback_.Reset();
|
| +}
|
| +
|
| } // namespace content
|
|
|