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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 const CookieOptions& options, | 510 const CookieOptions& options, |
509 std::vector<CanonicalCookie*>* cookies); | 511 std::vector<CanonicalCookie*>* cookies); |
510 | 512 |
511 void FindCookiesForKey(const std::string& key, | 513 void FindCookiesForKey(const std::string& key, |
512 const GURL& url, | 514 const GURL& url, |
513 const CookieOptions& options, | 515 const CookieOptions& options, |
514 const base::Time& current, | 516 const base::Time& current, |
515 std::vector<CanonicalCookie*>* cookies); | 517 std::vector<CanonicalCookie*>* cookies); |
516 | 518 |
517 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). | 519 // Delete any cookies that are equivalent to |ecc| (same path, domain, etc). |
518 // |source_url| is the URL that is attempting to set the cookie. | 520 // |source_secure| indicates if the source may override existing secure |
| 521 // cookies. |
519 // If |skip_httponly| is true, httponly cookies will not be deleted. The | 522 // If |skip_httponly| is true, httponly cookies will not be deleted. The |
520 // return value will be true if |skip_httponly| skipped an httponly cookie or | 523 // return value will be true if |skip_httponly| skipped an httponly cookie or |
521 // the cookie to delete was Secure and the scheme of |ecc| is insecure. |key| | 524 // the cookie to delete was Secure and the scheme of |ecc| is insecure. |key| |
522 // is the key to find the cookie in cookies_; see the comment before the | 525 // is the key to find the cookie in cookies_; see the comment before the |
523 // CookieMap typedef for details. | 526 // CookieMap typedef for details. |
524 // NOTE: There should never be more than a single matching equivalent cookie. | 527 // NOTE: There should never be more than a single matching equivalent cookie. |
525 bool DeleteAnyEquivalentCookie(const std::string& key, | 528 bool DeleteAnyEquivalentCookie(const std::string& key, |
526 const CanonicalCookie& ecc, | 529 const CanonicalCookie& ecc, |
527 const GURL& source_url, | 530 bool source_secure, |
528 bool skip_httponly, | 531 bool skip_httponly, |
529 bool already_expired); | 532 bool already_expired); |
530 | 533 |
531 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted | 534 // Inserts |cc| into cookies_. Returns an iterator that points to the inserted |
532 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. | 535 // cookie in cookies_. Guarantee: all iterators to cookies_ remain valid. |
533 CookieMap::iterator InternalInsertCookie(const std::string& key, | 536 CookieMap::iterator InternalInsertCookie(const std::string& key, |
534 std::unique_ptr<CanonicalCookie> cc, | 537 std::unique_ptr<CanonicalCookie> cc, |
535 const GURL& source_url, | |
536 bool sync_to_store); | 538 bool sync_to_store); |
537 | 539 |
538 // Helper function that sets cookies with more control. | 540 // Helper function that sets cookies with more control. |
539 // 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 |
540 // to specify (potentially duplicate) creation times. | 542 // to specify (potentially duplicate) creation times. |
541 bool SetCookieWithCreationTimeAndOptions(const GURL& url, | 543 bool SetCookieWithCreationTimeAndOptions(const GURL& url, |
542 const std::string& cookie_line, | 544 const std::string& cookie_line, |
543 const base::Time& creation_time, | 545 const base::Time& creation_time, |
544 const CookieOptions& options); | 546 const CookieOptions& options); |
545 | 547 |
546 // Helper function that sets a canonical cookie, deleting equivalents and | 548 // Sets a canonical cookie, deletes equivalents and performs garbage |
547 // performing garbage collection. | 549 // collection. |source_secure| indicates if the cookie is being set |
548 // |source_url| is the URL that's attempting to set the cookie. | 550 // from a secure source (e.g. a cryptographic scheme). |
549 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc, | 551 // |modify_http_only| indicates if this setting operation is allowed |
550 const GURL& source_url, | 552 // to affect http_only cookies. |
551 const CookieOptions& options); | 553 bool SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cookie, |
| 554 bool secure_source, |
| 555 bool can_modify_httponly); |
552 | 556 |
553 // Helper function calling SetCanonicalCookie() for all cookies in |list|. | 557 // Sets all cookies from |list| after deleting any equivalent cookie. |
554 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); |
555 | 561 |
556 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, | 562 void InternalUpdateCookieAccessTime(CanonicalCookie* cc, |
557 const base::Time& current_time); | 563 const base::Time& current_time); |
558 | 564 |
559 // |deletion_cause| argument is used for collecting statistics and choosing | 565 // |deletion_cause| argument is used for collecting statistics and choosing |
560 // the correct CookieStore::ChangeCause for OnCookieChanged | 566 // the correct CookieStore::ChangeCause for OnCookieChanged |
561 // notifications. Guarantee: All iterators to cookies_ except to the | 567 // notifications. Guarantee: All iterators to cookies_ except to the |
562 // deleted entry remain valid. | 568 // deleted entry remain valid. |
563 void InternalDeleteCookie(CookieMap::iterator it, | 569 void InternalDeleteCookie(CookieMap::iterator it, |
564 bool sync_to_store, | 570 bool sync_to_store, |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 virtual ~PersistentCookieStore() {} | 827 virtual ~PersistentCookieStore() {} |
822 | 828 |
823 private: | 829 private: |
824 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 830 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
825 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 831 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
826 }; | 832 }; |
827 | 833 |
828 } // namespace net | 834 } // namespace net |
829 | 835 |
830 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 836 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |