| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/frame/csp/CSPSource.h" | 5 #include "core/frame/csp/CSPSource.h" |
| 6 | 6 |
| 7 #include "core/frame/UseCounter.h" | 7 #include "core/frame/UseCounter.h" |
| 8 #include "core/frame/csp/ContentSecurityPolicy.h" | 8 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 9 #include "platform/weborigin/KURL.h" | 9 #include "platform/weborigin/KURL.h" |
| 10 #include "platform/weborigin/KnownPorts.h" | 10 #include "platform/weborigin/KnownPorts.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 WildcardDisposition portWildcard = | 155 WildcardDisposition portWildcard = |
| 156 (m_portWildcard == HasWildcard) ? other->m_portWildcard : m_portWildcard; | 156 (m_portWildcard == HasWildcard) ? other->m_portWildcard : m_portWildcard; |
| 157 return new CSPSource(m_policy, scheme, host, port, path, hostWildcard, | 157 return new CSPSource(m_policy, scheme, host, port, path, hostWildcard, |
| 158 portWildcard); | 158 portWildcard); |
| 159 } | 159 } |
| 160 | 160 |
| 161 bool CSPSource::isSchemeOnly() const { | 161 bool CSPSource::isSchemeOnly() const { |
| 162 return m_host.isEmpty(); | 162 return m_host.isEmpty(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool CSPSource::firstSubsumesSecond(HeapVector<Member<CSPSource>> listA, |
| 166 HeapVector<Member<CSPSource>> listB) { |
| 167 // Empty vector of CSPSources has an effect of 'none'. |
| 168 if (!listA.size() || !listB.size()) |
| 169 return !listB.size(); |
| 170 |
| 171 // Walk through all the items in |listB|, ensuring that each is subsumed by at |
| 172 // least one item in |listA|. If any item in |listB| is not subsumed, return |
| 173 // false. |
| 174 for (const auto& sourceB : listB) { |
| 175 bool foundMatch = false; |
| 176 for (const auto& sourceA : listA) { |
| 177 if ((foundMatch = sourceA->subsumes(sourceB))) |
| 178 break; |
| 179 } |
| 180 if (!foundMatch) |
| 181 return false; |
| 182 } |
| 183 return true; |
| 184 } |
| 185 |
| 165 DEFINE_TRACE(CSPSource) { | 186 DEFINE_TRACE(CSPSource) { |
| 166 visitor->trace(m_policy); | 187 visitor->trace(m_policy); |
| 167 } | 188 } |
| 168 | 189 |
| 169 } // namespace blink | 190 } // namespace blink |
| OLD | NEW |