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 #ifndef NET_COOKIES_CANONICAL_COOKIE_H_ | 5 #ifndef NET_COOKIES_CANONICAL_COOKIE_H_ |
6 #define NET_COOKIES_CANONICAL_COOKIE_H_ | 6 #define NET_COOKIES_CANONICAL_COOKIE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // having been canonicalized (in | 96 // having been canonicalized (in |
97 // GetCookieDomainWithString->CanonicalizeHost). | 97 // GetCookieDomainWithString->CanonicalizeHost). |
98 bool IsEquivalent(const CanonicalCookie& ecc) const { | 98 bool IsEquivalent(const CanonicalCookie& ecc) const { |
99 // It seems like it would make sense to take secure and httponly into | 99 // It seems like it would make sense to take secure and httponly into |
100 // account, but the RFC doesn't specify this. | 100 // account, but the RFC doesn't specify this. |
101 // NOTE: Keep this logic in-sync with TrimDuplicateCookiesForHost(). | 101 // NOTE: Keep this logic in-sync with TrimDuplicateCookiesForHost(). |
102 return (name_ == ecc.Name() && domain_ == ecc.Domain() | 102 return (name_ == ecc.Name() && domain_ == ecc.Domain() |
103 && path_ == ecc.Path()); | 103 && path_ == ecc.Path()); |
104 } | 104 } |
105 | 105 |
106 // Checks if two cookies have the same name and domain-match per RFC 6265. | 106 // Checks a looser set of equivalency rules than 'IsEquivalent()' in order |
107 // Note that this purposefully ignores paths, and that this function is | 107 // to support the stricter 'Secure' behaviors specified in |
108 // guaranteed to return |true| for a superset of the inputs that | 108 // https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone#section-3 |
109 // IsEquivalent() above returns |true| for. | |
110 // | 109 // |
111 // This is needed for the updates to RFC6265 as per | 110 // Returns 'true' if this cookie's name matches |ecc|, and this cookie is |
112 // https://tools.ietf.org/html/draft-west-leave-secure-cookies-alone. | 111 // a domain-match for |ecc| (or vice versa), and |ecc|'s path is "on" this |
| 112 // cookie's path (as per 'IsOnPath()'). |
| 113 // |
| 114 // Note that while the domain-match cuts both ways (e.g. 'example.com' |
| 115 // matches 'www.example.com' in either direction), the path-match is |
| 116 // unidirectional (e.g. '/login/en' matches '/login' and '/', but |
| 117 // '/login' and '/' do not match '/login/en'). |
113 bool IsEquivalentForSecureCookieMatching(const CanonicalCookie& ecc) const; | 118 bool IsEquivalentForSecureCookieMatching(const CanonicalCookie& ecc) const; |
114 | 119 |
115 void SetLastAccessDate(const base::Time& date) { | 120 void SetLastAccessDate(const base::Time& date) { |
116 last_access_date_ = date; | 121 last_access_date_ = date; |
117 } | 122 } |
118 | 123 |
119 // Returns true if the given |url_path| path-matches the cookie-path as | 124 // Returns true if the given |url_path| path-matches the cookie-path as |
120 // described in section 5.1.4 in RFC 6265. | 125 // described in section 5.1.4 in RFC 6265. |
121 bool IsOnPath(const std::string& url_path) const; | 126 bool IsOnPath(const std::string& url_path) const; |
122 | 127 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 bool httponly_; | 212 bool httponly_; |
208 CookieSameSite same_site_; | 213 CookieSameSite same_site_; |
209 CookiePriority priority_; | 214 CookiePriority priority_; |
210 }; | 215 }; |
211 | 216 |
212 typedef std::vector<CanonicalCookie> CookieList; | 217 typedef std::vector<CanonicalCookie> CookieList; |
213 | 218 |
214 } // namespace net | 219 } // namespace net |
215 | 220 |
216 #endif // NET_COOKIES_CANONICAL_COOKIE_H_ | 221 #endif // NET_COOKIES_CANONICAL_COOKIE_H_ |
OLD | NEW |