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 // Portions of this code based on Mozilla: | 5 // Portions of this code based on Mozilla: |
6 // (netwerk/cookie/src/nsCookieService.cpp) | 6 // (netwerk/cookie/src/nsCookieService.cpp) |
7 /* ***** BEGIN LICENSE BLOCK ***** | 7 /* ***** BEGIN LICENSE BLOCK ***** |
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
9 * | 9 * |
10 * The contents of this file are subject to the Mozilla Public License Version | 10 * The contents of this file are subject to the Mozilla Public License Version |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 #else | 150 #else |
151 sscanf( | 151 sscanf( |
152 #endif | 152 #endif |
153 pc.MaxAge().c_str(), " %" PRIu64, &max_age) == 1) { | 153 pc.MaxAge().c_str(), " %" PRIu64, &max_age) == 1) { |
154 return current + TimeDelta::FromSeconds(max_age); | 154 return current + TimeDelta::FromSeconds(max_age); |
155 } | 155 } |
156 | 156 |
157 // Try the Expires attribute. | 157 // Try the Expires attribute. |
158 if (pc.HasExpires() && !pc.Expires().empty()) { | 158 if (pc.HasExpires() && !pc.Expires().empty()) { |
159 // Adjust for clock skew between server and host. | 159 // Adjust for clock skew between server and host. |
160 base::Time parsed_expiry = | 160 base::Time parsed_expiry = cookie_util::ParseCookieTime(pc.Expires()); |
161 cookie_util::ParseCookieExpirationTime(pc.Expires()); | |
162 if (!parsed_expiry.is_null()) | 161 if (!parsed_expiry.is_null()) |
163 return parsed_expiry + (current - server_time); | 162 return parsed_expiry + (current - server_time); |
164 } | 163 } |
165 | 164 |
166 // Invalid or no expiration, persistent cookie. | 165 // Invalid or no expiration, persistent cookie. |
167 return Time(); | 166 return Time(); |
168 } | 167 } |
169 | 168 |
170 // static | 169 // static |
171 std::unique_ptr<CanonicalCookie> CanonicalCookie::Create( | 170 std::unique_ptr<CanonicalCookie> CanonicalCookie::Create( |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 return true; | 522 return true; |
524 } | 523 } |
525 | 524 |
526 std::string CanonicalCookie::DomainWithoutDot() const { | 525 std::string CanonicalCookie::DomainWithoutDot() const { |
527 if (domain_.empty() || domain_[0] != '.') | 526 if (domain_.empty() || domain_[0] != '.') |
528 return domain_; | 527 return domain_; |
529 return domain_.substr(1); | 528 return domain_.substr(1); |
530 } | 529 } |
531 | 530 |
532 } // namespace net | 531 } // namespace net |
OLD | NEW |