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