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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // We match IE/Firefox in allowing a domain=IPADDR if it matches the url | 44 // We match IE/Firefox in allowing a domain=IPADDR if it matches the url |
45 // ip address hostname exactly. It should be treated as a host cookie. | 45 // ip address hostname exactly. It should be treated as a host cookie. |
46 if (domain_string.empty() || | 46 if (domain_string.empty() || |
47 (url.HostIsIPAddress() && url_host == domain_string)) { | 47 (url.HostIsIPAddress() && url_host == domain_string)) { |
48 *result = url_host; | 48 *result = url_host; |
49 DCHECK(DomainIsHostOnly(*result)); | 49 DCHECK(DomainIsHostOnly(*result)); |
50 return true; | 50 return true; |
51 } | 51 } |
52 | 52 |
53 // Get the normalized domain specified in cookie line. | 53 // Get the normalized domain specified in cookie line. |
54 url_canon::CanonHostInfo ignored; | 54 url::CanonHostInfo ignored; |
55 std::string cookie_domain(CanonicalizeHost(domain_string, &ignored)); | 55 std::string cookie_domain(CanonicalizeHost(domain_string, &ignored)); |
56 if (cookie_domain.empty()) | 56 if (cookie_domain.empty()) |
57 return false; | 57 return false; |
58 if (cookie_domain[0] != '.') | 58 if (cookie_domain[0] != '.') |
59 cookie_domain = "." + cookie_domain; | 59 cookie_domain = "." + cookie_domain; |
60 | 60 |
61 // Ensure |url| and |cookie_domain| have the same domain+registry. | 61 // Ensure |url| and |cookie_domain| have the same domain+registry. |
62 const std::string url_scheme(url.scheme()); | 62 const std::string url_scheme(url.scheme()); |
63 const std::string url_domain_and_registry( | 63 const std::string url_domain_and_registry( |
64 GetEffectiveDomain(url_scheme, url_host)); | 64 GetEffectiveDomain(url_scheme, url_host)); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return GURL(); | 206 return GURL(); |
207 | 207 |
208 const std::string scheme = is_https ? "https" : "http"; | 208 const std::string scheme = is_https ? "https" : "http"; |
209 const std::string host = domain[0] == '.' ? domain.substr(1) : domain; | 209 const std::string host = domain[0] == '.' ? domain.substr(1) : domain; |
210 return GURL(scheme + "://" + host); | 210 return GURL(scheme + "://" + host); |
211 } | 211 } |
212 | 212 |
213 } // namespace cookie_utils | 213 } // namespace cookie_utils |
214 } // namespace net | 214 } // namespace net |
215 | 215 |
OLD | NEW |