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
67
|
// Copyright (c) 2006-2009 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_BASE_COOKIE_STORE_H_
#define NET_BASE_COOKIE_STORE_H_
#include <string>
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "base/time.h"
#include "net/base/cookie_options.h"
class GURL;
namespace net {
class CookieMonster;
// An interface for storing and retrieving cookies. Implementations need to
// be thread safe as its methods can be accessed from IO as well as UI threads.
class CookieStore : public base::RefCountedThreadSafe<CookieStore> {
public:
virtual ~CookieStore() {}
// Set a single cookie. Expects a cookie line, like "a=1; domain=b.com".
virtual bool SetCookie(const GURL& url, const std::string& cookie_line) = 0;
virtual bool SetCookieWithOptions(const GURL& url,
const std::string& cookie_line,
const CookieOptions& options) = 0;
// Sets a single cookie with a specific creation date. To set a cookie with
// a creation date of Now() use SetCookie() instead (it calls this function
// internally).
virtual bool SetCookieWithCreationTime(const GURL& url,
const std::string& cookie_line,
const base::Time& creation_time) = 0;
virtual bool SetCookieWithCreationTimeWithOptions(
const GURL& url,
const std::string& cookie_line,
const base::Time& creation_time,
const CookieOptions& options) = 0;
// Set a vector of response cookie values for the same URL.
virtual void SetCookies(const GURL& url,
const std::vector<std::string>& cookies) = 0;
virtual void SetCookiesWithOptions(const GURL& url,
const std::vector<std::string>& cookies,
const CookieOptions& options) = 0;
// TODO what if the total size of all the cookies >4k, can we have a header
// that big or do we need multiple Cookie: headers?
// Simple interface, get a cookie string "a=b; c=d" for the given URL.
// It will _not_ return httponly cookies, see CookieOptions.
virtual std::string GetCookies(const GURL& url) = 0;
virtual std::string GetCookiesWithOptions(const GURL& url,
const CookieOptions& options) = 0;
virtual CookieMonster* GetCookieMonster() {
return NULL;
};
};
} // namespace net
#endif // NET_BASE_COOKIE_STORE_H_
|