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

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

Issue 2903213004: Refactor transmission of security of source and http_only mods in cookie_monster.cc. (Closed)
Patch Set: Revert test reference to histogram back. Created 3 years, 6 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 | « no previous file | net/cookies/cookie_monster.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 // Brought to you by the letter D and the number 2. 5 // Brought to you by the letter D and the number 2.
6 6
7 #ifndef NET_COOKIES_COOKIE_MONSTER_H_ 7 #ifndef NET_COOKIES_COOKIE_MONSTER_H_
8 #define NET_COOKIES_COOKIE_MONSTER_H_ 8 #define NET_COOKIES_COOKIE_MONSTER_H_
9 9
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 ChannelIDService* channel_id_service); 143 ChannelIDService* channel_id_service);
144 144
145 // Only used during unit testing. 145 // Only used during unit testing.
146 CookieMonster(PersistentCookieStore* store, 146 CookieMonster(PersistentCookieStore* store,
147 CookieMonsterDelegate* delegate, 147 CookieMonsterDelegate* delegate,
148 base::TimeDelta last_access_threshold); 148 base::TimeDelta last_access_threshold);
149 149
150 ~CookieMonster() override; 150 ~CookieMonster() override;
151 151
152 // Replaces all the cookies by |list|. This method does not flush the backend. 152 // Replaces all the cookies by |list|. This method does not flush the backend.
153 // This method does not support setting secure cookies, which need source 153 // TODO(rdsmith, mmenke): Do not use this function; it is deprecated
154 // URLs. 154 // and should be removed.
155 // TODO(mmenke): This method is only used on iOS. Consider removing it. 155 // See https://codereview.chromium.org/2882063002/#msg64.
droger 2017/06/09 12:22:52 If this function is broken in some way (i.e. does
Randy Smith (Not in Mondays) 2017/06/09 13:43:34 It actually isn't, anymore; it's really just doing
droger 2017/06/09 15:17:32 I just thought (from comments on other CL) that th
droger 2017/06/09 15:19:25 Ah, after reading better... actually I fell into t
Randy Smith (Not in Mondays) 2017/06/09 17:41:50 It used to not work properly with secure cookies,
Randy Smith (Not in Mondays) 2017/06/09 17:41:50 Done.
156 void SetAllCookiesAsync(const CookieList& list, 156 void SetAllCookiesAsync(const CookieList& list,
157 const SetCookiesCallback& callback); 157 const SetCookiesCallback& callback);
158 158
159 // CookieStore implementation. 159 // CookieStore implementation.
160 void SetCookieWithOptionsAsync(const GURL& url, 160 void SetCookieWithOptionsAsync(const GURL& url,
161 const std::string& cookie_line, 161 const std::string& cookie_line,
162 const CookieOptions& options, 162 const CookieOptions& options,
163 const SetCookiesCallback& callback) override; 163 const SetCookiesCallback& callback) override;
164 void SetCookieWithDetailsAsync(const GURL& url, 164 void SetCookieWithDetailsAsync(const GURL& url,
165 const std::string& name, 165 const std::string& name,
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 const CookieOptions& options, 507 const CookieOptions& options,
508 std::vector<CanonicalCookie*>* cookies); 508 std::vector<CanonicalCookie*>* cookies);
509 509
510 void FindCookiesForKey(const std::string& key, 510 void FindCookiesForKey(const std::string& key,
511 const GURL& url, 511 const GURL& url,
512 const CookieOptions& options, 512 const CookieOptions& options,
513 const base::Time& current, 513 const base::Time& current,
514 std::vector<CanonicalCookie*>* cookies); 514 std::vector<CanonicalCookie*>* cookies);
515 515
516 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). 516 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc).
517 // |source_url| is the URL that is attempting to set the cookie. 517 // |source_secure| indicates if the source may override existing secure
518 // cookies.
518 // If |skip_httponly| is true, httponly cookies will not be deleted. The 519 // If |skip_httponly| is true, httponly cookies will not be deleted. The
519 // return value will be true if |skip_httponly| skipped an httponly cookie or 520 // return value will be true if |skip_httponly| skipped an httponly cookie or
520 // the cookie to delete was Secure and the scheme of |ecc| is insecure. |key| 521 // the cookie to delete was Secure and the scheme of |ecc| is insecure. |key|
521 // is the key to find the cookie in cookies_; see the comment before the 522 // is the key to find the cookie in cookies_; see the comment before the
522 // CookieMap typedef for details. 523 // CookieMap typedef for details.
523 // NOTE: There should never be more than a single matching equivalent cookie. 524 // NOTE: There should never be more than a single matching equivalent cookie.
524 bool DeleteAnyEquivalentCookie(const std::string& key, 525 bool DeleteAnyEquivalentCookie(const std::string& key,
525 const CanonicalCookie& ecc, 526 const CanonicalCookie& ecc,
526 const GURL& source_url, 527 bool source_secure,
527 bool skip_httponly, 528 bool skip_httponly,
528 bool already_expired); 529 bool already_expired);
529 530
530 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted 531 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted
531 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. 532 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid.
533 // |secure_source| indicates if the setting of the canonical cookie is
534 // coming from a secure source (e.g. a cryptographically schemed URL).
532 CookieMap::iterator InternalInsertCookie(const std::string& key, 535 CookieMap::iterator InternalInsertCookie(const std::string& key,
533 std::unique_ptr<CanonicalCookie> cc, 536 std::unique_ptr<CanonicalCookie> cc,
534 const GURL& source_url, 537 bool source_secure,
535 bool sync_to_store); 538 bool sync_to_store);
536 539
537 // Helper function that sets cookies with more control. 540 // Helper function that sets cookies with more control.
538 // Not exposed as we don't want callers to have the ability 541 // Not exposed as we don't want callers to have the ability
539 // to specify (potentially duplicate) creation times. 542 // to specify (potentially duplicate) creation times.
540 bool SetCookieWithCreationTimeAndOptions(const GURL& url, 543 bool SetCookieWithCreationTimeAndOptions(const GURL& url,
541 const std::string& cookie_line, 544 const std::string& cookie_line,
542 const base::Time& creation_time, 545 const base::Time& creation_time,
543 const CookieOptions& options); 546 const CookieOptions& options);
544 547
545 // Helper function that sets a canonical cookie, deleting equivalents and 548 // Sets a canonical cookie, deletes equivalents and performs garbage
546 // performing garbage collection. 549 // collection. |source_secure| indicates if the cookie is being set
547 // |source_url| is the URL that's attempting to set the cookie. 550 // from a secure source (e.g. a cryptographic scheme).
548 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc, 551 // |modify_http_only| indicates if this setting operation is allowed
549 const GURL& source_url, 552 // to affect http_only cookies.
550 const CookieOptions& options); 553 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cookie,
554 bool secure_source,
555 bool can_modify_httponly);
551 556
552 // Helper function calling SetCanonicalCookie() for all cookies in |list|. 557 // Sets all cookies from |list| after deleting any equivalent cookie.
553 bool SetCanonicalCookies(const CookieList& list); 558 // For data gathering purposes, this routine is treated as if it is
559 // restoring saved cookies; some statistics are not gathered in this case.
560 bool SetAllCookies(const CookieList& list);
554 561
555 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, 562 void InternalUpdateCookieAccessTime(CanonicalCookie* cc,
556 const base::Time& current_time); 563 const base::Time& current_time);
557 564
558 // |deletion_cause| argument is used for collecting statistics and choosing 565 // |deletion_cause| argument is used for collecting statistics and choosing
559 // the correct CookieStore::ChangeCause for OnCookieChanged 566 // the correct CookieStore::ChangeCause for OnCookieChanged
560 // notifications. Guarantee: All iterators to cookies_ except to the 567 // notifications. Guarantee: All iterators to cookies_ except to the
561 // deleted entry remain valid. 568 // deleted entry remain valid.
562 void InternalDeleteCookie(CookieMap::iterator it, 569 void InternalDeleteCookie(CookieMap::iterator it,
563 bool sync_to_store, 570 bool sync_to_store,
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 virtual ~PersistentCookieStore() {} 823 virtual ~PersistentCookieStore() {}
817 824
818 private: 825 private:
819 friend class base::RefCountedThreadSafe<PersistentCookieStore>; 826 friend class base::RefCountedThreadSafe<PersistentCookieStore>;
820 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 827 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
821 }; 828 };
822 829
823 } // namespace net 830 } // namespace net
824 831
825 #endif // NET_COOKIES_COOKIE_MONSTER_H_ 832 #endif // NET_COOKIES_COOKIE_MONSTER_H_
OLDNEW
« no previous file with comments | « no previous file | net/cookies/cookie_monster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698