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

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

Issue 2889003002: Change NavigationEntry to use virtual URL in error pages for blocked navigations (Closed)
Patch Set: Remove reload test since it isn't accessible cross-origin. 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_controller_impl.cc
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc
index 1e0e55b71fc212027d87e08368f5815c83eb9acf..083a0024b9671eb3f3f577b1a12e4d74453a39dd 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -162,6 +162,18 @@ bool ShouldTreatNavigationAsReload(const NavigationEntry* entry) {
return false;
}
+bool IsBlockedNavigation(net::Error error_code) {
Charlie Reis 2017/05/24 16:42:11 Can we include a comment here with some context?
nasko 2017/05/24 20:46:29 Done.
+ switch (error_code) {
+ case net::ERR_BLOCKED_BY_CLIENT:
+ case net::ERR_BLOCKED_BY_RESPONSE:
+ case net::ERR_BLOCKED_BY_XSS_AUDITOR:
+ case net::ERR_UNSAFE_REDIRECT:
+ return true;
+ default:
+ return false;
+ }
+}
+
} // namespace
// NavigationControllerImpl ----------------------------------------------------
@@ -933,6 +945,24 @@ bool NavigationControllerImpl::RendererDidNavigate(
frame_entry->set_redirect_chain(params.redirects);
}
+ // When a navigation in the main frame is blocked, it will display an error
+ // page. To avoid loading the blocked URL on back/forward/reload navigations,
+ // do not store it in the FrameNavigationEntry's URL or PageState. Instead,
+ // make it visible to the user as the virtual URL. Store a safe URL
+ // (about:blank) as the one to load if the entry is revisited.
+ // TODO(nasko): Consider supporting similar behavior for subframe
+ // navigatios, including AUTO_SUBFRAME.
Charlie Reis 2017/05/24 16:42:11 nit: navigations
+ if (!rfh->GetParent() &&
+ IsBlockedNavigation(navigation_handle->GetNetErrorCode())) {
+ DCHECK(params.url_is_unreachable);
+ active_entry->SetURL(GURL(url::kAboutBlankURL));
+ active_entry->SetVirtualURL(params.url);
+ if (frame_entry) {
+ frame_entry->SetPageState(
+ PageState::CreateFromURL(active_entry->GetURL()));
+ }
+ }
+
// Use histogram to track memory impact of redirect chain because it's now
// not cleared for committed entries.
size_t redirect_chain_size = 0;

Powered by Google App Engine
This is Rietveld 408576698