| 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);
|
|
|