| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "platform/weborigin/OriginAccessEntry.h" | 31 #include "platform/weborigin/OriginAccessEntry.h" |
| 32 | 32 |
| 33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 33 #include "platform/weborigin/KURL.h" | 34 #include "platform/weborigin/KURL.h" |
| 34 #include "platform/weborigin/SecurityOrigin.h" | 35 #include "platform/weborigin/SecurityOrigin.h" |
| 35 #include "public/platform/Platform.h" | |
| 36 #include "public/platform/WebPublicSuffixList.h" | |
| 37 #include "url/third_party/mozilla/url_parse.h" | 36 #include "url/third_party/mozilla/url_parse.h" |
| 38 #include "url/url_canon.h" | 37 #include "url/url_canon.h" |
| 39 | 38 |
| 40 namespace blink { | 39 namespace blink { |
| 41 | 40 |
| 42 namespace { | 41 namespace { |
| 43 | 42 |
| 44 // TODO(mkwst): This basically replicates GURL::HostIsIPAddress. If/when | 43 // TODO(mkwst): This basically replicates GURL::HostIsIPAddress. If/when |
| 45 // we re-evaluate everything after merging the Blink and Chromium | 44 // we re-evaluate everything after merging the Blink and Chromium |
| 46 // repositories, perhaps we can just use that directly. | 45 // repositories, perhaps we can just use that directly. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 , m_host(host.lower()) | 80 , m_host(host.lower()) |
| 82 , m_subdomainSettings(subdomainSetting) | 81 , m_subdomainSettings(subdomainSetting) |
| 83 , m_hostIsPublicSuffix(false) | 82 , m_hostIsPublicSuffix(false) |
| 84 { | 83 { |
| 85 ASSERT(subdomainSetting >= AllowSubdomains || subdomainSetting <= DisallowSu
bdomains); | 84 ASSERT(subdomainSetting >= AllowSubdomains || subdomainSetting <= DisallowSu
bdomains); |
| 86 | 85 |
| 87 m_hostIsIPAddress = HostIsIPAddress(host); | 86 m_hostIsIPAddress = HostIsIPAddress(host); |
| 88 | 87 |
| 89 // Look for top-level domains, either with or without an additional dot. | 88 // Look for top-level domains, either with or without an additional dot. |
| 90 if (!m_hostIsIPAddress) { | 89 if (!m_hostIsIPAddress) { |
| 91 WebPublicSuffixList* suffixList = Platform::current()->publicSuffixList(
); | 90 std::string hostString(reinterpret_cast<const char*>(m_host.characters8(
)), m_host.length()); |
| 92 if (!suffixList) | 91 size_t publicSuffixLength = net::registry_controlled_domains::GetRegistr
yLength( |
| 93 return; | 92 hostString, |
| 93 net::registry_controlled_domains::INCLUDE_UNKNOWN_REGISTRIES, |
| 94 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 95 if (!publicSuffixLength) |
| 96 publicSuffixLength = m_host.length(); |
| 94 | 97 |
| 95 size_t publicSuffixLength = suffixList->getPublicSuffixLength(m_host); | |
| 96 if (m_host.length() <= publicSuffixLength + 1) { | 98 if (m_host.length() <= publicSuffixLength + 1) { |
| 97 m_hostIsPublicSuffix = true; | 99 m_hostIsPublicSuffix = true; |
| 98 } else if (subdomainSetting == AllowRegisterableDomains && publicSuffixL
ength) { | 100 } else if (subdomainSetting == AllowRegisterableDomains && publicSuffixL
ength) { |
| 99 // The "2" in the next line is 1 for the '.', plus a 1-char minimum
label length. | 101 // The "2" in the next line is 1 for the '.', plus a 1-char minimum
label length. |
| 100 const size_t dot = m_host.reverseFind('.', m_host.length() - publicS
uffixLength - 2); | 102 const size_t dot = m_host.reverseFind('.', m_host.length() - publicS
uffixLength - 2); |
| 101 if (dot == kNotFound) | 103 if (dot == kNotFound) |
| 102 m_registerableDomain = host; | 104 m_registerableDomain = host; |
| 103 else | 105 else |
| 104 m_registerableDomain = host.substring(dot + 1); | 106 m_registerableDomain = host.substring(dot + 1); |
| 105 } | 107 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 break; | 154 break; |
| 153 }; | 155 }; |
| 154 | 156 |
| 155 if (m_hostIsPublicSuffix) | 157 if (m_hostIsPublicSuffix) |
| 156 return MatchesOriginButIsPublicSuffix; | 158 return MatchesOriginButIsPublicSuffix; |
| 157 | 159 |
| 158 return MatchesOrigin; | 160 return MatchesOrigin; |
| 159 } | 161 } |
| 160 | 162 |
| 161 } // namespace blink | 163 } // namespace blink |
| OLD | NEW |