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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (IsSecure() && !url.SchemeIsCryptographic()) | 415 if (IsSecure() && !url.SchemeIsCryptographic()) |
416 return false; | 416 return false; |
417 // Don't include cookies for requests that don't apply to the cookie domain. | 417 // Don't include cookies for requests that don't apply to the cookie domain. |
418 if (!IsDomainMatch(url.host())) | 418 if (!IsDomainMatch(url.host())) |
419 return false; | 419 return false; |
420 // Don't include cookies for requests with a url path that does not path | 420 // Don't include cookies for requests with a url path that does not path |
421 // match the cookie-path. | 421 // match the cookie-path. |
422 if (!IsOnPath(url.path())) | 422 if (!IsOnPath(url.path())) |
423 return false; | 423 return false; |
424 // Don't include same-site cookies for cross-site requests. | 424 // Don't include same-site cookies for cross-site requests. |
425 // | 425 if (SameSite() > options.include_same_site()) |
426 // TODO(mkwst): This currently treats both "strict" and "lax" SameSite cookies | |
427 // in the same way. https://codereview.chromium.org/1783813002 will eventually | |
428 // distinguish between them based on attributes of the request. | |
429 if (SameSite() != CookieSameSite::NO_RESTRICTION && | |
430 !options.include_same_site()) { | |
431 return false; | 426 return false; |
432 } | |
433 | 427 |
434 return true; | 428 return true; |
435 } | 429 } |
436 | 430 |
437 std::string CanonicalCookie::DebugString() const { | 431 std::string CanonicalCookie::DebugString() const { |
438 return base::StringPrintf( | 432 return base::StringPrintf( |
439 "name: %s value: %s domain: %s path: %s creation: %" PRId64, | 433 "name: %s value: %s domain: %s path: %s creation: %" PRId64, |
440 name_.c_str(), value_.c_str(), domain_.c_str(), path_.c_str(), | 434 name_.c_str(), value_.c_str(), domain_.c_str(), path_.c_str(), |
441 static_cast<int64_t>(creation_date_.ToTimeT())); | 435 static_cast<int64_t>(creation_date_.ToTimeT())); |
442 } | 436 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 if (prefix == CanonicalCookie::COOKIE_PREFIX_SECURE) | 507 if (prefix == CanonicalCookie::COOKIE_PREFIX_SECURE) |
514 return parsed_cookie.IsSecure() && url.SchemeIsCryptographic(); | 508 return parsed_cookie.IsSecure() && url.SchemeIsCryptographic(); |
515 if (prefix == CanonicalCookie::COOKIE_PREFIX_HOST) { | 509 if (prefix == CanonicalCookie::COOKIE_PREFIX_HOST) { |
516 return parsed_cookie.IsSecure() && url.SchemeIsCryptographic() && | 510 return parsed_cookie.IsSecure() && url.SchemeIsCryptographic() && |
517 !parsed_cookie.HasDomain() && parsed_cookie.Path() == "/"; | 511 !parsed_cookie.HasDomain() && parsed_cookie.Path() == "/"; |
518 } | 512 } |
519 return true; | 513 return true; |
520 } | 514 } |
521 | 515 |
522 } // namespace net | 516 } // namespace net |
OLD | NEW |