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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // dots) | 220 // dots) |
221 // http://192.168.0.1/file.html -> 0 (IP address) | 221 // http://192.168.0.1/file.html -> 0 (IP address) |
222 // http://bar/file.html -> 0 (no subcomponents) | 222 // http://bar/file.html -> 0 (no subcomponents) |
223 // http://co.uk/file.html -> 0 (host is a registry) | 223 // http://co.uk/file.html -> 0 (host is a registry) |
224 // http://foo.bar/file.html -> 0 or 3, depending (no rule; assume | 224 // http://foo.bar/file.html -> 0 or 3, depending (no rule; assume |
225 // bar) | 225 // bar) |
226 NET_EXPORT size_t GetRegistryLength(const GURL& gurl, | 226 NET_EXPORT size_t GetRegistryLength(const GURL& gurl, |
227 UnknownRegistryFilter unknown_filter, | 227 UnknownRegistryFilter unknown_filter, |
228 PrivateRegistryFilter private_filter); | 228 PrivateRegistryFilter private_filter); |
229 | 229 |
230 // Like the GURL version, but takes a host (which is canonicalized internally) | 230 // Returns true if the given host name has a registry-controlled domain. The |
231 // instead of a full GURL. | 231 // nost name will be internally canonicalized. Invalid host names like |
232 NET_EXPORT size_t GetRegistryLength(base::StringPiece host, | 232 // "*.google.com" can be passed and will return true as long as it has a valid |
233 UnknownRegistryFilter unknown_filter, | 233 // registry-controlled portion. |
234 PrivateRegistryFilter private_filter); | 234 NET_EXPORT bool HostHasRegistryControlledDomain( |
| 235 base::StringPiece host, |
| 236 UnknownRegistryFilter unknown_filter, |
| 237 PrivateRegistryFilter private_filter); |
| 238 |
| 239 // Like GetRegistryLength, but takes a previously-canonicalized host. Prefer |
| 240 // the GURL version above or HasRegistryControlledSuffix to eliminate |
| 241 // bugs with non-canonical hosts. |
| 242 NET_EXPORT size_t |
| 243 GetRegistryLengthForCanonicalHost(base::StringPiece canon_host, |
| 244 UnknownRegistryFilter unknown_filter, |
| 245 PrivateRegistryFilter private_filter); |
| 246 |
| 247 // This function canonicalizes the host name and returns the registry controlled |
| 248 // length of the canonical version. |
| 249 // |
| 250 // TODO(bug 657199) any use of this length by the caller is likely a bug. |
| 251 // Canonicalization can change the length of different URL components, so using |
| 252 // the returned value as an index into the returned string will be incorrect. If |
| 253 // you have a canonicalized URL, this is safe and you should use |
| 254 // GetRegistryLengthForCanonicalHost above. |
| 255 NET_EXPORT size_t |
| 256 BuggyGetHostRegistryLength(const std::string& host, |
| 257 UnknownRegistryFilter unknown_filter, |
| 258 PrivateRegistryFilter private_filter); |
235 | 259 |
236 typedef const struct DomainRule* (*FindDomainPtr)(const char *, unsigned int); | 260 typedef const struct DomainRule* (*FindDomainPtr)(const char *, unsigned int); |
237 | 261 |
238 // Used for unit tests. Use default domains. | 262 // Used for unit tests. Use default domains. |
239 NET_EXPORT_PRIVATE void SetFindDomainGraph(); | 263 NET_EXPORT_PRIVATE void SetFindDomainGraph(); |
240 | 264 |
241 // Used for unit tests, so that a frozen list of domains is used. | 265 // Used for unit tests, so that a frozen list of domains is used. |
242 NET_EXPORT_PRIVATE void SetFindDomainGraph(const unsigned char* domains, | 266 NET_EXPORT_PRIVATE void SetFindDomainGraph(const unsigned char* domains, |
243 size_t length); | 267 size_t length); |
244 } // namespace registry_controlled_domains | 268 } // namespace registry_controlled_domains |
245 } // namespace net | 269 } // namespace net |
246 | 270 |
247 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAINS_REGISTRY_CONTROLLED_DOMAIN_H_ | 271 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAINS_REGISTRY_CONTROLLED_DOMAIN_H_ |
OLD | NEW |