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 "config.h" | 5 #include "config.h" |
6 #include "core/frame/csp/CSPSource.h" | 6 #include "core/frame/csp/CSPSource.h" |
7 | 7 |
8 #include "core/frame/UseCounter.h" | 8 #include "core/frame/UseCounter.h" |
9 #include "core/frame/csp/ContentSecurityPolicy.h" | 9 #include "core/frame/csp/ContentSecurityPolicy.h" |
10 #include "platform/weborigin/KURL.h" | 10 #include "platform/weborigin/KURL.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 if (isSchemeOnly()) | 32 if (isSchemeOnly()) |
33 return true; | 33 return true; |
34 bool pathsMatch = (redirectStatus == ContentSecurityPolicy::DidRedirect) ||
pathMatches(url); | 34 bool pathsMatch = (redirectStatus == ContentSecurityPolicy::DidRedirect) ||
pathMatches(url); |
35 return hostMatches(url) && portMatches(url) && pathsMatch; | 35 return hostMatches(url) && portMatches(url) && pathsMatch; |
36 } | 36 } |
37 | 37 |
38 bool CSPSource::schemeMatches(const KURL& url) const | 38 bool CSPSource::schemeMatches(const KURL& url) const |
39 { | 39 { |
40 if (m_scheme.isEmpty()) | 40 if (m_scheme.isEmpty()) |
41 return m_policy->protocolMatchesSelf(url); | 41 return m_policy->protocolMatchesSelf(url); |
| 42 if (equalIgnoringCase(m_scheme, "http")) |
| 43 return equalIgnoringCase(url.protocol(), "http") || equalIgnoringCase(ur
l.protocol(), "https"); |
| 44 if (equalIgnoringCase(m_scheme, "ws")) |
| 45 return equalIgnoringCase(url.protocol(), "ws") || equalIgnoringCase(url.
protocol(), "wss"); |
42 return equalIgnoringCase(url.protocol(), m_scheme); | 46 return equalIgnoringCase(url.protocol(), m_scheme); |
43 } | 47 } |
44 | 48 |
45 bool CSPSource::hostMatches(const KURL& url) const | 49 bool CSPSource::hostMatches(const KURL& url) const |
46 { | 50 { |
47 const String& host = url.host(); | 51 const String& host = url.host(); |
48 Document* document = m_policy->document(); | 52 Document* document = m_policy->document(); |
49 bool match; | 53 bool match; |
50 | 54 |
51 bool equalHosts = equalIgnoringCase(host, m_host); | 55 bool equalHosts = equalIgnoringCase(host, m_host); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 100 |
97 return false; | 101 return false; |
98 } | 102 } |
99 | 103 |
100 bool CSPSource::isSchemeOnly() const | 104 bool CSPSource::isSchemeOnly() const |
101 { | 105 { |
102 return m_host.isEmpty(); | 106 return m_host.isEmpty(); |
103 } | 107 } |
104 | 108 |
105 } // namespace | 109 } // namespace |
OLD | NEW |