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

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

Issue 1957783002: Replicate Content-Security-Policy into remote frame proxies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test for inheriting CSP via srcdoc frame. Created 4 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
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/browser/frame_host/render_frame_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 894f6ea13c0bced481e0404917b7837f41a1c2d4..b2fbbb702e147559ab438d4d14b95faf2986d60d 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -28,6 +28,25 @@ void UpdateThrottleCheckResult(
*to_update = result;
}
+void ResetContentSecurityPolicyFromHttpHeaders(
+ FrameTreeNode* frame_tree_node,
+ const scoped_refptr<net::HttpResponseHeaders>& response_headers) {
+ frame_tree_node->ResetContentSecurityPolicy();
+
+ ContentSecurityPolicyHeader header;
+ header.source = blink::WebContentSecurityPolicySourceHTTP;
+ if (response_headers->GetNormalizedHeader("Content-Security-Policy",
+ &header.header_value)) {
+ header.type = blink::WebContentSecurityPolicyTypeEnforce;
+ frame_tree_node->AddContentSecurityPolicy(header);
+ }
+ if (response_headers->GetNormalizedHeader(
+ "Content-Security-Policy-Report-Only", &header.header_value)) {
+ header.type = blink::WebContentSecurityPolicyTypeReport;
+ frame_tree_node->AddContentSecurityPolicy(header);
+ }
+}
+
} // namespace
// static
@@ -361,8 +380,11 @@ void NavigationHandleImpl::WillProcessResponse(
NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse();
// If the navigation is about to proceed, then it's ready to commit.
- if (result == NavigationThrottle::PROCEED)
+ if (result == NavigationThrottle::PROCEED) {
ReadyToCommitNavigation(render_frame_host);
+ ResetContentSecurityPolicyFromHttpHeaders(
+ render_frame_host->frame_tree_node(), response_headers);
+ }
// If the navigation is not deferred, run the callback.
if (result != NavigationThrottle::DEFER)
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/browser/frame_host/render_frame_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698