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

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

Issue 1009583003: Add CSP header for resources with an active policy (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: test tweaks Created 5 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: Source/core/frame/csp/ContentSecurityPolicy.cpp
diff --git a/Source/core/frame/csp/ContentSecurityPolicy.cpp b/Source/core/frame/csp/ContentSecurityPolicy.cpp
index 19a7c264f149fc090fdc59220b5e817438ba912b..ad4f31ed859fa9b869875b36fbc6e745a25253bd 100644
--- a/Source/core/frame/csp/ContentSecurityPolicy.cpp
+++ b/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -421,6 +421,16 @@ bool checkDigest(const String& source, uint8_t hashAlgorithmsUsed, const CSPDire
return false;
}
+template <bool (CSPDirectiveList::*hasPolicy)() const>
+bool hasAnyPolicy(const CSPDirectiveListVector& policies)
+{
+ for (const auto& policy : policies) {
+ if ((policy.get()->*hasPolicy)())
+ return true;
+ }
+ return false;
+}
+
bool ContentSecurityPolicy::allowJavaScriptURLs(const String& contextURL, const WTF::OrdinalNumber& contextLine, ContentSecurityPolicy::ReportingStatus reportingStatus) const
{
return isAllowedByAllWithContext<&CSPDirectiveList::allowJavaScriptURLs>(m_policies, contextURL, contextLine, reportingStatus);
@@ -900,6 +910,36 @@ bool ContentSecurityPolicy::experimentalFeaturesEnabled() const
return RuntimeEnabledFeatures::experimentalContentSecurityPolicyFeaturesEnabled();
}
+bool ContentSecurityPolicy::hasScriptPolicy() const
+{
+ return hasAnyPolicy<&CSPDirectiveList::hasScriptPolicy>(m_policies);
+}
+
+bool ContentSecurityPolicy::hasStylePolicy() const
+{
+ return hasAnyPolicy<&CSPDirectiveList::hasStylePolicy>(m_policies);
+}
+
+bool ContentSecurityPolicy::hasImagePolicy() const
+{
+ return hasAnyPolicy<&CSPDirectiveList::hasImagePolicy>(m_policies);
+}
+
+bool ContentSecurityPolicy::hasFontPolicy() const
+{
+ return hasAnyPolicy<&CSPDirectiveList::hasFontPolicy>(m_policies);
+}
+
+bool ContentSecurityPolicy::hasMediaPolicy() const
+{
+ return hasAnyPolicy<&CSPDirectiveList::hasMediaPolicy>(m_policies);
+}
+
+bool ContentSecurityPolicy::hasPluginPolicy() const
+{
+ return hasAnyPolicy<&CSPDirectiveList::hasPluginPolicy>(m_policies);
+}
+
bool ContentSecurityPolicy::urlMatchesSelf(const KURL& url) const
{
return m_selfSource->matches(url, DidNotRedirect);
« Source/core/frame/csp/CSPDirectiveList.cpp ('K') | « Source/core/frame/csp/ContentSecurityPolicy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698