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 // 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate); | 135 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate); |
136 | 136 |
137 // Only used during unit testing. | 137 // Only used during unit testing. |
138 CookieMonster(PersistentCookieStore* store, | 138 CookieMonster(PersistentCookieStore* store, |
139 CookieMonsterDelegate* delegate, | 139 CookieMonsterDelegate* delegate, |
140 base::TimeDelta last_access_threshold); | 140 base::TimeDelta last_access_threshold); |
141 | 141 |
142 ~CookieMonster() override; | 142 ~CookieMonster() override; |
143 | 143 |
144 // Replaces all the cookies by |list|. This method does not flush the backend. | 144 // Replaces all the cookies by |list|. This method does not flush the backend. |
| 145 // This method does not support setting secure cookies, which need source |
| 146 // URLs. |
145 void SetAllCookiesAsync(const CookieList& list, | 147 void SetAllCookiesAsync(const CookieList& list, |
146 const SetCookiesCallback& callback); | 148 const SetCookiesCallback& callback); |
147 | 149 |
148 // CookieStore implementation. | 150 // CookieStore implementation. |
149 void SetCookieWithOptionsAsync(const GURL& url, | 151 void SetCookieWithOptionsAsync(const GURL& url, |
150 const std::string& cookie_line, | 152 const std::string& cookie_line, |
151 const CookieOptions& options, | 153 const CookieOptions& options, |
152 const SetCookiesCallback& callback) override; | 154 const SetCookiesCallback& callback) override; |
153 void SetCookieWithDetailsAsync(const GURL& url, | 155 void SetCookieWithDetailsAsync(const GURL& url, |
154 const std::string& name, | 156 const std::string& name, |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 const CookieOptions& options, | 482 const CookieOptions& options, |
481 std::vector<CanonicalCookie*>* cookies); | 483 std::vector<CanonicalCookie*>* cookies); |
482 | 484 |
483 void FindCookiesForKey(const std::string& key, | 485 void FindCookiesForKey(const std::string& key, |
484 const GURL& url, | 486 const GURL& url, |
485 const CookieOptions& options, | 487 const CookieOptions& options, |
486 const base::Time& current, | 488 const base::Time& current, |
487 std::vector<CanonicalCookie*>* cookies); | 489 std::vector<CanonicalCookie*>* cookies); |
488 | 490 |
489 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). | 491 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). |
| 492 // |source_url| is the URL that is attempting to set the cookie. |
490 // If |skip_httponly| is true, httponly cookies will not be deleted. The | 493 // If |skip_httponly| is true, httponly cookies will not be deleted. The |
491 // return value will be true if |skip_httponly| skipped an httponly cookie or | 494 // return value will be true if |skip_httponly| skipped an httponly cookie or |
492 // |enforce_strict_secure| is true and the cookie to | 495 // |enforce_strict_secure| is true and the cookie to |
493 // delete was Secure and the scheme of |ecc| is insecure. |key| is the key to | 496 // delete was Secure and the scheme of |ecc| is insecure. |key| is the key to |
494 // find the cookie in cookies_; see the comment before the CookieMap typedef | 497 // find the cookie in cookies_; see the comment before the CookieMap typedef |
495 // for details. | 498 // for details. |
496 // NOTE: There should never be more than a single matching equivalent cookie. | 499 // NOTE: There should never be more than a single matching equivalent cookie. |
497 bool DeleteAnyEquivalentCookie(const std::string& key, | 500 bool DeleteAnyEquivalentCookie(const std::string& key, |
498 const CanonicalCookie& ecc, | 501 const CanonicalCookie& ecc, |
| 502 const GURL& source_url, |
499 bool skip_httponly, | 503 bool skip_httponly, |
500 bool already_expired, | 504 bool already_expired, |
501 bool enforce_strict_secure); | 505 bool enforce_strict_secure); |
502 | 506 |
503 // Takes ownership of *cc. Returns an iterator that points to the inserted | 507 // Takes ownership of *cc. Returns an iterator that points to the inserted |
504 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. | 508 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. |
505 CookieMap::iterator InternalInsertCookie(const std::string& key, | 509 CookieMap::iterator InternalInsertCookie(const std::string& key, |
506 CanonicalCookie* cc, | 510 CanonicalCookie* cc, |
| 511 const GURL& source_url, |
507 bool sync_to_store); | 512 bool sync_to_store); |
508 | 513 |
509 // Helper function that sets cookies with more control. | 514 // Helper function that sets cookies with more control. |
510 // Not exposed as we don't want callers to have the ability | 515 // Not exposed as we don't want callers to have the ability |
511 // to specify (potentially duplicate) creation times. | 516 // to specify (potentially duplicate) creation times. |
512 bool SetCookieWithCreationTimeAndOptions(const GURL& url, | 517 bool SetCookieWithCreationTimeAndOptions(const GURL& url, |
513 const std::string& cookie_line, | 518 const std::string& cookie_line, |
514 const base::Time& creation_time, | 519 const base::Time& creation_time, |
515 const CookieOptions& options); | 520 const CookieOptions& options); |
516 | 521 |
517 // Helper function that sets a canonical cookie, deleting equivalents and | 522 // Helper function that sets a canonical cookie, deleting equivalents and |
518 // performing garbage collection. | 523 // performing garbage collection. |
| 524 // |source_url| is the URL that's attempting to set the cookie. |
519 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc, | 525 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc, |
| 526 const GURL& source_url, |
520 const CookieOptions& options); | 527 const CookieOptions& options); |
521 | 528 |
522 // Helper function calling SetCanonicalCookie() for all cookies in |list|. | 529 // Helper function calling SetCanonicalCookie() for all cookies in |list|. |
523 bool SetCanonicalCookies(const CookieList& list); | 530 bool SetCanonicalCookies(const CookieList& list); |
524 | 531 |
525 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, | 532 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, |
526 const base::Time& current_time); | 533 const base::Time& current_time); |
527 | 534 |
528 // |deletion_cause| argument is used for collecting statistics and choosing | 535 // |deletion_cause| argument is used for collecting statistics and choosing |
529 // the correct CookieMonsterDelegate::ChangeCause for OnCookieChanged | 536 // the correct CookieMonsterDelegate::ChangeCause for OnCookieChanged |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 virtual ~PersistentCookieStore() {} | 806 virtual ~PersistentCookieStore() {} |
800 | 807 |
801 private: | 808 private: |
802 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 809 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
803 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 810 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
804 }; | 811 }; |
805 | 812 |
806 } // namespace net | 813 } // namespace net |
807 | 814 |
808 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 815 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |