| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 number 42. | 5 // Brought to you by number 42. | 
| 6 | 6 | 
| 7 #ifndef NET_BASE_COOKIE_STORE_H_ | 7 #ifndef NET_BASE_COOKIE_STORE_H_ | 
| 8 #define NET_BASE_COOKIE_STORE_H_ | 8 #define NET_BASE_COOKIE_STORE_H_ | 
| 9 #pragma once | 9 #pragma once | 
| 10 | 10 | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 40     // TODO(abarth): Add value if any clients need it. | 40     // TODO(abarth): Add value if any clients need it. | 
| 41 | 41 | 
| 42     // The time at which the cookie was created. | 42     // The time at which the cookie was created. | 
| 43     base::Time creation_date; | 43     base::Time creation_date; | 
| 44 | 44 | 
| 45     // The value of the MAC-Key and MAC-Algorithm attributes, if present. | 45     // The value of the MAC-Key and MAC-Algorithm attributes, if present. | 
| 46     std::string mac_key; | 46     std::string mac_key; | 
| 47     std::string mac_algorithm; | 47     std::string mac_algorithm; | 
| 48   }; | 48   }; | 
| 49 | 49 | 
|  | 50   // Callback definitions. | 
|  | 51   typedef base::Callback <void( | 
|  | 52       const std::string& cookie_line, | 
|  | 53       const std::vector<CookieInfo>& cookie_infos)> GetCookieInfoCallback; | 
|  | 54   typedef base::Callback<void(const std::string& cookie)> | 
|  | 55       GetCookiesCallback; | 
|  | 56   typedef base::Callback<void(bool)> SetCookiesCallback; | 
|  | 57 | 
|  | 58 | 
| 50   // Sets a single cookie.  Expects a cookie line, like "a=1; domain=b.com". | 59   // Sets a single cookie.  Expects a cookie line, like "a=1; domain=b.com". | 
| 51   // | 60   // | 
| 52   // Fails either if the cookie is invalid or if this is a non-HTTPONLY cookie | 61   // Fails either if the cookie is invalid or if this is a non-HTTPONLY cookie | 
| 53   // and it would overwrite an existing HTTPONLY cookie. | 62   // and it would overwrite an existing HTTPONLY cookie. | 
| 54   // Returns true if the cookie is successfully set. | 63   // Returns true if the cookie is successfully set. | 
| 55   virtual bool SetCookieWithOptions(const GURL& url, |  | 
| 56                                     const std::string& cookie_line, |  | 
| 57                                     const CookieOptions& options) = 0; |  | 
| 58 |  | 
| 59   typedef base::Callback<void(bool)> SetCookiesCallback; |  | 
| 60 |  | 
| 61   virtual void SetCookieWithOptionsAsync( | 64   virtual void SetCookieWithOptionsAsync( | 
| 62       const GURL& url, | 65       const GURL& url, | 
| 63       const std::string& cookie_line, | 66       const std::string& cookie_line, | 
| 64       const CookieOptions& options, | 67       const CookieOptions& options, | 
| 65       const SetCookiesCallback& callback) = 0; | 68       const SetCookiesCallback& callback) = 0; | 
| 66 | 69 | 
| 67   // TODO(???): what if the total size of all the cookies >4k, can we have a | 70   // TODO(???): what if the total size of all the cookies >4k, can we have a | 
| 68   // header that big or do we need multiple Cookie: headers? | 71   // header that big or do we need multiple Cookie: headers? | 
| 69   // Note: Some sites, such as Facebook, occationally use Cookie headers >4k. | 72   // Note: Some sites, such as Facebook, occationally use Cookie headers >4k. | 
| 70   // | 73   // | 
| 71   // Simple interface, gets a cookie string "a=b; c=d" for the given URL. | 74   // Simple interface, gets a cookie string "a=b; c=d" for the given URL. | 
| 72   // Use options to access httponly cookies. | 75   // Use options to access httponly cookies. | 
| 73   virtual std::string GetCookiesWithOptions(const GURL& url, |  | 
| 74                                             const CookieOptions& options) = 0; |  | 
| 75 |  | 
| 76   typedef base::Callback<void(const std::string& cookie)> |  | 
| 77       GetCookiesCallback; |  | 
| 78 |  | 
| 79   virtual void GetCookiesWithOptionsAsync( | 76   virtual void GetCookiesWithOptionsAsync( | 
| 80       const GURL& url, const CookieOptions& options, | 77       const GURL& url, const CookieOptions& options, | 
| 81       const GetCookiesCallback& callback) = 0; | 78       const GetCookiesCallback& callback) = 0; | 
| 82 | 79 | 
| 83   // This function is similar to GetCookiesWithOptions same functionality as | 80   // This function is similar to GetCookiesWithOptions same functionality as | 
| 84   // GetCookiesWithOptions except that it additionaly provides detailed | 81   // GetCookiesWithOptions except that it additionaly provides detailed | 
| 85   // information about the cookie contained in the cookie line.  See |struct | 82   // information about the cookie contained in the cookie line.  See |struct | 
| 86   // CookieInfo| above for details. | 83   // CookieInfo| above for details. | 
| 87   virtual void GetCookiesWithInfo(const GURL& url, |  | 
| 88                                   const CookieOptions& options, |  | 
| 89                                   std::string* cookie_line, |  | 
| 90                                   std::vector<CookieInfo>* cookie_info) = 0; |  | 
| 91 |  | 
| 92   // Using for complete the asyn interface |  | 
| 93   typedef base::Callback <void( |  | 
| 94       std::string* cookie_line, |  | 
| 95       std::vector<CookieInfo>* cookie_infos)> GetCookieInfoCallback; |  | 
| 96 |  | 
| 97   virtual void GetCookiesWithInfoAsync( | 84   virtual void GetCookiesWithInfoAsync( | 
| 98       const GURL& url, | 85       const GURL& url, | 
| 99       const CookieOptions& options, | 86       const CookieOptions& options, | 
| 100       const GetCookieInfoCallback& callback) = 0; | 87       const GetCookieInfoCallback& callback) = 0; | 
| 101 | 88 | 
| 102   // Deletes the passed in cookie for the specified URL. | 89   // Deletes the passed in cookie for the specified URL. | 
| 103   virtual void DeleteCookie(const GURL& url, |  | 
| 104                             const std::string& cookie_name) = 0; |  | 
| 105   virtual void DeleteCookieAsync(const GURL& url, | 90   virtual void DeleteCookieAsync(const GURL& url, | 
| 106                                  const std::string& cookie_name, | 91                                  const std::string& cookie_name, | 
| 107                                  const base::Closure& callback) = 0; | 92                                  const base::Closure& callback) = 0; | 
| 108 | 93 | 
| 109   // Returns the underlying CookieMonster. | 94   // Returns the underlying CookieMonster. | 
| 110   virtual CookieMonster* GetCookieMonster() = 0; | 95   virtual CookieMonster* GetCookieMonster() = 0; | 
| 111 | 96 | 
| 112 |  | 
| 113   // -------------------------------------------------------------------------- |  | 
| 114   // Helpers to make the above interface simpler for some cases. |  | 
| 115 |  | 
| 116   // Sets a cookie for the given URL using default options. |  | 
| 117   bool SetCookie(const GURL& url, const std::string& cookie_line); |  | 
| 118 |  | 
| 119   // Gets cookies for the given URL using default options. |  | 
| 120   std::string GetCookies(const GURL& url); |  | 
| 121   void GetCookiesAsync(const GURL& url, |  | 
| 122                        const GetCookiesCallback& callback); |  | 
| 123 |  | 
| 124   // Sets a vector of response cookie values for the same URL. |  | 
| 125   void SetCookiesWithOptions(const GURL& url, |  | 
| 126                              const std::vector<std::string>& cookie_lines, |  | 
| 127                              const CookieOptions& options); |  | 
| 128   void SetCookies(const GURL& url, |  | 
| 129                   const std::vector<std::string>& cookie_lines); |  | 
| 130 |  | 
| 131  protected: | 97  protected: | 
| 132   friend class base::RefCountedThreadSafe<CookieStore>; | 98   friend class base::RefCountedThreadSafe<CookieStore>; | 
| 133   CookieStore(); | 99   CookieStore(); | 
| 134   virtual ~CookieStore(); | 100   virtual ~CookieStore(); | 
| 135 }; | 101 }; | 
| 136 | 102 | 
| 137 }  // namespace net | 103 }  // namespace net | 
| 138 | 104 | 
| 139 #endif  // NET_BASE_COOKIE_STORE_H_ | 105 #endif  // NET_BASE_COOKIE_STORE_H_ | 
| OLD | NEW | 
|---|