OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // NB: Modelled after Mozilla's code (originally written by Pamela Greene, | 5 // NB: Modelled after Mozilla's code (originally written by Pamela Greene, |
6 // later modified by others), but almost entirely rewritten for Chrome. | 6 // later modified by others), but almost entirely rewritten for Chrome. |
7 // (netwerk/dns/src/nsEffectiveTLDService.h) | 7 // (netwerk/dns/src/nsEffectiveTLDService.h) |
8 /* ***** BEGIN LICENSE BLOCK ***** | 8 /* ***** BEGIN LICENSE BLOCK ***** |
9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
10 * | 10 * |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 // std::string-returning version. Update clients. | 188 // std::string-returning version. Update clients. |
189 NET_EXPORT base::StringPiece GetDomainAndRegistryAsStringPiece( | 189 NET_EXPORT base::StringPiece GetDomainAndRegistryAsStringPiece( |
190 const GURL& gurl, | 190 const GURL& gurl, |
191 PrivateRegistryFilter filter); | 191 PrivateRegistryFilter filter); |
192 | 192 |
193 // Like the GURL version, but takes a host (which is canonicalized internally) | 193 // Like the GURL version, but takes a host (which is canonicalized internally) |
194 // instead of a full GURL. | 194 // instead of a full GURL. |
195 NET_EXPORT std::string GetDomainAndRegistry(base::StringPiece host, | 195 NET_EXPORT std::string GetDomainAndRegistry(base::StringPiece host, |
196 PrivateRegistryFilter filter); | 196 PrivateRegistryFilter filter); |
197 | 197 |
198 // Returns whether the hosts of the GURLs are identical. | |
engedy
2016/10/21 08:43:22
nit: Maybe we could put this into the anonymous na
| |
199 NET_EXPORT bool SameHost(const GURL& gurl1, const GURL& gurl2); | |
200 | |
198 // These convenience functions return true if the two GURLs or Origins both have | 201 // These convenience functions return true if the two GURLs or Origins both have |
199 // hosts and one of the following is true: | 202 // hosts and one of the following is true: |
200 // * They each have a known domain and registry, and it is the same for both | 203 // * They each have a known domain and registry, and it is the same for both |
201 // URLs. Note that this means the trailing dot, if any, must match too. | 204 // URLs. Note that this means the trailing dot, if any, must match too. |
202 // * They don't have known domains/registries, but the hosts are identical. | 205 // * They don't have known domains/registries, but the hosts are identical |
206 // (determined by the SameHost function above). | |
203 // Effectively, callers can use this function to check whether the input URLs | 207 // Effectively, callers can use this function to check whether the input URLs |
204 // represent hosts "on the same site". | 208 // represent hosts "on the same site". |
205 NET_EXPORT bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2, | 209 NET_EXPORT bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2, |
206 PrivateRegistryFilter filter); | 210 PrivateRegistryFilter filter); |
207 NET_EXPORT bool SameDomainOrHost(const url::Origin& origin1, | 211 NET_EXPORT bool SameDomainOrHost(const url::Origin& origin1, |
208 const url::Origin& origin2, | 212 const url::Origin& origin2, |
209 PrivateRegistryFilter filter); | 213 PrivateRegistryFilter filter); |
210 | 214 |
211 // Finds the length in bytes of the registrar portion of the host in the | 215 // Finds the length in bytes of the registrar portion of the host in the |
212 // given GURL. Returns std::string::npos if the GURL is invalid or has no | 216 // given GURL. Returns std::string::npos if the GURL is invalid or has no |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 // Used for unit tests. Use default domains. | 250 // Used for unit tests. Use default domains. |
247 NET_EXPORT_PRIVATE void SetFindDomainGraph(); | 251 NET_EXPORT_PRIVATE void SetFindDomainGraph(); |
248 | 252 |
249 // Used for unit tests, so that a frozen list of domains is used. | 253 // Used for unit tests, so that a frozen list of domains is used. |
250 NET_EXPORT_PRIVATE void SetFindDomainGraph(const unsigned char* domains, | 254 NET_EXPORT_PRIVATE void SetFindDomainGraph(const unsigned char* domains, |
251 size_t length); | 255 size_t length); |
252 } // namespace registry_controlled_domains | 256 } // namespace registry_controlled_domains |
253 } // namespace net | 257 } // namespace net |
254 | 258 |
255 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAINS_REGISTRY_CONTROLLED_DOMAIN_H_ | 259 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAINS_REGISTRY_CONTROLLED_DOMAIN_H_ |
OLD | NEW |