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

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 downloads, plugin handling and browser side navigations Created 3 years, 9 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 c20e6bd5656d752813bcb5d31c12cdcbdc862b7e..8dd3a69002c45ffab19741d3e58cf8c04916f122 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/frame_tree_node.h"
#include "content/browser/frame_host/mixed_content_navigation_throttle.h"
@@ -282,6 +283,10 @@ bool NavigationHandleImpl::HasCommitted() {
return state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE;
}
+bool NavigationHandleImpl::IsDownload() {
+ return is_download_;
+}
+
bool NavigationHandleImpl::IsErrorPage() {
return state_ == DID_COMMIT_ERROR_PAGE;
}
@@ -660,14 +665,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() {
@@ -922,6 +919,11 @@ void NavigationHandleImpl::RegisterNavigationThrottles() {
if (clear_site_data_throttle)
throttles_to_register.push_back(std::move(clear_site_data_throttle));
+ 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)

Powered by Google App Engine
This is Rietveld 408576698