| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 CookieMonsterDelegate* delegate, | 142 CookieMonsterDelegate* delegate, |
| 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 // Writes all the cookies in |list| into the store, replacing existing |
| 153 // This method does not support setting secure cookies, which need source | 153 // cookies that collide. Does not affect cookies not listed in |list|. |
| 154 // URLs. | 154 // This method does not flush the backend. |
| 155 // TODO(mmenke): This method is only used on iOS. Consider removing it. | 155 // TODO(rdsmith, mmenke): Do not use this function; it is deprecated |
| 156 // and should be removed. |
| 157 // See https://codereview.chromium.org/2882063002/#msg64. |
| 156 void SetAllCookiesAsync(const CookieList& list, | 158 void SetAllCookiesAsync(const CookieList& list, |
| 157 const SetCookiesCallback& callback); | 159 const SetCookiesCallback& callback); |
| 158 | 160 |
| 159 // CookieStore implementation. | 161 // CookieStore implementation. |
| 160 void SetCookieWithOptionsAsync(const GURL& url, | 162 void SetCookieWithOptionsAsync(const GURL& url, |
| 161 const std::string& cookie_line, | 163 const std::string& cookie_line, |
| 162 const CookieOptions& options, | 164 const CookieOptions& options, |
| 163 const SetCookiesCallback& callback) override; | 165 const SetCookiesCallback& callback) override; |
| 164 void SetCookieWithDetailsAsync(const GURL& url, | 166 void SetCookieWithDetailsAsync(const GURL& url, |
| 165 const std::string& name, | 167 const std::string& name, |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 const CookieOptions& options, | 509 const CookieOptions& options, |
| 508 std::vector<CanonicalCookie*>* cookies); | 510 std::vector<CanonicalCookie*>* cookies); |
| 509 | 511 |
| 510 void FindCookiesForKey(const std::string& key, | 512 void FindCookiesForKey(const std::string& key, |
| 511 const GURL& url, | 513 const GURL& url, |
| 512 const CookieOptions& options, | 514 const CookieOptions& options, |
| 513 const base::Time& current, | 515 const base::Time& current, |
| 514 std::vector<CanonicalCookie*>* cookies); | 516 std::vector<CanonicalCookie*>* cookies); |
| 515 | 517 |
| 516 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). | 518 // 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. | 519 // |source_secure| indicates if the source may override existing secure |
| 520 // cookies. |
| 518 // If |skip_httponly| is true, httponly cookies will not be deleted. The | 521 // 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 | 522 // 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| | 523 // 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 | 524 // is the key to find the cookie in cookies_; see the comment before the |
| 522 // CookieMap typedef for details. | 525 // CookieMap typedef for details. |
| 523 // NOTE: There should never be more than a single matching equivalent cookie. | 526 // NOTE: There should never be more than a single matching equivalent cookie. |
| 524 bool DeleteAnyEquivalentCookie(const std::string& key, | 527 bool DeleteAnyEquivalentCookie(const std::string& key, |
| 525 const CanonicalCookie& ecc, | 528 const CanonicalCookie& ecc, |
| 526 const GURL& source_url, | 529 bool source_secure, |
| 527 bool skip_httponly, | 530 bool skip_httponly, |
| 528 bool already_expired); | 531 bool already_expired); |
| 529 | 532 |
| 530 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted | 533 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted |
| 531 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. | 534 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. |
| 535 // |secure_source| indicates if the setting of the canonical cookie is |
| 536 // coming from a secure source (e.g. a cryptographically schemed URL). |
| 532 CookieMap::iterator InternalInsertCookie(const std::string& key, | 537 CookieMap::iterator InternalInsertCookie(const std::string& key, |
| 533 std::unique_ptr<CanonicalCookie> cc, | 538 std::unique_ptr<CanonicalCookie> cc, |
| 534 const GURL& source_url, | 539 bool source_secure, |
| 535 bool sync_to_store); | 540 bool sync_to_store); |
| 536 | 541 |
| 537 // Helper function that sets cookies with more control. | 542 // Helper function that sets cookies with more control. |
| 538 // Not exposed as we don't want callers to have the ability | 543 // Not exposed as we don't want callers to have the ability |
| 539 // to specify (potentially duplicate) creation times. | 544 // to specify (potentially duplicate) creation times. |
| 540 bool SetCookieWithCreationTimeAndOptions(const GURL& url, | 545 bool SetCookieWithCreationTimeAndOptions(const GURL& url, |
| 541 const std::string& cookie_line, | 546 const std::string& cookie_line, |
| 542 const base::Time& creation_time, | 547 const base::Time& creation_time, |
| 543 const CookieOptions& options); | 548 const CookieOptions& options); |
| 544 | 549 |
| 545 // Helper function that sets a canonical cookie, deleting equivalents and | 550 // Sets a canonical cookie, deletes equivalents and performs garbage |
| 546 // performing garbage collection. | 551 // collection. |source_secure| indicates if the cookie is being set |
| 547 // |source_url| is the URL that's attempting to set the cookie. | 552 // from a secure source (e.g. a cryptographic scheme). |
| 548 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc, | 553 // |modify_http_only| indicates if this setting operation is allowed |
| 549 const GURL& source_url, | 554 // to affect http_only cookies. |
| 550 const CookieOptions& options); | 555 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cookie, |
| 556 bool secure_source, |
| 557 bool can_modify_httponly); |
| 551 | 558 |
| 552 // Helper function calling SetCanonicalCookie() for all cookies in |list|. | 559 // Sets all cookies from |list| after deleting any equivalent cookie. |
| 553 bool SetCanonicalCookies(const CookieList& list); | 560 // For data gathering purposes, this routine is treated as if it is |
| 561 // restoring saved cookies; some statistics are not gathered in this case. |
| 562 bool SetAllCookies(const CookieList& list); |
| 554 | 563 |
| 555 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, | 564 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, |
| 556 const base::Time& current_time); | 565 const base::Time& current_time); |
| 557 | 566 |
| 558 // |deletion_cause| argument is used for collecting statistics and choosing | 567 // |deletion_cause| argument is used for collecting statistics and choosing |
| 559 // the correct CookieStore::ChangeCause for OnCookieChanged | 568 // the correct CookieStore::ChangeCause for OnCookieChanged |
| 560 // notifications. Guarantee: All iterators to cookies_ except to the | 569 // notifications. Guarantee: All iterators to cookies_ except to the |
| 561 // deleted entry remain valid. | 570 // deleted entry remain valid. |
| 562 void InternalDeleteCookie(CookieMap::iterator it, | 571 void InternalDeleteCookie(CookieMap::iterator it, |
| 563 bool sync_to_store, | 572 bool sync_to_store, |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 virtual ~PersistentCookieStore() {} | 825 virtual ~PersistentCookieStore() {} |
| 817 | 826 |
| 818 private: | 827 private: |
| 819 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 828 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
| 820 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 829 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
| 821 }; | 830 }; |
| 822 | 831 |
| 823 } // namespace net | 832 } // namespace net |
| 824 | 833 |
| 825 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 834 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
| OLD | NEW |