Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: net/cookies/cookie_monster.cc

Issue 1773133002: SameSite: Implement 'Strict'/'Lax' attribute parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke@ Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cookies/cookie_monster.h ('k') | net/cookies/cookie_monster_store_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 const GURL& url, 373 const GURL& url,
374 const std::string& name, 374 const std::string& name,
375 const std::string& value, 375 const std::string& value,
376 const std::string& domain, 376 const std::string& domain,
377 const std::string& path, 377 const std::string& path,
378 base::Time creation_time, 378 base::Time creation_time,
379 base::Time expiration_time, 379 base::Time expiration_time,
380 base::Time last_access_time, 380 base::Time last_access_time,
381 bool secure, 381 bool secure,
382 bool http_only, 382 bool http_only,
383 bool same_site, 383 CookieSameSite same_site,
384 bool enforce_strict_secure, 384 bool enforce_strict_secure,
385 CookiePriority priority, 385 CookiePriority priority,
386 const SetCookiesCallback& callback) 386 const SetCookiesCallback& callback)
387 : CookieMonsterTask(cookie_monster), 387 : CookieMonsterTask(cookie_monster),
388 url_(url), 388 url_(url),
389 name_(name), 389 name_(name),
390 value_(value), 390 value_(value),
391 domain_(domain), 391 domain_(domain),
392 path_(path), 392 path_(path),
393 creation_time_(creation_time), 393 creation_time_(creation_time),
(...skipping 16 matching lines...) Expand all
410 GURL url_; 410 GURL url_;
411 std::string name_; 411 std::string name_;
412 std::string value_; 412 std::string value_;
413 std::string domain_; 413 std::string domain_;
414 std::string path_; 414 std::string path_;
415 base::Time creation_time_; 415 base::Time creation_time_;
416 base::Time expiration_time_; 416 base::Time expiration_time_;
417 base::Time last_access_time_; 417 base::Time last_access_time_;
418 bool secure_; 418 bool secure_;
419 bool http_only_; 419 bool http_only_;
420 bool same_site_; 420 CookieSameSite same_site_;
421 bool enforce_strict_secure_; 421 bool enforce_strict_secure_;
422 CookiePriority priority_; 422 CookiePriority priority_;
423 SetCookiesCallback callback_; 423 SetCookiesCallback callback_;
424 424
425 DISALLOW_COPY_AND_ASSIGN(SetCookieWithDetailsTask); 425 DISALLOW_COPY_AND_ASSIGN(SetCookieWithDetailsTask);
426 }; 426 };
427 427
428 void CookieMonster::SetCookieWithDetailsTask::Run() { 428 void CookieMonster::SetCookieWithDetailsTask::Run() {
429 bool success = this->cookie_monster()->SetCookieWithDetails( 429 bool success = this->cookie_monster()->SetCookieWithDetails(
430 url_, name_, value_, domain_, path_, creation_time_, expiration_time_, 430 url_, name_, value_, domain_, path_, creation_time_, expiration_time_,
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 const GURL& url, 817 const GURL& url,
818 const std::string& name, 818 const std::string& name,
819 const std::string& value, 819 const std::string& value,
820 const std::string& domain, 820 const std::string& domain,
821 const std::string& path, 821 const std::string& path,
822 Time creation_time, 822 Time creation_time,
823 Time expiration_time, 823 Time expiration_time,
824 Time last_access_time, 824 Time last_access_time,
825 bool secure, 825 bool secure,
826 bool http_only, 826 bool http_only,
827 bool same_site, 827 CookieSameSite same_site,
828 bool enforce_strict_secure, 828 bool enforce_strict_secure,
829 CookiePriority priority, 829 CookiePriority priority,
830 const SetCookiesCallback& callback) { 830 const SetCookiesCallback& callback) {
831 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask( 831 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask(
832 this, url, name, value, domain, path, creation_time, expiration_time, 832 this, url, name, value, domain, path, creation_time, expiration_time,
833 last_access_time, secure, http_only, same_site, enforce_strict_secure, 833 last_access_time, secure, http_only, same_site, enforce_strict_secure,
834 priority, callback); 834 priority, callback);
835 DoCookieTaskForURL(task, url); 835 DoCookieTaskForURL(task, url);
836 } 836 }
837 837
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 bool CookieMonster::SetCookieWithDetails(const GURL& url, 1007 bool CookieMonster::SetCookieWithDetails(const GURL& url,
1008 const std::string& name, 1008 const std::string& name,
1009 const std::string& value, 1009 const std::string& value,
1010 const std::string& domain, 1010 const std::string& domain,
1011 const std::string& path, 1011 const std::string& path,
1012 base::Time creation_time, 1012 base::Time creation_time,
1013 base::Time expiration_time, 1013 base::Time expiration_time,
1014 base::Time last_access_time, 1014 base::Time last_access_time,
1015 bool secure, 1015 bool secure,
1016 bool http_only, 1016 bool http_only,
1017 bool same_site, 1017 CookieSameSite same_site,
1018 bool enforce_strict_secure, 1018 bool enforce_strict_secure,
1019 CookiePriority priority) { 1019 CookiePriority priority) {
1020 DCHECK(thread_checker_.CalledOnValidThread()); 1020 DCHECK(thread_checker_.CalledOnValidThread());
1021 1021
1022 if (!HasCookieableScheme(url)) 1022 if (!HasCookieableScheme(url))
1023 return false; 1023 return false;
1024 1024
1025 // TODO(mmenke): This class assumes each cookie to have a unique creation 1025 // TODO(mmenke): This class assumes each cookie to have a unique creation
1026 // time. Allowing the caller to set the creation time violates that 1026 // time. Allowing the caller to set the creation time violates that
1027 // assumption. Worth fixing? Worth noting that time changes between browser 1027 // assumption. Worth fixing? Worth noting that time changes between browser
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 sync_to_store) 1670 sync_to_store)
1671 store_->AddCookie(*cc); 1671 store_->AddCookie(*cc);
1672 CookieMap::iterator inserted = 1672 CookieMap::iterator inserted =
1673 cookies_.insert(CookieMap::value_type(key, cc)); 1673 cookies_.insert(CookieMap::value_type(key, cc));
1674 if (delegate_.get()) { 1674 if (delegate_.get()) {
1675 delegate_->OnCookieChanged(*cc, false, 1675 delegate_->OnCookieChanged(*cc, false,
1676 CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT); 1676 CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT);
1677 } 1677 }
1678 1678
1679 // See InitializeHistograms() for details. 1679 // See InitializeHistograms() for details.
1680 int32_t type_sample = cc->IsSameSite() ? 1 << COOKIE_TYPE_SAME_SITE : 0; 1680 int32_t type_sample = cc->SameSite() != CookieSameSite::NO_RESTRICTION
1681 ? 1 << COOKIE_TYPE_SAME_SITE
1682 : 0;
1681 type_sample |= cc->IsHttpOnly() ? 1 << COOKIE_TYPE_HTTPONLY : 0; 1683 type_sample |= cc->IsHttpOnly() ? 1 << COOKIE_TYPE_HTTPONLY : 0;
1682 type_sample |= cc->IsSecure() ? 1 << COOKIE_TYPE_SECURE : 0; 1684 type_sample |= cc->IsSecure() ? 1 << COOKIE_TYPE_SECURE : 0;
1683 histogram_cookie_type_->Add(type_sample); 1685 histogram_cookie_type_->Add(type_sample);
1684 1686
1685 // Histogram the type of scheme used on URLs that set cookies. This 1687 // Histogram the type of scheme used on URLs that set cookies. This
1686 // intentionally includes cookies that are set or overwritten by 1688 // intentionally includes cookies that are set or overwritten by
1687 // http:// URLs, but not cookies that are cleared by http:// URLs, to 1689 // http:// URLs, but not cookies that are cleared by http:// URLs, to
1688 // understand if the former behavior can be deprecated for Secure 1690 // understand if the former behavior can be deprecated for Secure
1689 // cookies. 1691 // cookies.
1690 if (!cc->Source().is_empty()) { 1692 if (!cc->Source().is_empty()) {
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 it != hook_map_.end(); ++it) { 2341 it != hook_map_.end(); ++it) {
2340 std::pair<GURL, std::string> key = it->first; 2342 std::pair<GURL, std::string> key = it->first;
2341 if (cookie.IncludeForRequestURL(key.first, opts) && 2343 if (cookie.IncludeForRequestURL(key.first, opts) &&
2342 cookie.Name() == key.second) { 2344 cookie.Name() == key.second) {
2343 it->second->Notify(cookie, removed); 2345 it->second->Notify(cookie, removed);
2344 } 2346 }
2345 } 2347 }
2346 } 2348 }
2347 2349
2348 } // namespace net 2350 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/cookie_monster.h ('k') | net/cookies/cookie_monster_store_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698