| 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 #include "net/cookies/cookie_util.h" | 5 #include "net/cookies/cookie_util.h" |
| 6 | 6 |
| 7 #include <cstdio> | 7 #include <cstdio> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/strings/string_tokenizer.h" | 12 #include "base/strings/string_tokenizer.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 16 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 16 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 namespace cookie_util { | 19 namespace cookie_util { |
| 20 | 20 |
| 21 bool DomainIsHostOnly(const std::string& domain_string) { | 21 bool DomainIsHostOnly(const std::string& domain_string) { |
| 22 return (domain_string.empty() || domain_string[0] != '.'); | 22 return (domain_string.empty() || domain_string[0] != '.'); |
| 23 } | 23 } |
| 24 | 24 |
| 25 std::string GetEffectiveDomain(const std::string& scheme, | 25 std::string GetEffectiveDomain(const std::string& scheme, |
| 26 const std::string& host) { | 26 const std::string& host) { |
| 27 if (scheme == "http" || scheme == "https") | 27 if (scheme == "http" || scheme == "https") |
| 28 return RegistryControlledDomainService::GetDomainAndRegistry(host); | 28 return registry_controlled_domains::GetDomainAndRegistry( |
| 29 host, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
| 29 | 30 |
| 30 if (!DomainIsHostOnly(host)) | 31 if (!DomainIsHostOnly(host)) |
| 31 return host.substr(1); | 32 return host.substr(1); |
| 32 return host; | 33 return host; |
| 33 } | 34 } |
| 34 | 35 |
| 35 bool GetCookieDomainWithString(const GURL& url, | 36 bool GetCookieDomainWithString(const GURL& url, |
| 36 const std::string& domain_string, | 37 const std::string& domain_string, |
| 37 std::string* result) { | 38 std::string* result) { |
| 38 const std::string url_host(url.host()); | 39 const std::string url_host(url.host()); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 return GURL(); | 204 return GURL(); |
| 204 | 205 |
| 205 const std::string scheme = is_https ? "https" : "http"; | 206 const std::string scheme = is_https ? "https" : "http"; |
| 206 const std::string host = domain[0] == '.' ? domain.substr(1) : domain; | 207 const std::string host = domain[0] == '.' ? domain.substr(1) : domain; |
| 207 return GURL(scheme + "://" + host); | 208 return GURL(scheme + "://" + host); |
| 208 } | 209 } |
| 209 | 210 |
| 210 } // namespace cookie_utils | 211 } // namespace cookie_utils |
| 211 } // namespace net | 212 } // namespace net |
| 212 | 213 |
| OLD | NEW |