summaryrefslogtreecommitdiff
path: root/chromium/net/cookies/cookie_options.h
blob: 4d2a774c1bcc723c46d9906cfc2c0b068b44f0f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Brought to you by number 42.

#ifndef NET_COOKIES_COOKIE_OPTIONS_H_
#define NET_COOKIES_COOKIE_OPTIONS_H_

#include "base/time/time.h"
#include "net/base/net_export.h"
#include "url/gurl.h"

namespace net {

class NET_EXPORT CookieOptions {
 public:
  // Creates a CookieOptions object which:
  //
  // * Excludes HttpOnly cookies
  // * Excludes First-Party-Only cookies
  // * Does not enforce prefix restrictions (e.g. "$Secure-*")
  //
  // These settings can be altered by calling:
  //
  // * |set_{include,exclude}_httponly()|
  // * |set_include_first_party_only_cookies()|
  // * |set_enforce_prefixes()|
  CookieOptions();

  void set_exclude_httponly() { exclude_httponly_ = true; }
  void set_include_httponly() { exclude_httponly_ = false; }
  bool exclude_httponly() const { return exclude_httponly_; }

  // Default is to exclude 'first-party-only' cookies.
  void set_include_first_party_only_cookies() {
    include_first_party_only_cookies_ = true;
  }
  bool include_first_party_only_cookies() const {
    return include_first_party_only_cookies_;
  }

  // TODO(jww): Remove once we decide whether to ship modifying 'secure' cookies
  // only from secure schemes. https://crbug.com/546820
  void set_enforce_strict_secure() { enforce_strict_secure_ = true; }
  bool enforce_strict_secure() const { return enforce_strict_secure_; }

  // |server_time| indicates what the server sending us the Cookie thought the
  // current time was when the cookie was produced.  This is used to adjust for
  // clock skew between server and host.
  void set_server_time(const base::Time& server_time) {
    server_time_ = server_time;
  }
  bool has_server_time() const { return !server_time_.is_null(); }
  base::Time server_time() const { return server_time_; }

 private:
  bool exclude_httponly_;
  bool include_first_party_only_cookies_;
  bool enforce_strict_secure_;
  base::Time server_time_;
};

}  // namespace net

#endif  // NET_COOKIES_COOKIE_OPTIONS_H_