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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 #include <stddef.h> | 116 #include <stddef.h> |
117 | 117 |
118 #include <string> | 118 #include <string> |
119 | 119 |
120 #include "base/strings/string_piece.h" | 120 #include "base/strings/string_piece.h" |
121 #include "net/base/net_export.h" | 121 #include "net/base/net_export.h" |
122 | 122 |
123 class GURL; | 123 class GURL; |
124 | 124 |
| 125 namespace url { |
| 126 class Origin; |
| 127 }; |
| 128 |
125 struct DomainRule; | 129 struct DomainRule; |
126 | 130 |
127 namespace net { | 131 namespace net { |
128 namespace registry_controlled_domains { | 132 namespace registry_controlled_domains { |
129 | 133 |
130 // This enum is a required parameter to all public methods declared for this | 134 // This enum is a required parameter to all public methods declared for this |
131 // service. The Public Suffix List (http://publicsuffix.org/) this service | 135 // service. The Public Suffix List (http://publicsuffix.org/) this service |
132 // uses as a data source splits all effective-TLDs into two groups. The main | 136 // uses as a data source splits all effective-TLDs into two groups. The main |
133 // group describes registries that are acknowledged by ICANN. The second group | 137 // group describes registries that are acknowledged by ICANN. The second group |
134 // contains a list of private additions for domains that enable external users | 138 // contains a list of private additions for domains that enable external users |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // http://co.uk/file.html -> "" (host is a registry) | 180 // http://co.uk/file.html -> "" (host is a registry) |
177 // http://foo.bar/file.html -> "foo.bar" (no rule; assume bar) | 181 // http://foo.bar/file.html -> "foo.bar" (no rule; assume bar) |
178 NET_EXPORT std::string GetDomainAndRegistry(const GURL& gurl, | 182 NET_EXPORT std::string GetDomainAndRegistry(const GURL& gurl, |
179 PrivateRegistryFilter filter); | 183 PrivateRegistryFilter filter); |
180 | 184 |
181 // Like the GURL version, but takes a host (which is canonicalized internally) | 185 // Like the GURL version, but takes a host (which is canonicalized internally) |
182 // instead of a full GURL. | 186 // instead of a full GURL. |
183 NET_EXPORT std::string GetDomainAndRegistry(base::StringPiece host, | 187 NET_EXPORT std::string GetDomainAndRegistry(base::StringPiece host, |
184 PrivateRegistryFilter filter); | 188 PrivateRegistryFilter filter); |
185 | 189 |
186 // This convenience function returns true if the two GURLs both have hosts | 190 // These convenience functions return true if the two GURLs or Origins both have |
187 // and one of the following is true: | 191 // hosts and one of the following is true: |
188 // * They each have a known domain and registry, and it is the same for both | 192 // * They each have a known domain and registry, and it is the same for both |
189 // URLs. Note that this means the trailing dot, if any, must match too. | 193 // URLs. Note that this means the trailing dot, if any, must match too. |
190 // * They don't have known domains/registries, but the hosts are identical. | 194 // * They don't have known domains/registries, but the hosts are identical. |
191 // Effectively, callers can use this function to check whether the input URLs | 195 // Effectively, callers can use this function to check whether the input URLs |
192 // represent hosts "on the same site". | 196 // represent hosts "on the same site". |
193 NET_EXPORT bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2, | 197 NET_EXPORT bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2, |
194 PrivateRegistryFilter filter); | 198 PrivateRegistryFilter filter); |
| 199 NET_EXPORT bool SameDomainOrHost(const url::Origin& origin1, |
| 200 const url::Origin& origin2, |
| 201 PrivateRegistryFilter filter); |
195 | 202 |
196 // Finds the length in bytes of the registrar portion of the host in the | 203 // Finds the length in bytes of the registrar portion of the host in the |
197 // given GURL. Returns std::string::npos if the GURL is invalid or has no | 204 // given GURL. Returns std::string::npos if the GURL is invalid or has no |
198 // host (e.g. a file: URL). Returns 0 if the GURL has multiple trailing dots, | 205 // host (e.g. a file: URL). Returns 0 if the GURL has multiple trailing dots, |
199 // is an IP address, has no subcomponents, or is itself a recognized registry | 206 // is an IP address, has no subcomponents, or is itself a recognized registry |
200 // identifier. The result is also dependent on the UnknownRegistryFilter. | 207 // identifier. The result is also dependent on the UnknownRegistryFilter. |
201 // If no matching rule is found in the effective-TLD data (or in | 208 // If no matching rule is found in the effective-TLD data (or in |
202 // the default data, if the resource failed to load), returns 0 if | 209 // the default data, if the resource failed to load), returns 0 if |
203 // |unknown_filter| is EXCLUDE_UNKNOWN_REGISTRIES, or the length of the last | 210 // |unknown_filter| is EXCLUDE_UNKNOWN_REGISTRIES, or the length of the last |
204 // subcomponent if |unknown_filter| is INCLUDE_UNKNOWN_REGISTRIES. | 211 // subcomponent if |unknown_filter| is INCLUDE_UNKNOWN_REGISTRIES. |
(...skipping 26 matching lines...) Expand all Loading... |
231 // Used for unit tests. Use default domains. | 238 // Used for unit tests. Use default domains. |
232 NET_EXPORT_PRIVATE void SetFindDomainGraph(); | 239 NET_EXPORT_PRIVATE void SetFindDomainGraph(); |
233 | 240 |
234 // Used for unit tests, so that a frozen list of domains is used. | 241 // Used for unit tests, so that a frozen list of domains is used. |
235 NET_EXPORT_PRIVATE void SetFindDomainGraph(const unsigned char* domains, | 242 NET_EXPORT_PRIVATE void SetFindDomainGraph(const unsigned char* domains, |
236 size_t length); | 243 size_t length); |
237 } // namespace registry_controlled_domains | 244 } // namespace registry_controlled_domains |
238 } // namespace net | 245 } // namespace net |
239 | 246 |
240 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAINS_REGISTRY_CONTROLLED_DOMAIN_H_ | 247 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAINS_REGISTRY_CONTROLLED_DOMAIN_H_ |
OLD | NEW |