Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_BROWSING_DATA_COOKIE_HELPER_H_ | |
| 6 #define CHROME_BROWSER_BROWSING_DATA_COOKIE_HELPER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "net/base/cookie_monster.h" | |
| 12 #include "net/url_request/url_request_context_getter.h" | |
| 13 | |
|
erikwright (departed)
2011/07/18 02:08:30
Include what you use (scoped_refptr, DISALLOW_COPY
ycxiao1
2011/07/19 22:12:48
Done.
| |
| 14 class Profile; | |
| 15 | |
| 16 // This class fetches cookie information on behalf of a caller | |
| 17 // on the UI thread. | |
| 18 class BrowsingDataCookieHelper | |
| 19 : public base::RefCountedThreadSafe<BrowsingDataCookieHelper> { | |
| 20 public: | |
| 21 explicit BrowsingDataCookieHelper(Profile* profile); | |
|
erikwright (departed)
2011/07/18 02:08:30
Add documentation for each of the methods.
ycxiao1
2011/07/19 22:12:48
Done.
| |
| 22 | |
| 23 virtual void StartFetching( | |
| 24 const net::CookieMonster::GetCookieListCallback& callback); | |
|
erikwright (departed)
2011/07/18 02:08:30
Don't re-use the callback type from CookieMonster.
ycxiao1
2011/07/19 22:12:48
Done.
| |
| 25 virtual void CancelNotification(); | |
| 26 virtual void DeleteCookie(const net::CookieMonster::CanonicalCookie& cookie); | |
| 27 | |
| 28 const net::CookieList& cookie_list(); | |
|
erikwright (departed)
2011/07/18 02:08:30
This accessor seems inconsistent with helpers for
ycxiao1
2011/07/19 22:12:48
Done. Moving cookie_list_ to CannedBrowsingDataCoo
| |
| 29 | |
| 30 protected: | |
| 31 friend class base::RefCountedThreadSafe<BrowsingDataCookieHelper>; | |
| 32 virtual ~BrowsingDataCookieHelper(); | |
| 33 | |
| 34 net::CookieList cookie_list_; | |
| 35 bool is_fetching_; | |
|
erikwright (departed)
2011/07/18 02:08:30
is_fetching_ may be private.
ycxiao1
2011/07/19 22:12:48
Done.
| |
| 36 | |
| 37 private: | |
| 38 void OnFetchComplete(const net::CookieList& cookies); | |
| 39 | |
| 40 Profile* profile_; | |
| 41 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | |
| 42 net::CookieMonster::GetCookieListCallback completion_callback_; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(BrowsingDataCookieHelper); | |
| 45 }; | |
| 46 | |
| 47 // This class is a thin wrapper around BrowsingDataCookieHelper that does not | |
| 48 // fetch its information from the persistent cookie store, but gets them passed | |
| 49 // as a parameter during construction. | |
| 50 class CannedBrowsingDataCookieHelper : public BrowsingDataCookieHelper { | |
| 51 public: | |
| 52 explicit CannedBrowsingDataCookieHelper(Profile* profile); | |
| 53 | |
| 54 // Return a copy of the cookie helper. Only one consumer can use the | |
| 55 // StartFetching method at a time, so we need to create a copy of the helper | |
| 56 // everytime we instantiate a cookies tree model for it. | |
| 57 CannedBrowsingDataCookieHelper* Clone(); | |
| 58 | |
| 59 // Add those cookies which are not in the current CookieList. | |
| 60 void AddReadCookie(const GURL& url, | |
| 61 const net::CookieList& cookie_list); | |
| 62 | |
| 63 // Add the cookies which can successfully parsed and no in the current | |
|
erikwright (departed)
2011/07/18 02:08:30
This comment is confusing. I guess it means, "Pars
ycxiao1
2011/07/19 22:12:48
Need more work for the consistent behaviour. One i
| |
| 64 // CookieList. | |
| 65 void AddChangeCookie(const GURL& url, | |
| 66 const std::string& cookie_line, | |
| 67 const net::CookieOptions& options); | |
| 68 | |
| 69 // Clears the list of canned cookies. | |
| 70 void Reset(); | |
| 71 | |
| 72 // True if no cookie are currently stored. | |
| 73 bool empty() const; | |
| 74 | |
| 75 // BrowsingDataCookieHelper methods. | |
| 76 virtual void StartFetching( | |
| 77 const net::CookieMonster::GetCookieListCallback& callback); | |
| 78 virtual void CancelNotification() {} | |
|
erikwright (departed)
2011/07/18 02:08:30
Don't inline virtual methods.
http://www.chromium
ycxiao1
2011/07/19 22:12:48
Done.
| |
| 79 | |
| 80 private: | |
| 81 bool HasCookie(const net::CookieMonster::CanonicalCookie& add_cookie); | |
| 82 virtual ~CannedBrowsingDataCookieHelper(); | |
| 83 | |
| 84 Profile* profile_; | |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataCookieHelper); | |
| 87 }; | |
| 88 | |
| 89 #endif // CHROME_BROWSER_BROWSING_DATA_COOKIE_HELPER_H_ | |
| OLD | NEW |