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_url(const GURL& url) { first_party_url_ = url; } |
36 GURL first_party_url() const { return first_party_url_; } | 37 GURL first_party_url() const { return first_party_url_; } |
37 | 38 |
| 39 void set_requestor_origin(const url::Origin& requestor_origin) { |
| 40 requestor_origin_ = requestor_origin; |
| 41 } |
| 42 const url::Origin& requestor_origin() const { return requestor_origin_; } |
| 43 |
38 // |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 |
39 // 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 |
40 // clock skew between server and host. | 46 // clock skew between server and host. |
41 void set_server_time(const base::Time& server_time) { | 47 void set_server_time(const base::Time& server_time) { |
42 server_time_ = server_time; | 48 server_time_ = server_time; |
43 } | 49 } |
44 bool has_server_time() const { return !server_time_.is_null(); } | 50 bool has_server_time() const { return !server_time_.is_null(); } |
45 base::Time server_time() const { return server_time_; } | 51 base::Time server_time() const { return server_time_; } |
46 | 52 |
47 private: | 53 private: |
48 bool exclude_httponly_; | 54 bool exclude_httponly_; |
49 bool include_first_party_only_; | 55 bool include_first_party_only_; |
50 GURL first_party_url_; | 56 GURL first_party_url_; |
| 57 url::Origin requestor_origin_; |
51 base::Time server_time_; | 58 base::Time server_time_; |
52 }; | 59 }; |
53 | 60 |
54 } // namespace net | 61 } // namespace net |
55 | 62 |
56 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ | 63 #endif // NET_COOKIES_COOKIE_OPTIONS_H_ |
OLD | NEW |