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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 const GURL& url, | 399 const GURL& url, |
400 const std::string& name, | 400 const std::string& name, |
401 const std::string& value, | 401 const std::string& value, |
402 const std::string& domain, | 402 const std::string& domain, |
403 const std::string& path, | 403 const std::string& path, |
404 base::Time creation_time, | 404 base::Time creation_time, |
405 base::Time expiration_time, | 405 base::Time expiration_time, |
406 base::Time last_access_time, | 406 base::Time last_access_time, |
407 bool secure, | 407 bool secure, |
408 bool http_only, | 408 bool http_only, |
409 bool same_site, | 409 CookieSameSite same_site, |
410 bool enforce_strict_secure, | 410 bool enforce_strict_secure, |
411 CookiePriority priority, | 411 CookiePriority priority, |
412 const SetCookiesCallback& callback) | 412 const SetCookiesCallback& callback) |
413 : CookieMonsterTask(cookie_monster), | 413 : CookieMonsterTask(cookie_monster), |
414 url_(url), | 414 url_(url), |
415 name_(name), | 415 name_(name), |
416 value_(value), | 416 value_(value), |
417 domain_(domain), | 417 domain_(domain), |
418 path_(path), | 418 path_(path), |
419 creation_time_(creation_time), | 419 creation_time_(creation_time), |
(...skipping 16 matching lines...) Expand all Loading... |
436 GURL url_; | 436 GURL url_; |
437 std::string name_; | 437 std::string name_; |
438 std::string value_; | 438 std::string value_; |
439 std::string domain_; | 439 std::string domain_; |
440 std::string path_; | 440 std::string path_; |
441 base::Time creation_time_; | 441 base::Time creation_time_; |
442 base::Time expiration_time_; | 442 base::Time expiration_time_; |
443 base::Time last_access_time_; | 443 base::Time last_access_time_; |
444 bool secure_; | 444 bool secure_; |
445 bool http_only_; | 445 bool http_only_; |
446 bool same_site_; | 446 CookieSameSite same_site_; |
447 bool enforce_strict_secure_; | 447 bool enforce_strict_secure_; |
448 CookiePriority priority_; | 448 CookiePriority priority_; |
449 SetCookiesCallback callback_; | 449 SetCookiesCallback callback_; |
450 | 450 |
451 DISALLOW_COPY_AND_ASSIGN(SetCookieWithDetailsTask); | 451 DISALLOW_COPY_AND_ASSIGN(SetCookieWithDetailsTask); |
452 }; | 452 }; |
453 | 453 |
454 void CookieMonster::SetCookieWithDetailsTask::Run() { | 454 void CookieMonster::SetCookieWithDetailsTask::Run() { |
455 bool success = this->cookie_monster()->SetCookieWithDetails( | 455 bool success = this->cookie_monster()->SetCookieWithDetails( |
456 url_, name_, value_, domain_, path_, creation_time_, expiration_time_, | 456 url_, name_, value_, domain_, path_, creation_time_, expiration_time_, |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 const GURL& url, | 843 const GURL& url, |
844 const std::string& name, | 844 const std::string& name, |
845 const std::string& value, | 845 const std::string& value, |
846 const std::string& domain, | 846 const std::string& domain, |
847 const std::string& path, | 847 const std::string& path, |
848 Time creation_time, | 848 Time creation_time, |
849 Time expiration_time, | 849 Time expiration_time, |
850 Time last_access_time, | 850 Time last_access_time, |
851 bool secure, | 851 bool secure, |
852 bool http_only, | 852 bool http_only, |
853 bool same_site, | 853 CookieSameSite same_site, |
854 bool enforce_strict_secure, | 854 bool enforce_strict_secure, |
855 CookiePriority priority, | 855 CookiePriority priority, |
856 const SetCookiesCallback& callback) { | 856 const SetCookiesCallback& callback) { |
857 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask( | 857 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask( |
858 this, url, name, value, domain, path, creation_time, expiration_time, | 858 this, url, name, value, domain, path, creation_time, expiration_time, |
859 last_access_time, secure, http_only, same_site, enforce_strict_secure, | 859 last_access_time, secure, http_only, same_site, enforce_strict_secure, |
860 priority, callback); | 860 priority, callback); |
861 DoCookieTaskForURL(task, url); | 861 DoCookieTaskForURL(task, url); |
862 } | 862 } |
863 | 863 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 bool CookieMonster::SetCookieWithDetails(const GURL& url, | 1033 bool CookieMonster::SetCookieWithDetails(const GURL& url, |
1034 const std::string& name, | 1034 const std::string& name, |
1035 const std::string& value, | 1035 const std::string& value, |
1036 const std::string& domain, | 1036 const std::string& domain, |
1037 const std::string& path, | 1037 const std::string& path, |
1038 base::Time creation_time, | 1038 base::Time creation_time, |
1039 base::Time expiration_time, | 1039 base::Time expiration_time, |
1040 base::Time last_access_time, | 1040 base::Time last_access_time, |
1041 bool secure, | 1041 bool secure, |
1042 bool http_only, | 1042 bool http_only, |
1043 bool same_site, | 1043 CookieSameSite same_site, |
1044 bool enforce_strict_secure, | 1044 bool enforce_strict_secure, |
1045 CookiePriority priority) { | 1045 CookiePriority priority) { |
1046 DCHECK(thread_checker_.CalledOnValidThread()); | 1046 DCHECK(thread_checker_.CalledOnValidThread()); |
1047 | 1047 |
1048 if (!HasCookieableScheme(url)) | 1048 if (!HasCookieableScheme(url)) |
1049 return false; | 1049 return false; |
1050 | 1050 |
1051 // TODO(mmenke): This class assumes each cookie to have a unique creation | 1051 // TODO(mmenke): This class assumes each cookie to have a unique creation |
1052 // time. Allowing the caller to set the creation time violates that | 1052 // time. Allowing the caller to set the creation time violates that |
1053 // assumption. Worth fixing? Worth noting that time changes between browser | 1053 // assumption. Worth fixing? Worth noting that time changes between browser |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 sync_to_store) | 1696 sync_to_store) |
1697 store_->AddCookie(*cc); | 1697 store_->AddCookie(*cc); |
1698 CookieMap::iterator inserted = | 1698 CookieMap::iterator inserted = |
1699 cookies_.insert(CookieMap::value_type(key, cc)); | 1699 cookies_.insert(CookieMap::value_type(key, cc)); |
1700 if (delegate_.get()) { | 1700 if (delegate_.get()) { |
1701 delegate_->OnCookieChanged(*cc, false, | 1701 delegate_->OnCookieChanged(*cc, false, |
1702 CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT); | 1702 CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT); |
1703 } | 1703 } |
1704 | 1704 |
1705 // See InitializeHistograms() for details. | 1705 // See InitializeHistograms() for details. |
1706 int32_t type_sample = cc->IsSameSite() ? 1 << COOKIE_TYPE_SAME_SITE : 0; | 1706 int32_t type_sample = |
| 1707 cc->SameSite() != COOKIE_SAME_SITE_NONE ? 1 << COOKIE_TYPE_SAME_SITE : 0; |
1707 type_sample |= cc->IsHttpOnly() ? 1 << COOKIE_TYPE_HTTPONLY : 0; | 1708 type_sample |= cc->IsHttpOnly() ? 1 << COOKIE_TYPE_HTTPONLY : 0; |
1708 type_sample |= cc->IsSecure() ? 1 << COOKIE_TYPE_SECURE : 0; | 1709 type_sample |= cc->IsSecure() ? 1 << COOKIE_TYPE_SECURE : 0; |
1709 histogram_cookie_type_->Add(type_sample); | 1710 histogram_cookie_type_->Add(type_sample); |
1710 | 1711 |
1711 // Histogram the type of scheme used on URLs that set cookies. This | 1712 // Histogram the type of scheme used on URLs that set cookies. This |
1712 // intentionally includes cookies that are set or overwritten by | 1713 // intentionally includes cookies that are set or overwritten by |
1713 // http:// URLs, but not cookies that are cleared by http:// URLs, to | 1714 // http:// URLs, but not cookies that are cleared by http:// URLs, to |
1714 // understand if the former behavior can be deprecated for Secure | 1715 // understand if the former behavior can be deprecated for Secure |
1715 // cookies. | 1716 // cookies. |
1716 if (!cc->Source().is_empty()) { | 1717 if (!cc->Source().is_empty()) { |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 it != hook_map_.end(); ++it) { | 2350 it != hook_map_.end(); ++it) { |
2350 std::pair<GURL, std::string> key = it->first; | 2351 std::pair<GURL, std::string> key = it->first; |
2351 if (cookie.IncludeForRequestURL(key.first, opts) && | 2352 if (cookie.IncludeForRequestURL(key.first, opts) && |
2352 cookie.Name() == key.second) { | 2353 cookie.Name() == key.second) { |
2353 it->second->Notify(cookie, removed); | 2354 it->second->Notify(cookie, removed); |
2354 } | 2355 } |
2355 } | 2356 } |
2356 } | 2357 } |
2357 | 2358 |
2358 } // namespace net | 2359 } // namespace net |
OLD | NEW |