| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 if (!port) | 99 if (!port) |
| 100 return isDefaultPortForProtocol(m_port, protocol); | 100 return isDefaultPortForProtocol(m_port, protocol); |
| 101 | 101 |
| 102 if (!m_port) | 102 if (!m_port) |
| 103 return isDefaultPortForProtocol(port, protocol); | 103 return isDefaultPortForProtocol(port, protocol); |
| 104 | 104 |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool CSPSource::isSubsumingOf(CSPSource* other) { |
| 109 if (!schemeMatches(other->m_scheme)) |
| 110 return false; |
| 111 |
| 112 if (other->isSchemeOnly() || isSchemeOnly()) |
| 113 return isSchemeOnly(); |
| 114 |
| 115 if ((m_hostWildcard == NoWildcard && other->m_hostWildcard == HasWildcard) || |
| 116 (m_portWildcard == NoWildcard && other->m_portWildcard == HasWildcard)) { |
| 117 return false; |
| 118 } |
| 119 |
| 120 bool hostIsSubsumingOf = |
| 121 (m_host == other->m_host || hostMatches(other->m_host)); |
| 122 bool portIsSubsumingOf = (m_portWildcard == HasWildcard) || |
| 123 portMatches(other->m_port, other->m_scheme); |
| 124 bool pathIsSubsumingOf = pathMatches(other->m_path); |
| 125 return hostIsSubsumingOf && portIsSubsumingOf && pathIsSubsumingOf; |
| 126 } |
| 127 |
| 108 bool CSPSource::isSchemeOnly() const { | 128 bool CSPSource::isSchemeOnly() const { |
| 109 return m_host.isEmpty(); | 129 return m_host.isEmpty(); |
| 110 } | 130 } |
| 111 | 131 |
| 112 DEFINE_TRACE(CSPSource) { | 132 DEFINE_TRACE(CSPSource) { |
| 113 visitor->trace(m_policy); | 133 visitor->trace(m_policy); |
| 114 } | 134 } |
| 115 | 135 |
| 116 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |