Index: third_party/WebKit/Source/core/frame/csp/CSPSource.cpp |
diff --git a/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp b/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp |
index 7b6be14df07012db9a466cba5bf8d1f89d9e452f..43722fd1a3a30920c13e071cef09bed41c5e5464 100644 |
--- a/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp |
+++ b/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp |
@@ -105,6 +105,26 @@ bool CSPSource::portMatches(int port, const String& protocol) const { |
return false; |
} |
+bool CSPSource::isSubsumingOf(CSPSource* other) { |
+ if (!schemeMatches(other->m_scheme)) |
+ return false; |
+ |
+ if (other->isSchemeOnly() || isSchemeOnly()) |
+ return isSchemeOnly(); |
+ |
+ if ((m_hostWildcard == NoWildcard && other->m_hostWildcard == HasWildcard) || |
+ (m_portWildcard == NoWildcard && other->m_portWildcard == HasWildcard)) { |
+ return false; |
+ } |
+ |
+ bool hostIsSubsumingOf = |
+ (m_host == other->m_host || hostMatches(other->m_host)); |
+ bool portIsSubsumingOf = (m_portWildcard == HasWildcard) || |
+ portMatches(other->m_port, other->m_scheme); |
+ bool pathIsSubsumingOf = pathMatches(other->m_path); |
+ return hostIsSubsumingOf && portIsSubsumingOf && pathIsSubsumingOf; |
+} |
+ |
bool CSPSource::isSchemeOnly() const { |
return m_host.isEmpty(); |
} |