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.cpp) | 7 // (netwerk/dns/src/nsEffectiveTLDService.cpp) |
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return SameDomainOrHost(origin1.GetURL(), origin2.GetURL(), filter); | 234 return SameDomainOrHost(origin1.GetURL(), origin2.GetURL(), filter); |
235 } | 235 } |
236 | 236 |
237 size_t GetRegistryLength( | 237 size_t GetRegistryLength( |
238 const GURL& gurl, | 238 const GURL& gurl, |
239 UnknownRegistryFilter unknown_filter, | 239 UnknownRegistryFilter unknown_filter, |
240 PrivateRegistryFilter private_filter) { | 240 PrivateRegistryFilter private_filter) { |
241 base::StringPiece host = gurl.host_piece(); | 241 base::StringPiece host = gurl.host_piece(); |
242 if (host.empty()) | 242 if (host.empty()) |
243 return std::string::npos; | 243 return std::string::npos; |
244 if (gurl.HostIsIPAddress()) | |
245 return 0; | |
246 return GetRegistryLengthImpl(host, unknown_filter, private_filter); | 244 return GetRegistryLengthImpl(host, unknown_filter, private_filter); |
247 } | 245 } |
248 | 246 |
249 size_t GetRegistryLength(base::StringPiece host, | 247 bool HostHasRegistryControlledDomain(base::StringPiece host, |
250 UnknownRegistryFilter unknown_filter, | 248 UnknownRegistryFilter unknown_filter, |
251 PrivateRegistryFilter private_filter) { | 249 PrivateRegistryFilter private_filter) { |
| 250 url::CanonHostInfo host_info; |
| 251 const std::string canon_host(CanonicalizeHost(host, &host_info)); |
| 252 if (canon_host.empty()) |
| 253 return false; |
| 254 return GetRegistryLengthImpl(canon_host, unknown_filter, private_filter) > 0; |
| 255 } |
| 256 |
| 257 size_t GetRegistryLengthForCanonicalHost(base::StringPiece canon_host, |
| 258 UnknownRegistryFilter unknown_filter, |
| 259 PrivateRegistryFilter private_filter) { |
| 260 if (canon_host.empty()) |
| 261 return std::string::npos; |
| 262 return GetRegistryLengthImpl(canon_host, unknown_filter, private_filter); |
| 263 } |
| 264 |
| 265 size_t BuggyGetHostRegistryLength(const std::string& host, |
| 266 UnknownRegistryFilter unknown_filter, |
| 267 PrivateRegistryFilter private_filter) { |
252 url::CanonHostInfo host_info; | 268 url::CanonHostInfo host_info; |
253 const std::string canon_host(CanonicalizeHost(host, &host_info)); | 269 const std::string canon_host(CanonicalizeHost(host, &host_info)); |
254 if (canon_host.empty()) | 270 if (canon_host.empty()) |
255 return std::string::npos; | 271 return std::string::npos; |
256 if (host_info.IsIPAddress()) | |
257 return 0; | |
258 return GetRegistryLengthImpl(canon_host, unknown_filter, private_filter); | 272 return GetRegistryLengthImpl(canon_host, unknown_filter, private_filter); |
259 } | 273 } |
260 | 274 |
261 void SetFindDomainGraph() { | 275 void SetFindDomainGraph() { |
262 g_graph = kDafsa; | 276 g_graph = kDafsa; |
263 g_graph_length = sizeof(kDafsa); | 277 g_graph_length = sizeof(kDafsa); |
264 } | 278 } |
265 | 279 |
266 void SetFindDomainGraph(const unsigned char* domains, size_t length) { | 280 void SetFindDomainGraph(const unsigned char* domains, size_t length) { |
267 CHECK(domains); | 281 CHECK(domains); |
268 CHECK_NE(length, 0u); | 282 CHECK_NE(length, 0u); |
269 g_graph = domains; | 283 g_graph = domains; |
270 g_graph_length = length; | 284 g_graph_length = length; |
271 } | 285 } |
272 | 286 |
273 } // namespace registry_controlled_domains | 287 } // namespace registry_controlled_domains |
274 } // namespace net | 288 } // namespace net |
OLD | NEW |