Chromium Code Reviews| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 return true; | 138 return true; |
| 139 | 139 |
| 140 return false; | 140 return false; |
| 141 } | 141 } |
| 142 | 142 |
| 143 CSPSource* CSPSource::intersect(CSPSource* other) { | 143 CSPSource* CSPSource::intersect(CSPSource* other) { |
| 144 if (!isSimilar(other)) | 144 if (!isSimilar(other)) |
| 145 return nullptr; | 145 return nullptr; |
| 146 | 146 |
| 147 String scheme = other->schemeMatches(m_scheme) ? m_scheme : other->m_scheme; | 147 String scheme = other->schemeMatches(m_scheme) ? m_scheme : other->m_scheme; |
| 148 if (isSchemeOnly() || other->isSchemeOnly()) { | |
|
Mike West
2016/11/17 10:58:31
Unit test?
amalika
2016/11/19 18:34:32
Added `IntersectSchemesOnly`!
(and test `Intersect
| |
| 149 CSPSource* stricter = isSchemeOnly() ? other : this; | |
| 150 return new CSPSource(m_policy, scheme, stricter->m_host, stricter->m_port, | |
| 151 stricter->m_path, stricter->m_hostWildcard, | |
| 152 stricter->m_portWildcard); | |
| 153 } | |
| 154 | |
| 148 String host = m_hostWildcard == NoWildcard ? m_host : other->m_host; | 155 String host = m_hostWildcard == NoWildcard ? m_host : other->m_host; |
| 149 String path = other->pathMatches(m_path) ? m_path : other->m_path; | 156 String path = other->pathMatches(m_path) ? m_path : other->m_path; |
| 150 int port = (other->m_portWildcard == HasWildcard || !other->m_port) | 157 int port = (other->m_portWildcard == HasWildcard || !other->m_port) |
| 151 ? m_port | 158 ? m_port |
| 152 : other->m_port; | 159 : other->m_port; |
| 153 WildcardDisposition hostWildcard = | 160 WildcardDisposition hostWildcard = |
| 154 (m_hostWildcard == HasWildcard) ? other->m_hostWildcard : m_hostWildcard; | 161 (m_hostWildcard == HasWildcard) ? other->m_hostWildcard : m_hostWildcard; |
| 155 WildcardDisposition portWildcard = | 162 WildcardDisposition portWildcard = |
| 156 (m_portWildcard == HasWildcard) ? other->m_portWildcard : m_portWildcard; | 163 (m_portWildcard == HasWildcard) ? other->m_portWildcard : m_portWildcard; |
| 157 return new CSPSource(m_policy, scheme, host, port, path, hostWildcard, | 164 return new CSPSource(m_policy, scheme, host, port, path, hostWildcard, |
| 158 portWildcard); | 165 portWildcard); |
| 159 } | 166 } |
| 160 | 167 |
| 161 bool CSPSource::isSchemeOnly() const { | 168 bool CSPSource::isSchemeOnly() const { |
| 162 return m_host.isEmpty(); | 169 return m_host.isEmpty(); |
| 163 } | 170 } |
| 164 | 171 |
| 165 DEFINE_TRACE(CSPSource) { | 172 DEFINE_TRACE(CSPSource) { |
| 166 visitor->trace(m_policy); | 173 visitor->trace(m_policy); |
| 167 } | 174 } |
| 168 | 175 |
| 169 } // namespace blink | 176 } // namespace blink |
| OLD | NEW |