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

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

Issue 2702503002: Block renderer-initiated main frame navigations to data URLs (Closed)
Patch Set: Fix Android PDF tests where PDFs should be downloaded Created 3 years, 8 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 8dca64448352d1df95c7755808d80e7f7a8b84a0..b86f81e89e52b60d02019c29c55f12e710a23771 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -13,6 +13,7 @@
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/devtools/render_frame_devtools_agent_host.h"
#include "content/browser/frame_host/ancestor_throttle.h"
+#include "content/browser/frame_host/data_url_navigation_throttle.h"
#include "content/browser/frame_host/debug_urls.h"
#include "content/browser/frame_host/form_submission_throttle.h"
#include "content/browser/frame_host/frame_tree_node.h"
@@ -681,14 +682,6 @@ void NavigationHandleImpl::DidCommitNavigation(
} else {
state_ = DID_COMMIT;
}
-
- if (url_.SchemeIs(url::kDataScheme) && IsInMainFrame() &&
- IsRendererInitiated()) {
- GetRenderFrameHost()->AddMessageToConsole(
- CONSOLE_MESSAGE_LEVEL_WARNING,
- "Upcoming versions will block content-initiated top frame navigations "
- "to data: URLs. For more information, see https://goo.gl/BaZAea.");
- }
}
void NavigationHandleImpl::Transfer() {
@@ -930,6 +923,13 @@ void NavigationHandleImpl::RegisterNavigationThrottles() {
std::vector<std::unique_ptr<NavigationThrottle>> throttles_to_register =
GetDelegate()->CreateThrottlesForNavigation(this);
+ // Check for renderer-inititated main frame navigations to data URLs. This is
+ // done first as it may block the main frame navigation altogether.
+ std::unique_ptr<NavigationThrottle> data_url_navigation_throttle =
+ DataUrlNavigationThrottle::CreateThrottleForNavigation(this);
+ if (data_url_navigation_throttle)
+ throttles_to_register.push_back(std::move(data_url_navigation_throttle));
+
std::unique_ptr<content::NavigationThrottle> ancestor_throttle =
content::AncestorThrottle::MaybeCreateThrottleFor(this);
if (ancestor_throttle)
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.h ('k') | content/browser/web_contents/web_contents_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698