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

Unified Diff: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp

Issue 2404373003: Experimental Feature: Allow-CSP-From header (Closed)
Patch Set: Better format of ContentSecurityPolicyTest.ShouldEnforceEmbeddersPolicy Created 4 years, 2 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: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
index 3ff396642f61a6722b5b1cf7f35136afc2fc77c1..c82f49fb495336968e1beb3725d94e1b325f8360 100644
--- a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -311,6 +311,30 @@ void ContentSecurityPolicy::didReceiveHeader(
applyPolicySideEffectsToExecutionContext();
}
+bool ContentSecurityPolicy::shouldEnforceEmbeddersPolicy(
+ const ResourceResponse& response,
+ SecurityOrigin* parentOrigin) {
+ if (response.url().isEmpty() || response.url().protocolIsAbout() ||
+ response.url().protocolIsData() || response.url().protocolIs("blob") ||
+ response.url().protocolIs("filesystem")) {
+ return true;
+ }
+
+ if (parentOrigin->canAccess(SecurityOrigin::create(response.url()).get()))
+ return true;
+
+ String header = response.httpHeaderField(HTTPNames::Allow_CSP_From);
+ header = header.stripWhiteSpace();
+ if (header == "*")
+ return true;
+ if (RefPtr<SecurityOrigin> childOrigin =
+ SecurityOrigin::createFromString(header)) {
+ return parentOrigin->canAccess(childOrigin.get());
+ }
+
+ return false;
+}
+
void ContentSecurityPolicy::addPolicyFromHeaderValue(
const String& header,
ContentSecurityPolicyHeaderType type,

Powered by Google App Engine
This is Rietveld 408576698