Chromium Code Reviews| 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 "net/cookies/cookie_constants.h" | |
| 12 #include "url/gurl.h" | 13 #include "url/gurl.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: |
| 19 enum class SameSiteMode { | |
| 20 INCLUDE_STRICT_AND_LAX, | |
| 21 INCLUDE_LAX, | |
| 22 DO_NOT_INCLUDE | |
|
mmenke
2016/03/17 19:15:56
SameSiteMode::DO_NOT_INCLUDE seems weird...Maybe S
Mike West
2016/03/17 19:57:12
I come from Blink. I was born in verbosity. :)
Mike West
2016/03/18 14:27:17
Done.
| |
| 23 }; | |
| 24 | |
| 18 // Creates a CookieOptions object which: | 25 // Creates a CookieOptions object which: |
| 19 // | 26 // |
| 20 // * Excludes HttpOnly cookies | 27 // * Excludes HttpOnly cookies |
| 21 // * Excludes SameSite cookies | 28 // * Excludes SameSite cookies |
| 22 // * Does not enforce prefix restrictions (e.g. "$Secure-*") | 29 // * Does not enforce prefix restrictions (e.g. "$Secure-*") |
| 23 // * Updates last-accessed time. | 30 // * Updates last-accessed time. |
| 24 // | 31 // |
| 25 // These settings can be altered by calling: | 32 // These settings can be altered by calling: |
| 26 // | 33 // |
| 27 // * |set_{include,exclude}_httponly()| | 34 // * |set_{include,exclude}_httponly()| |
| 28 // * |set_include_same_site()| | 35 // * |set_same_site_mode(CookieOptions::SameSiteMode::INCLUDE_STRICT_AND_LAX)| |
| 29 // * |set_enforce_prefixes()| | 36 // * |set_enforce_prefixes()| |
| 30 // * |set_do_not_update_access_time()| | 37 // * |set_do_not_update_access_time()| |
| 31 CookieOptions(); | 38 CookieOptions(); |
| 32 | 39 |
| 33 void set_exclude_httponly() { exclude_httponly_ = true; } | 40 void set_exclude_httponly() { exclude_httponly_ = true; } |
| 34 void set_include_httponly() { exclude_httponly_ = false; } | 41 void set_include_httponly() { exclude_httponly_ = false; } |
| 35 bool exclude_httponly() const { return exclude_httponly_; } | 42 bool exclude_httponly() const { return exclude_httponly_; } |
| 36 | 43 |
| 37 // Default is to exclude 'same_site' cookies. | 44 // Default is to exclude 'same_site' cookies. |
| 38 void set_include_same_site() { include_same_site_ = true; } | 45 void set_same_site_mode(SameSiteMode mode) { same_site_mode_ = mode; } |
| 39 bool include_same_site() const { return include_same_site_; } | 46 SameSiteMode same_site_mode() const { return same_site_mode_; } |
| 40 | 47 |
| 41 // TODO(jww): Remove once we decide whether to ship modifying 'secure' cookies | 48 // TODO(jww): Remove once we decide whether to ship modifying 'secure' cookies |
| 42 // only from secure schemes. https://crbug.com/546820 | 49 // only from secure schemes. https://crbug.com/546820 |
| 43 void set_enforce_strict_secure() { enforce_strict_secure_ = true; } | 50 void set_enforce_strict_secure() { enforce_strict_secure_ = true; } |
| 44 bool enforce_strict_secure() const { return enforce_strict_secure_; } | 51 bool enforce_strict_secure() const { return enforce_strict_secure_; } |
| 45 | 52 |
| 46 // |server_time| indicates what the server sending us the Cookie thought the | 53 // |server_time| indicates what the server sending us the Cookie thought the |
| 47 // current time was when the cookie was produced. This is used to adjust for | 54 // current time was when the cookie was produced. This is used to adjust for |
| 48 // clock skew between server and host. | 55 // clock skew between server and host. |
| 49 void set_server_time(const base::Time& server_time) { | 56 void set_server_time(const base::Time& server_time) { |
| 50 server_time_ = server_time; | 57 server_time_ = server_time; |
| 51 } | 58 } |
| 52 bool has_server_time() const { return !server_time_.is_null(); } | 59 bool has_server_time() const { return !server_time_.is_null(); } |
| 53 base::Time server_time() const { return server_time_; } | 60 base::Time server_time() const { return server_time_; } |
| 54 | 61 |
| 55 void set_do_not_update_access_time() { update_access_time_ = false; } | 62 void set_do_not_update_access_time() { update_access_time_ = false; } |
| 56 bool update_access_time() const { return update_access_time_; } | 63 bool update_access_time() const { return update_access_time_; } |
| 57 | 64 |
| 58 private: | 65 private: |
| 59 bool exclude_httponly_; | 66 bool exclude_httponly_; |
| 60 bool include_same_site_; | 67 SameSiteMode same_site_mode_; |
| 61 bool enforce_strict_secure_; | 68 bool enforce_strict_secure_; |
| 62 bool update_access_time_; | 69 bool update_access_time_; |
| 63 base::Time server_time_; | 70 base::Time server_time_; |
| 64 }; | 71 }; |
| 65 | 72 |
| 66 } // namespace net | 73 } // namespace net |
| 67 | 74 |
| 68 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ | 75 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ |
| OLD | NEW |