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 0d2dfe1a4f3665f150cde6ff3d3be7004ab91d68..d54d4ddfbcbf6bcc36dfd6db0c55c255f56c032f 100644 |
--- a/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp |
+++ b/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp |
@@ -162,6 +162,27 @@ bool CSPSource::isSchemeOnly() const { |
return m_host.isEmpty(); |
} |
+bool CSPSource::firstSubsumesSecond(HeapVector<Member<CSPSource>> listA, |
+ HeapVector<Member<CSPSource>> listB) { |
+ // Empty vector of CSPSources has an effect of 'none'. |
+ if (!listA.size() || !listB.size()) |
+ return !listB.size(); |
+ |
+ // Walk through all the items in |listB|, ensuring that each is subsumed by at |
+ // least one item in |listA|. If any item in |listB| is not subsumed, return |
+ // false. |
+ for (const auto& sourceB : listB) { |
+ bool foundMatch = false; |
+ for (const auto& sourceA : listA) { |
+ if ((foundMatch = sourceA->subsumes(sourceB))) |
+ break; |
+ } |
+ if (!foundMatch) |
+ return false; |
+ } |
+ return true; |
+} |
+ |
DEFINE_TRACE(CSPSource) { |
visitor->trace(m_policy); |
} |