summaryrefslogtreecommitdiffstats
path: root/net/base/static_cookie_policy.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/static_cookie_policy.h')
-rw-r--r--net/base/static_cookie_policy.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/net/base/static_cookie_policy.h b/net/base/static_cookie_policy.h
new file mode 100644
index 0000000..a16fd0c
--- /dev/null
+++ b/net/base/static_cookie_policy.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2010 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.
+
+#ifndef NET_BASE_STATIC_COOKIE_POLICY_H_
+#define NET_BASE_STATIC_COOKIE_POLICY_H_
+
+#include "base/basictypes.h"
+#include "net/base/cookie_policy.h"
+
+class GURL;
+
+namespace net {
+
+// The StaticCookiePolicy class implements a static cookie policy that supports
+// three modes: allow all, deny all, or block third-party cookies.
+class StaticCookiePolicy : public CookiePolicy {
+ public:
+ // Consult the user's third-party cookie blocking preferences to determine
+ // whether the URL's cookies can be read.
+ bool CanGetCookies(const GURL& url, const GURL& first_party_for_cookies);
+
+ // Consult the user's third-party cookie blocking preferences to determine
+ // whether the URL's cookies can be set.
+ bool CanSetCookie(const GURL& url, const GURL& first_party_for_cookies);
+
+ enum Type {
+ ALLOW_ALL_COOKIES = 0, // Do not perform any cookie blocking.
+ BLOCK_THIRD_PARTY_COOKIES, // Prevent third-party cookies from being set.
+ BLOCK_ALL_COOKIES // Disable cookies.
+ };
+
+ // Sets the current policy to enforce. This should be called when the user's
+ // preferences change.
+ void set_type(Type type) { type_ = type; }
+
+ Type type() const {
+ return type_;
+ }
+
+ StaticCookiePolicy()
+ : type_(StaticCookiePolicy::ALLOW_ALL_COOKIES) {
+ }
+
+ explicit StaticCookiePolicy(Type type)
+ : type_(type) {
+ }
+
+ private:
+ Type type_;
+
+ DISALLOW_COPY_AND_ASSIGN(StaticCookiePolicy);
+};
+
+} // namespace net
+
+#endif // NET_BASE_STATIC_COOKIE_POLICY_H_