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

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: Add a test for reload. 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..9352302e6d32cac26ae991693029441b11bfc513 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -162,6 +162,26 @@ bool ShouldTreatNavigationAsReload(const NavigationEntry* entry) {
return false;
}
+bool IsBlockedNavigation(net::Error error_code) {
+ switch (error_code) {
Charlie Reis 2017/05/18 22:41:46 I'm nervous about hand picking these out of net_er
nasko 2017/05/18 22:55:11 I don't think that such a distinction exists actua
+ case net::ERR_ACCESS_DENIED:
+ case net::ERR_NOT_IMPLEMENTED:
+ case net::ERR_BLOCKED_BY_CLIENT:
+ case net::ERR_BLOCKED_BY_ADMINISTRATOR:
+ case net::ERR_BLOCKED_BY_RESPONSE:
+ case net::ERR_BLOCKED_BY_XSS_AUDITOR:
+ case net::ERR_CLEARTEXT_NOT_PERMITTED:
+ case net::ERR_NETWORK_ACCESS_DENIED: // Does this mean blocked?
Charlie Reis 2017/05/18 22:41:46 I would probably remove this. Network access deni
nasko 2017/05/18 22:55:11 My goal was to pick the errors that aren't transie
+ case net::ERR_INVALID_URL:
Charlie Reis 2017/05/18 22:41:46 Should we remove this to get the test to pass, or
nasko 2017/05/18 22:55:11 I don't think the test is doing what it is expecti
Charlie Reis 2017/05/18 23:15:51 Agreed-- let's look more closely at it tomorrow.
+ case net::ERR_DISALLOWED_URL_SCHEME:
+ case net::ERR_UNSAFE_REDIRECT:
+ case net::ERR_UNSAFE_PORT:
+ return true;
+ default:
+ return false;
+ }
+}
+
} // namespace
// NavigationControllerImpl ----------------------------------------------------
@@ -933,6 +953,22 @@ 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 committing the blocked URL in back/forward/reload
+ // navigations, ensure the underlying URL is safe to load and preserve the
+ // UX by setting the blocked URL as the virtual URL on |active_entry|. To
+ // ensure the renderer process doesn't also navigate there, overwrite the
+ // PageState with a new one.
Charlie Reis 2017/05/18 22:41:46 Sounds good. Slight rephrase: ... To avoid loadi
nasko 2017/05/18 22:55:11 Done.
+ if (!rfh->GetParent() &&
+ IsBlockedNavigation(navigation_handle->GetNetErrorCode())) {
+ DCHECK(params.url_is_unreachable);
Charlie Reis 2017/05/18 22:41:46 Heh, I have some mixed feelings here. We generall
nasko 2017/05/18 22:55:11 I wanted it mainly for discovering potential issue
+ active_entry->SetURL(GURL(url::kAboutBlankURL));
+ active_entry->SetVirtualURL(params.url);
+ if (frame_entry)
Charlie Reis 2017/05/18 22:41:46 nit: Needs braces.
nasko 2017/05/18 22:55:11 Done.
+ 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