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()) { |
| 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, |
(...skipping 23 matching lines...) Expand all Loading... |
181 return false; | 188 return false; |
182 } | 189 } |
183 return true; | 190 return true; |
184 } | 191 } |
185 | 192 |
186 DEFINE_TRACE(CSPSource) { | 193 DEFINE_TRACE(CSPSource) { |
187 visitor->trace(m_policy); | 194 visitor->trace(m_policy); |
188 } | 195 } |
189 | 196 |
190 } // namespace blink | 197 } // namespace blink |
OLD | NEW |