| 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 number 42. | 5 // Brought to you by number 42. |
| 6 | 6 |
| 7 #ifndef NET_COOKIES_COOKIE_OPTIONS_H_ | 7 #ifndef NET_COOKIES_COOKIE_OPTIONS_H_ |
| 8 #define NET_COOKIES_COOKIE_OPTIONS_H_ | 8 #define NET_COOKIES_COOKIE_OPTIONS_H_ |
| 9 | 9 |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 #include "url/origin.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 class NET_EXPORT CookieOptions { | 17 class NET_EXPORT CookieOptions { |
| 17 public: | 18 public: |
| 18 // Default is to exclude httponly completely, and exclude first-party from | 19 // Default is to exclude httponly completely, and exclude first-party from |
| 19 // being read, which means: | 20 // being read, which means: |
| 20 // - reading operations will not return httponly or first-party cookies. | 21 // - reading operations will not return httponly or first-party cookies. |
| 21 // - writing operations will not write httponly cookies (first-party will be | 22 // - writing operations will not write httponly cookies (first-party will be |
| 22 // written). | 23 // written). |
| 23 // | 24 // |
| 24 // If a first-party URL is set, then first-party cookies which match that URL | 25 // If a first-party URL is set, then first-party cookies which match that URL |
| 25 // will be returned. | 26 // will be returned. |
| 26 CookieOptions(); | 27 CookieOptions(); |
| 27 | 28 |
| 28 void set_exclude_httponly() { exclude_httponly_ = true; } | 29 void set_exclude_httponly() { exclude_httponly_ = true; } |
| 29 void set_include_httponly() { exclude_httponly_ = false; } | 30 void set_include_httponly() { exclude_httponly_ = false; } |
| 30 bool exclude_httponly() const { return exclude_httponly_; } | 31 bool exclude_httponly() const { return exclude_httponly_; } |
| 31 | 32 |
| 32 void set_include_first_party_only() { include_first_party_only_ = true; } | 33 void set_include_first_party_only() { include_first_party_only_ = true; } |
| 33 bool include_first_party_only() const { return include_first_party_only_; } | 34 bool include_first_party_only() const { return include_first_party_only_; } |
| 34 | 35 |
| 35 void set_first_party_url(const GURL& url) { first_party_url_ = url; } | 36 void set_first_party(const url::Origin& origin) { first_party_ = origin; } |
| 36 GURL first_party_url() const { return first_party_url_; } | 37 const url::Origin& first_party() const { return first_party_; } |
| 37 | 38 |
| 38 // TODO(estark): Remove once we decide whether to ship cookie | 39 // TODO(estark): Remove once we decide whether to ship cookie |
| 39 // prefixes. https://crbug.com/541511 | 40 // prefixes. https://crbug.com/541511 |
| 40 void set_enforce_prefixes() { enforce_prefixes_ = true; } | 41 void set_enforce_prefixes() { enforce_prefixes_ = true; } |
| 41 bool enforce_prefixes() const { return enforce_prefixes_; } | 42 bool enforce_prefixes() const { return enforce_prefixes_; } |
| 42 | 43 |
| 43 // |server_time| indicates what the server sending us the Cookie thought the | 44 // |server_time| indicates what the server sending us the Cookie thought the |
| 44 // current time was when the cookie was produced. This is used to adjust for | 45 // current time was when the cookie was produced. This is used to adjust for |
| 45 // clock skew between server and host. | 46 // clock skew between server and host. |
| 46 void set_server_time(const base::Time& server_time) { | 47 void set_server_time(const base::Time& server_time) { |
| 47 server_time_ = server_time; | 48 server_time_ = server_time; |
| 48 } | 49 } |
| 49 bool has_server_time() const { return !server_time_.is_null(); } | 50 bool has_server_time() const { return !server_time_.is_null(); } |
| 50 base::Time server_time() const { return server_time_; } | 51 base::Time server_time() const { return server_time_; } |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 bool exclude_httponly_; | 54 bool exclude_httponly_; |
| 54 bool include_first_party_only_; | 55 bool include_first_party_only_; |
| 55 GURL first_party_url_; | 56 url::Origin first_party_; |
| 56 bool enforce_prefixes_; | 57 bool enforce_prefixes_; |
| 57 base::Time server_time_; | 58 base::Time server_time_; |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 } // namespace net | 61 } // namespace net |
| 61 | 62 |
| 62 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ | 63 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ |
| OLD | NEW |