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 <deque> | 10 #include <deque> |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // Only used during unit testing. | 117 // Only used during unit testing. |
118 CookieMonster(PersistentCookieStore* store, | 118 CookieMonster(PersistentCookieStore* store, |
119 Delegate* delegate, | 119 Delegate* delegate, |
120 int last_access_threshold_milliseconds); | 120 int last_access_threshold_milliseconds); |
121 | 121 |
122 // Helper function that adds all cookies from |list| into this instance. | 122 // Helper function that adds all cookies from |list| into this instance. |
123 bool InitializeFrom(const CookieList& list); | 123 bool InitializeFrom(const CookieList& list); |
124 | 124 |
125 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback; | 125 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback; |
126 typedef base::Callback<void(bool success)> DeleteCookieCallback; | 126 typedef base::Callback<void(bool success)> DeleteCookieCallback; |
| 127 typedef base::Callback<void(bool cookies_exist)> HasCookiesForETLDP1Callback; |
127 | 128 |
128 // Sets a cookie given explicit user-provided cookie attributes. The cookie | 129 // Sets a cookie given explicit user-provided cookie attributes. The cookie |
129 // name, value, domain, etc. are each provided as separate strings. This | 130 // name, value, domain, etc. are each provided as separate strings. This |
130 // function expects each attribute to be well-formed. It will check for | 131 // function expects each attribute to be well-formed. It will check for |
131 // disallowed characters (e.g. the ';' character is disallowed within the | 132 // disallowed characters (e.g. the ';' character is disallowed within the |
132 // cookie value attribute) and will return false without setting the cookie | 133 // cookie value attribute) and will return false without setting the cookie |
133 // if such characters are found. | 134 // if such characters are found. |
134 void SetCookieWithDetailsAsync(const GURL& url, | 135 void SetCookieWithDetailsAsync(const GURL& url, |
135 const std::string& name, | 136 const std::string& name, |
136 const std::string& value, | 137 const std::string& value, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // regardless of path. This includes all http_only and secure cookies, | 170 // regardless of path. This includes all http_only and secure cookies, |
170 // but does not include any domain cookies that may apply to this host. | 171 // but does not include any domain cookies that may apply to this host. |
171 // Returns the number of cookies deleted. | 172 // Returns the number of cookies deleted. |
172 void DeleteAllForHostAsync(const GURL& url, | 173 void DeleteAllForHostAsync(const GURL& url, |
173 const DeleteCallback& callback); | 174 const DeleteCallback& callback); |
174 | 175 |
175 // Deletes one specific cookie. | 176 // Deletes one specific cookie. |
176 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, | 177 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, |
177 const DeleteCookieCallback& callback); | 178 const DeleteCookieCallback& callback); |
178 | 179 |
| 180 // Checks whether for a given ETLD+1, there currently exist any cookies. |
| 181 void HasCookiesForETLDP1Async(const std::string& etldp1, |
| 182 const HasCookiesForETLDP1Callback& callback); |
| 183 |
179 // Resets the list of cookieable schemes to the supplied schemes. | 184 // Resets the list of cookieable schemes to the supplied schemes. |
180 // If this this method is called, it must be called before first use of | 185 // If this this method is called, it must be called before first use of |
181 // the instance (i.e. as part of the instance initialization process). | 186 // the instance (i.e. as part of the instance initialization process). |
182 void SetCookieableSchemes(const char* schemes[], size_t num_schemes); | 187 void SetCookieableSchemes(const char* schemes[], size_t num_schemes); |
183 | 188 |
184 // Resets the list of cookieable schemes to kDefaultCookieableSchemes with or | 189 // Resets the list of cookieable schemes to kDefaultCookieableSchemes with or |
185 // without 'file' being included. | 190 // without 'file' being included. |
186 void SetEnableFileScheme(bool accept); | 191 void SetEnableFileScheme(bool accept); |
187 | 192 |
188 // Instructs the cookie monster to not delete expired cookies. This is used | 193 // Instructs the cookie monster to not delete expired cookies. This is used |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 class DeleteAllForHostTask; | 274 class DeleteAllForHostTask; |
270 class DeleteAllTask; | 275 class DeleteAllTask; |
271 class DeleteCookieTask; | 276 class DeleteCookieTask; |
272 class DeleteCanonicalCookieTask; | 277 class DeleteCanonicalCookieTask; |
273 class GetAllCookiesForURLWithOptionsTask; | 278 class GetAllCookiesForURLWithOptionsTask; |
274 class GetAllCookiesTask; | 279 class GetAllCookiesTask; |
275 class GetCookiesWithOptionsTask; | 280 class GetCookiesWithOptionsTask; |
276 class SetCookieWithDetailsTask; | 281 class SetCookieWithDetailsTask; |
277 class SetCookieWithOptionsTask; | 282 class SetCookieWithOptionsTask; |
278 class DeleteSessionCookiesTask; | 283 class DeleteSessionCookiesTask; |
| 284 class HasCookiesForETLDP1Task; |
279 | 285 |
280 // Testing support. | 286 // Testing support. |
281 // For SetCookieWithCreationTime. | 287 // For SetCookieWithCreationTime. |
282 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, | 288 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, |
283 TestCookieDeleteAllCreatedBetweenTimestamps); | 289 TestCookieDeleteAllCreatedBetweenTimestamps); |
284 | 290 |
285 // For gargage collection constants. | 291 // For gargage collection constants. |
286 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestHostGarbageCollection); | 292 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestHostGarbageCollection); |
287 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestTotalGarbageCollection); | 293 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestTotalGarbageCollection); |
288 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GarbageCollectionTriggers); | 294 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GarbageCollectionTriggers); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 const CookieOptions& options); | 403 const CookieOptions& options); |
398 | 404 |
399 void DeleteCookie(const GURL& url, const std::string& cookie_name); | 405 void DeleteCookie(const GURL& url, const std::string& cookie_name); |
400 | 406 |
401 bool SetCookieWithCreationTime(const GURL& url, | 407 bool SetCookieWithCreationTime(const GURL& url, |
402 const std::string& cookie_line, | 408 const std::string& cookie_line, |
403 const base::Time& creation_time); | 409 const base::Time& creation_time); |
404 | 410 |
405 int DeleteSessionCookies(); | 411 int DeleteSessionCookies(); |
406 | 412 |
| 413 bool HasCookiesForETLDP1(const std::string& etldp1); |
| 414 |
407 // Called by all non-static functions to ensure that the cookies store has | 415 // Called by all non-static functions to ensure that the cookies store has |
408 // been initialized. This is not done during creating so it doesn't block | 416 // been initialized. This is not done during creating so it doesn't block |
409 // the window showing. | 417 // the window showing. |
410 // Note: this method should always be called with lock_ held. | 418 // Note: this method should always be called with lock_ held. |
411 void InitIfNecessary() { | 419 void InitIfNecessary() { |
412 if (!initialized_) { | 420 if (!initialized_) { |
413 if (store_) { | 421 if (store_) { |
414 InitStore(); | 422 InitStore(); |
415 } else { | 423 } else { |
416 loaded_ = true; | 424 loaded_ = true; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 virtual ~PersistentCookieStore() {} | 728 virtual ~PersistentCookieStore() {} |
721 | 729 |
722 private: | 730 private: |
723 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 731 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
724 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 732 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
725 }; | 733 }; |
726 | 734 |
727 } // namespace net | 735 } // namespace net |
728 | 736 |
729 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 737 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |