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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return a.Path().compare(b.Path()); | 118 return a.Path().compare(b.Path()); |
119 } | 119 } |
120 | 120 |
121 } // namespace | 121 } // namespace |
122 | 122 |
123 CanonicalCookie::CanonicalCookie() | 123 CanonicalCookie::CanonicalCookie() |
124 : secure_(false), | 124 : secure_(false), |
125 httponly_(false) { | 125 httponly_(false) { |
126 } | 126 } |
127 | 127 |
128 CanonicalCookie::CanonicalCookie(const GURL& url, | |
129 const std::string& name, | |
130 const std::string& value, | |
131 const std::string& domain, | |
132 const std::string& path, | |
133 const base::Time& creation, | |
134 const base::Time& expiration, | |
135 const base::Time& last_access, | |
136 bool secure, | |
137 bool httponly, | |
138 CookieSameSite same_site, | |
139 CookiePriority priority) | |
140 : name_(name), | |
141 value_(value), | |
142 domain_(domain), | |
143 path_(path), | |
144 creation_date_(creation), | |
145 expiry_date_(expiration), | |
146 last_access_date_(last_access), | |
147 secure_(secure), | |
148 httponly_(httponly), | |
149 same_site_(same_site), | |
150 priority_(priority) {} | |
151 | |
152 CanonicalCookie::CanonicalCookie(const CanonicalCookie& other) = default; | 128 CanonicalCookie::CanonicalCookie(const CanonicalCookie& other) = default; |
153 | 129 |
154 CanonicalCookie::~CanonicalCookie() { | 130 CanonicalCookie::~CanonicalCookie() {} |
155 } | |
156 | 131 |
157 // static | 132 // static |
158 std::string CanonicalCookie::CanonPath(const GURL& url, | 133 std::string CanonicalCookie::CanonPath(const GURL& url, |
159 const ParsedCookie& pc) { | 134 const ParsedCookie& pc) { |
160 std::string path_string; | 135 std::string path_string; |
161 if (pc.HasPath()) | 136 if (pc.HasPath()) |
162 path_string = pc.Path(); | 137 path_string = pc.Path(); |
163 return CanonPathWithString(url, path_string); | 138 return CanonPathWithString(url, path_string); |
164 } | 139 } |
165 | 140 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 448 |
474 if (IsSecure() != other.IsSecure()) | 449 if (IsSecure() != other.IsSecure()) |
475 return IsSecure(); | 450 return IsSecure(); |
476 | 451 |
477 if (IsHttpOnly() != other.IsHttpOnly()) | 452 if (IsHttpOnly() != other.IsHttpOnly()) |
478 return IsHttpOnly(); | 453 return IsHttpOnly(); |
479 | 454 |
480 return Priority() < other.Priority(); | 455 return Priority() < other.Priority(); |
481 } | 456 } |
482 | 457 |
| 458 CanonicalCookie::CanonicalCookie(const GURL& url, |
| 459 const std::string& name, |
| 460 const std::string& value, |
| 461 const std::string& domain, |
| 462 const std::string& path, |
| 463 const base::Time& creation, |
| 464 const base::Time& expiration, |
| 465 const base::Time& last_access, |
| 466 bool secure, |
| 467 bool httponly, |
| 468 CookieSameSite same_site, |
| 469 CookiePriority priority) |
| 470 : name_(name), |
| 471 value_(value), |
| 472 domain_(domain), |
| 473 path_(path), |
| 474 creation_date_(creation), |
| 475 expiry_date_(expiration), |
| 476 last_access_date_(last_access), |
| 477 secure_(secure), |
| 478 httponly_(httponly), |
| 479 same_site_(same_site), |
| 480 priority_(priority) {} |
| 481 |
483 // static | 482 // static |
484 CanonicalCookie::CookiePrefix CanonicalCookie::GetCookiePrefix( | 483 CanonicalCookie::CookiePrefix CanonicalCookie::GetCookiePrefix( |
485 const std::string& name) { | 484 const std::string& name) { |
486 const char kSecurePrefix[] = "__Secure-"; | 485 const char kSecurePrefix[] = "__Secure-"; |
487 const char kHostPrefix[] = "__Host-"; | 486 const char kHostPrefix[] = "__Host-"; |
488 if (base::StartsWith(name, kSecurePrefix, base::CompareCase::SENSITIVE)) | 487 if (base::StartsWith(name, kSecurePrefix, base::CompareCase::SENSITIVE)) |
489 return CanonicalCookie::COOKIE_PREFIX_SECURE; | 488 return CanonicalCookie::COOKIE_PREFIX_SECURE; |
490 if (base::StartsWith(name, kHostPrefix, base::CompareCase::SENSITIVE)) | 489 if (base::StartsWith(name, kHostPrefix, base::CompareCase::SENSITIVE)) |
491 return CanonicalCookie::COOKIE_PREFIX_HOST; | 490 return CanonicalCookie::COOKIE_PREFIX_HOST; |
492 return CanonicalCookie::COOKIE_PREFIX_NONE; | 491 return CanonicalCookie::COOKIE_PREFIX_NONE; |
(...skipping 30 matching lines...) Expand all 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 |