OLD | NEW |
1 //* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 //* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
4 * | 4 * |
5 * The contents of this file are subject to the Mozilla Public License Version | 5 * The contents of this file are subject to the Mozilla Public License Version |
6 * 1.1 (the "License"); you may not use this file except in compliance with | 6 * 1.1 (the "License"); you may not use this file except in compliance with |
7 * the License. You may obtain a copy of the License at | 7 * the License. You may obtain a copy of the License at |
8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
9 * | 9 * |
10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // http://foo.com../file.html -> "" (multiple trailing dots) | 148 // http://foo.com../file.html -> "" (multiple trailing dots) |
149 // http://192.168.0.1/file.html -> "" (IP address) | 149 // http://192.168.0.1/file.html -> "" (IP address) |
150 // http://bar/file.html -> "" (no subcomponents) | 150 // http://bar/file.html -> "" (no subcomponents) |
151 // http://co.uk/file.html -> "" (host is a registry) | 151 // http://co.uk/file.html -> "" (host is a registry) |
152 // http://foo.bar/file.html -> "foo.bar" (no rule; assume bar) | 152 // http://foo.bar/file.html -> "foo.bar" (no rule; assume bar) |
153 static std::string GetDomainAndRegistry(const GURL& gurl); | 153 static std::string GetDomainAndRegistry(const GURL& gurl); |
154 | 154 |
155 // Like the GURL version, but takes a host (which is canonicalized internally) | 155 // Like the GURL version, but takes a host (which is canonicalized internally) |
156 // instead of a full GURL. | 156 // instead of a full GURL. |
157 static std::string GetDomainAndRegistry(const std::string& host); | 157 static std::string GetDomainAndRegistry(const std::string& host); |
158 static std::string GetDomainAndRegistry(const std::wstring& host); | |
159 | 158 |
160 // This convenience function returns true if the two GURLs both have hosts | 159 // This convenience function returns true if the two GURLs both have hosts |
161 // and one of the following is true: | 160 // and one of the following is true: |
162 // * They each have a known domain and registry, and it is the same for both | 161 // * They each have a known domain and registry, and it is the same for both |
163 // URLs. Note that this means the trailing dot, if any, must match too. | 162 // URLs. Note that this means the trailing dot, if any, must match too. |
164 // * They don't have known domains/registries, but the hosts are identical. | 163 // * They don't have known domains/registries, but the hosts are identical. |
165 // Effectively, callers can use this function to check whether the input URLs | 164 // Effectively, callers can use this function to check whether the input URLs |
166 // represent hosts "on the same site". | 165 // represent hosts "on the same site". |
167 static bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2); | 166 static bool SameDomainOrHost(const GURL& gurl1, const GURL& gurl2); |
168 | 167 |
(...skipping 19 matching lines...) Expand all Loading... |
188 // http://co.uk/file.html -> 0 (host is a registry) | 187 // http://co.uk/file.html -> 0 (host is a registry) |
189 // http://foo.bar/file.html -> 0 or 3, depending (no rule; assume | 188 // http://foo.bar/file.html -> 0 or 3, depending (no rule; assume |
190 // bar) | 189 // bar) |
191 static size_t GetRegistryLength(const GURL& gurl, | 190 static size_t GetRegistryLength(const GURL& gurl, |
192 bool allow_unknown_registries); | 191 bool allow_unknown_registries); |
193 | 192 |
194 // 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) |
195 // instead of a full GURL. | 194 // instead of a full GURL. |
196 static size_t GetRegistryLength(const std::string& host, | 195 static size_t GetRegistryLength(const std::string& host, |
197 bool allow_unknown_registries); | 196 bool allow_unknown_registries); |
198 static size_t GetRegistryLength(const std::wstring& host, | |
199 bool allow_unknown_registries); | |
200 | 197 |
201 // Returns the singleton instance, after attempting to initialize it. | 198 // Returns the singleton instance, after attempting to initialize it. |
202 // NOTE that if the effective-TLD data resource can't be found, the instance | 199 // NOTE that if the effective-TLD data resource can't be found, the instance |
203 // will be initialized and continue operation with simple default TLD data. | 200 // will be initialized and continue operation with simple default TLD data. |
204 static RegistryControlledDomainService* GetInstance(); | 201 static RegistryControlledDomainService* GetInstance(); |
205 | 202 |
206 protected: | 203 protected: |
207 typedef const struct DomainRule* (*FindDomainPtr)(const char *, unsigned int); | 204 typedef const struct DomainRule* (*FindDomainPtr)(const char *, unsigned int); |
208 | 205 |
209 // The entire protected API is only for unit testing. I mean it. Don't make | 206 // The entire protected API is only for unit testing. I mean it. Don't make |
(...skipping 23 matching lines...) Expand all Loading... |
233 | 230 |
234 // Function that returns a DomainRule given a domain. | 231 // Function that returns a DomainRule given a domain. |
235 FindDomainPtr find_domain_function_; | 232 FindDomainPtr find_domain_function_; |
236 | 233 |
237 DISALLOW_COPY_AND_ASSIGN(RegistryControlledDomainService); | 234 DISALLOW_COPY_AND_ASSIGN(RegistryControlledDomainService); |
238 }; | 235 }; |
239 | 236 |
240 } // namespace net | 237 } // namespace net |
241 | 238 |
242 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H_ | 239 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H_ |
OLD | NEW |