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

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

Issue 2632633006: Implement NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE. (Closed)
Patch Set: Fix navigation transition type. 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 side-by-side diff with in-line comments
Download patch
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 c4524a8a7c3e821dcff3c9d33ec625071afdc5bc..80e02b288094d36fef2d2a9f0bcf2fc9ed94d449 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -371,7 +371,15 @@ void NavigationHandleImpl::CancelDeferredNavigation(
state_ == DEFERRING_REDIRECT ||
state_ == DEFERRING_RESPONSE);
DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE ||
- result == NavigationThrottle::CANCEL);
+ result == NavigationThrottle::CANCEL ||
+ result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
+ DCHECK(result != NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE ||
+ state_ == DEFERRING_START ||
+ (state_ == DEFERRING_REDIRECT && IsBrowserSideNavigationEnabled()));
+
+ if (result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE)
+ frame_tree_node_->SetCollapsed(true);
+
TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this,
"CancelDeferredNavigation");
state_ = CANCELING;
@@ -723,6 +731,17 @@ void NavigationHandleImpl::DidCommitNavigation(
TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this,
"DidCommitNavigation");
state_ = DID_COMMIT;
+
+ // Getting this far means that the navigation was not blocked, and neither
+ // is this the error page navigation following a blocked navigation. Ensure
+ // the frame owner element is no longer collapsed as a result of a prior
+ // navigation having been blocked with BLOCK_REQUEST_AND_COLLAPSE.
+ if (!frame_tree_node()->IsMainFrame()) {
+ // The last committed load in collapsed frames will be an error page with
+ // |kUnreachableWebDataURL|. Same-page navigation should not be possible.
+ DCHECK(!is_same_page_ || !frame_tree_node()->is_collapsed());
+ frame_tree_node()->SetCollapsed(false);
+ }
}
}
@@ -755,6 +774,8 @@ NavigationHandleImpl::CheckWillStartRequest() {
case NavigationThrottle::PROCEED:
continue;
+ case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE:
+ frame_tree_node_->SetCollapsed(true); // Fall through.
case NavigationThrottle::BLOCK_REQUEST:
case NavigationThrottle::CANCEL:
case NavigationThrottle::CANCEL_AND_IGNORE:
@@ -793,9 +814,12 @@ NavigationHandleImpl::CheckWillRedirectRequest() {
case NavigationThrottle::PROCEED:
continue;
+ case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE:
+ frame_tree_node_->SetCollapsed(true); // Fall through.
case NavigationThrottle::BLOCK_REQUEST:
CHECK(IsBrowserSideNavigationEnabled())
- << "BLOCK_REQUEST must not be used on redirect without PlzNavigate";
+ << "BLOCK_REQUEST and BLOCK_REQUEST_AND_COLLAPSE must not be used "
+ "on redirect without PlzNavigate";
case NavigationThrottle::CANCEL:
case NavigationThrottle::CANCEL_AND_IGNORE:
state_ = CANCELING;
@@ -849,6 +873,7 @@ NavigationHandleImpl::CheckWillProcessResponse() {
return result;
case NavigationThrottle::BLOCK_REQUEST:
+ case NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE:
NOTREACHED();
}
}
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/browser/frame_host/navigation_handle_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698