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 "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 #include "url/origin.h" | 13 #include "url/origin.h" |
|
mmenke
2016/01/12 16:20:58
No longer needed.
Mike West
2016/01/13 08:10:22
Done.
| |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 class NET_EXPORT CookieOptions { | 17 class NET_EXPORT CookieOptions { |
| 18 public: | 18 public: |
| 19 // Default is to exclude httponly completely, and exclude first-party from | 19 // Creates a CookieOptions object which: |
| 20 // being read, which means: | |
| 21 // - reading operations will not return httponly or first-party cookies. | |
| 22 // - writing operations will not write httponly cookies (first-party will be | |
| 23 // written). | |
| 24 // | 20 // |
| 25 // If a first-party URL is set, then first-party cookies which match that URL | 21 // * Excludes HttpOnly cookies |
| 26 // will be returned. | 22 // * Excludes First-Party-Only cookies |
| 23 // * Does not enforce prefix restrictions (e.g. "$Secure-*") | |
| 24 // | |
| 25 // These settings can be altered by calling: | |
| 26 // | |
| 27 // * |set_{include,exclude}_httponly()| | |
| 28 // * |set_include_first_party_only_cookies()| | |
| 29 // * |set_enforce_prefixes()| | |
| 27 CookieOptions(); | 30 CookieOptions(); |
| 28 | 31 |
| 29 void set_exclude_httponly() { exclude_httponly_ = true; } | 32 void set_exclude_httponly() { exclude_httponly_ = true; } |
| 30 void set_include_httponly() { exclude_httponly_ = false; } | 33 void set_include_httponly() { exclude_httponly_ = false; } |
| 31 bool exclude_httponly() const { return exclude_httponly_; } | 34 bool exclude_httponly() const { return exclude_httponly_; } |
| 32 | 35 |
| 33 void set_include_first_party_only() { include_first_party_only_ = true; } | 36 // Default is to exclude 'first-party-only' cookies. |
| 34 bool include_first_party_only() const { return include_first_party_only_; } | 37 void set_include_first_party_only_cookies() { |
| 35 | 38 include_first_party_only_cookies_ = true; |
| 36 void set_first_party(const url::Origin& origin) { first_party_ = origin; } | 39 } |
| 37 const url::Origin& first_party() const { return first_party_; } | 40 bool include_first_party_only_cookies() const { |
| 41 return include_first_party_only_cookies_; | |
| 42 } | |
| 38 | 43 |
| 39 // TODO(jww): Remove once we decide whether to ship modifying 'secure' cookies | 44 // TODO(jww): Remove once we decide whether to ship modifying 'secure' cookies |
| 40 // only from secure schemes. https://crbug.com/546820 | 45 // only from secure schemes. https://crbug.com/546820 |
| 41 void set_enforce_strict_secure() { enforce_strict_secure_ = true; } | 46 void set_enforce_strict_secure() { enforce_strict_secure_ = true; } |
| 42 bool enforce_strict_secure() const { return enforce_strict_secure_; } | 47 bool enforce_strict_secure() const { return enforce_strict_secure_; } |
| 43 | 48 |
| 44 // |server_time| indicates what the server sending us the Cookie thought the | 49 // |server_time| indicates what the server sending us the Cookie thought the |
| 45 // current time was when the cookie was produced. This is used to adjust for | 50 // current time was when the cookie was produced. This is used to adjust for |
| 46 // clock skew between server and host. | 51 // clock skew between server and host. |
| 47 void set_server_time(const base::Time& server_time) { | 52 void set_server_time(const base::Time& server_time) { |
| 48 server_time_ = server_time; | 53 server_time_ = server_time; |
| 49 } | 54 } |
| 50 bool has_server_time() const { return !server_time_.is_null(); } | 55 bool has_server_time() const { return !server_time_.is_null(); } |
| 51 base::Time server_time() const { return server_time_; } | 56 base::Time server_time() const { return server_time_; } |
| 52 | 57 |
| 53 private: | 58 private: |
| 54 bool exclude_httponly_; | 59 bool exclude_httponly_; |
| 55 bool include_first_party_only_; | 60 bool include_first_party_only_cookies_; |
| 61 bool enforce_strict_secure_; | |
| 56 url::Origin first_party_; | 62 url::Origin first_party_; |
|
mmenke
2016/01/12 16:20:58
No longer used.
Mike West
2016/01/13 08:10:22
Thanks!
| |
| 57 bool enforce_strict_secure_; | |
| 58 base::Time server_time_; | 63 base::Time server_time_; |
| 59 }; | 64 }; |
| 60 | 65 |
| 61 } // namespace net | 66 } // namespace net |
| 62 | 67 |
| 63 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ | 68 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ |
| OLD | NEW |