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: |
18 // Creates a CookieOptions object which: | 19 // Creates a CookieOptions object which: |
19 // | 20 // |
20 // * Excludes HttpOnly cookies | 21 // * Excludes HttpOnly cookies |
21 // * Excludes SameSite cookies | 22 // * Excludes SameSite cookies |
22 // * Does not enforce prefix restrictions (e.g. "$Secure-*") | 23 // * Does not enforce prefix restrictions (e.g. "$Secure-*") |
23 // * Updates last-accessed time. | 24 // * Updates last-accessed time. |
24 // | 25 // |
25 // These settings can be altered by calling: | 26 // These settings can be altered by calling: |
26 // | 27 // |
27 // * |set_{include,exclude}_httponly()| | 28 // * |set_{include,exclude}_httponly()| |
28 // * |set_include_same_site()| | 29 // * |set_include_same_site(CookieSameSite::STRICT_MODE)| |
29 // * |set_enforce_prefixes()| | 30 // * |set_enforce_prefixes()| |
30 // * |set_do_not_update_access_time()| | 31 // * |set_do_not_update_access_time()| |
31 CookieOptions(); | 32 CookieOptions(); |
32 | 33 |
33 void set_exclude_httponly() { exclude_httponly_ = true; } | 34 void set_exclude_httponly() { exclude_httponly_ = true; } |
34 void set_include_httponly() { exclude_httponly_ = false; } | 35 void set_include_httponly() { exclude_httponly_ = false; } |
35 bool exclude_httponly() const { return exclude_httponly_; } | 36 bool exclude_httponly() const { return exclude_httponly_; } |
36 | 37 |
37 // Default is to exclude 'same_site' cookies. | 38 // Default is to exclude 'same_site' cookies. |
38 void set_include_same_site() { include_same_site_ = true; } | 39 void set_include_same_site(CookieSameSite type) { include_same_site_ = type; } |
39 bool include_same_site() const { return include_same_site_; } | 40 CookieSameSite include_same_site() const { return include_same_site_; } |
Mike West
2016/03/14 15:24:10
TODO(me): Rename this to something like `set_which
| |
40 | 41 |
41 // TODO(jww): Remove once we decide whether to ship modifying 'secure' cookies | 42 // TODO(jww): Remove once we decide whether to ship modifying 'secure' cookies |
42 // only from secure schemes. https://crbug.com/546820 | 43 // only from secure schemes. https://crbug.com/546820 |
43 void set_enforce_strict_secure() { enforce_strict_secure_ = true; } | 44 void set_enforce_strict_secure() { enforce_strict_secure_ = true; } |
44 bool enforce_strict_secure() const { return enforce_strict_secure_; } | 45 bool enforce_strict_secure() const { return enforce_strict_secure_; } |
45 | 46 |
46 // |server_time| indicates what the server sending us the Cookie thought the | 47 // |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 | 48 // current time was when the cookie was produced. This is used to adjust for |
48 // clock skew between server and host. | 49 // clock skew between server and host. |
49 void set_server_time(const base::Time& server_time) { | 50 void set_server_time(const base::Time& server_time) { |
50 server_time_ = server_time; | 51 server_time_ = server_time; |
51 } | 52 } |
52 bool has_server_time() const { return !server_time_.is_null(); } | 53 bool has_server_time() const { return !server_time_.is_null(); } |
53 base::Time server_time() const { return server_time_; } | 54 base::Time server_time() const { return server_time_; } |
54 | 55 |
55 void set_do_not_update_access_time() { update_access_time_ = false; } | 56 void set_do_not_update_access_time() { update_access_time_ = false; } |
56 bool update_access_time() const { return update_access_time_; } | 57 bool update_access_time() const { return update_access_time_; } |
57 | 58 |
58 private: | 59 private: |
59 bool exclude_httponly_; | 60 bool exclude_httponly_; |
60 bool include_same_site_; | 61 CookieSameSite include_same_site_; |
61 bool enforce_strict_secure_; | 62 bool enforce_strict_secure_; |
62 bool update_access_time_; | 63 bool update_access_time_; |
63 base::Time server_time_; | 64 base::Time server_time_; |
64 }; | 65 }; |
65 | 66 |
66 } // namespace net | 67 } // namespace net |
67 | 68 |
68 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ | 69 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ |
OLD | NEW |