| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if (!subdomain.endsWith(host)) | 71 if (!subdomain.endsWith(host)) |
| 72 return false; | 72 return false; |
| 73 | 73 |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 } // namespace | 76 } // namespace |
| 77 | 77 |
| 78 OriginAccessEntry::OriginAccessEntry(const String& protocol, | 78 OriginAccessEntry::OriginAccessEntry(const String& protocol, |
| 79 const String& host, | 79 const String& host, |
| 80 SubdomainSetting subdomainSetting) | 80 SubdomainSetting subdomainSetting) |
| 81 : m_protocol(protocol.lower()), | 81 : m_protocol(protocol), |
| 82 m_host(host.lower()), | 82 m_host(host), |
| 83 m_subdomainSettings(subdomainSetting), | 83 m_subdomainSettings(subdomainSetting), |
| 84 m_hostIsPublicSuffix(false) { | 84 m_hostIsPublicSuffix(false) { |
| 85 ASSERT(subdomainSetting >= AllowSubdomains || | 85 ASSERT(subdomainSetting >= AllowSubdomains || |
| 86 subdomainSetting <= DisallowSubdomains); | 86 subdomainSetting <= DisallowSubdomains); |
| 87 | 87 |
| 88 m_hostIsIPAddress = HostIsIPAddress(host); | 88 m_hostIsIPAddress = HostIsIPAddress(host); |
| 89 | 89 |
| 90 // Look for top-level domains, either with or without an additional dot. | 90 // Look for top-level domains, either with or without an additional dot. |
| 91 if (!m_hostIsIPAddress) { | 91 if (!m_hostIsIPAddress) { |
| 92 WebPublicSuffixList* suffixList = Platform::current()->publicSuffixList(); | 92 WebPublicSuffixList* suffixList = Platform::current()->publicSuffixList(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 105 if (dot == kNotFound) | 105 if (dot == kNotFound) |
| 106 m_registerableDomain = host; | 106 m_registerableDomain = host; |
| 107 else | 107 else |
| 108 m_registerableDomain = host.substring(dot + 1); | 108 m_registerableDomain = host.substring(dot + 1); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 OriginAccessEntry::MatchResult OriginAccessEntry::matchesOrigin( | 113 OriginAccessEntry::MatchResult OriginAccessEntry::matchesOrigin( |
| 114 const SecurityOrigin& origin) const { | 114 const SecurityOrigin& origin) const { |
| 115 ASSERT(origin.protocol() == origin.protocol().lower()); | |
| 116 | |
| 117 if (m_protocol != origin.protocol()) | 115 if (m_protocol != origin.protocol()) |
| 118 return DoesNotMatchOrigin; | 116 return DoesNotMatchOrigin; |
| 119 | 117 |
| 120 return matchesDomain(origin); | 118 return matchesDomain(origin); |
| 121 } | 119 } |
| 122 | 120 |
| 123 OriginAccessEntry::MatchResult OriginAccessEntry::matchesDomain( | 121 OriginAccessEntry::MatchResult OriginAccessEntry::matchesDomain( |
| 124 const SecurityOrigin& origin) const { | 122 const SecurityOrigin& origin) const { |
| 125 ASSERT(origin.host() == origin.host().lower()); | |
| 126 // Special case: Include subdomains and empty host means "all hosts, including | 123 // Special case: Include subdomains and empty host means "all hosts, including |
| 127 // ip addresses". | 124 // ip addresses". |
| 128 if (m_subdomainSettings != DisallowSubdomains && m_host.isEmpty()) | 125 if (m_subdomainSettings != DisallowSubdomains && m_host.isEmpty()) |
| 129 return MatchesOrigin; | 126 return MatchesOrigin; |
| 130 | 127 |
| 131 // Exact match. | 128 // Exact match. |
| 132 if (m_host == origin.host()) | 129 if (m_host == origin.host()) |
| 133 return MatchesOrigin; | 130 return MatchesOrigin; |
| 134 | 131 |
| 135 // Don't try to do subdomain matching on IP addresses. | 132 // Don't try to do subdomain matching on IP addresses. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 159 break; | 156 break; |
| 160 }; | 157 }; |
| 161 | 158 |
| 162 if (m_hostIsPublicSuffix) | 159 if (m_hostIsPublicSuffix) |
| 163 return MatchesOriginButIsPublicSuffix; | 160 return MatchesOriginButIsPublicSuffix; |
| 164 | 161 |
| 165 return MatchesOrigin; | 162 return MatchesOrigin; |
| 166 } | 163 } |
| 167 | 164 |
| 168 } // namespace blink | 165 } // namespace blink |
| OLD | NEW |