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

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

Issue 549163003: CSP: Change 'self' to ask the policy object whether a URL matches. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | « Source/core/frame/csp/ContentSecurityPolicy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/csp/ContentSecurityPolicy.cpp
diff --git a/Source/core/frame/csp/ContentSecurityPolicy.cpp b/Source/core/frame/csp/ContentSecurityPolicy.cpp
index d06f0afb7cbc83840918a7ad298796d62ccb172c..b65139331b3cc5debda8187643e3ca98a5e4c27b 100644
--- a/Source/core/frame/csp/ContentSecurityPolicy.cpp
+++ b/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -137,6 +137,7 @@ ContentSecurityPolicy::ContentSecurityPolicy(ExecutionContext* executionContext)
, m_scriptHashAlgorithmsUsed(ContentSecurityPolicyHashAlgorithmNone)
, m_styleHashAlgorithmsUsed(ContentSecurityPolicyHashAlgorithmNone)
{
+ m_selfSource = adoptPtr(new CSPSource(this, securityOrigin()->protocol(), securityOrigin()->host(), securityOrigin()->port(), String(), false, false));
}
ContentSecurityPolicy::~ContentSecurityPolicy()
@@ -772,6 +773,19 @@ bool ContentSecurityPolicy::experimentalFeaturesEnabled() const
return RuntimeEnabledFeatures::experimentalContentSecurityPolicyFeaturesEnabled();
}
+bool ContentSecurityPolicy::urlMatchesSelf(const KURL& url) const
+{
+ return m_selfSource->matches(url);
+}
+
+bool ContentSecurityPolicy::protocolMatchesSelf(const KURL& url) const
+{
+ String protectedResourceScheme(securityOrigin()->protocol());
+ if (equalIgnoringCase("http", protectedResourceScheme))
+ return url.protocolIs("http") || url.protocolIs("https");
jochen (gone - plz use gerrit) 2014/09/09 08:11:14 isn't there some protocolIsInHTTPFamily() method?
+ return equalIgnoringCase(url.protocol(), protectedResourceScheme);
+}
+
bool ContentSecurityPolicy::shouldBypassMainWorld(ExecutionContext* context)
{
if (context && context->isDocument()) {
« no previous file with comments | « Source/core/frame/csp/ContentSecurityPolicy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698