| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_BASE_STATIC_COOKIE_POLICY_H_ | 5 #ifndef NET_BASE_STATIC_COOKIE_POLICY_H_ |
| 6 #define NET_BASE_STATIC_COOKIE_POLICY_H_ | 6 #define NET_BASE_STATIC_COOKIE_POLICY_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" |
| 10 | 10 |
| 11 class GURL; | 11 class GURL; |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 // The StaticCookiePolicy class implements a static cookie policy that supports | 15 // The StaticCookiePolicy class implements a static cookie policy that supports |
| 16 // three modes: allow all, deny all, or block third-party cookies. | 16 // three modes: allow all, deny all, or block third-party cookies. |
| 17 class NET_EXPORT StaticCookiePolicy { | 17 class NET_EXPORT StaticCookiePolicy { |
| 18 public: | 18 public: |
| 19 // Do not change the order of these types as they are persisted in | 19 // Do not change the order of these types as they are persisted in |
| 20 // preferences. | 20 // preferences. |
| 21 enum Type { | 21 enum Type { |
| 22 // Do not perform any cookie blocking. | 22 // Do not perform any cookie blocking. |
| 23 ALLOW_ALL_COOKIES = 0, | 23 ALLOW_ALL_COOKIES = 0, |
| 24 // Block all cookies (third-party or not) from begin set or read. | 24 // Block all cookies (third-party or not) from begin set or read. |
| 25 BLOCK_ALL_COOKIES, | 25 BLOCK_ALL_COOKIES, |
| 26 // Prevent only third-party cookies from being set or read. | 26 // Prevent only third-party cookies from being set or read. |
| 27 BLOCK_ALL_THIRD_PARTY_COOKIES | 27 BLOCK_ALL_THIRD_PARTY_COOKIES |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 StaticCookiePolicy() | 30 StaticCookiePolicy() : type_(StaticCookiePolicy::ALLOW_ALL_COOKIES) {} |
| 31 : type_(StaticCookiePolicy::ALLOW_ALL_COOKIES) { | |
| 32 } | |
| 33 | 31 |
| 34 explicit StaticCookiePolicy(Type type) | 32 explicit StaticCookiePolicy(Type type) : type_(type) {} |
| 35 : type_(type) { | |
| 36 } | |
| 37 | 33 |
| 38 // Sets the current policy to enforce. This should be called when the user's | 34 // Sets the current policy to enforce. This should be called when the user's |
| 39 // preferences change. | 35 // preferences change. |
| 40 void set_type(Type type) { type_ = type; } | 36 void set_type(Type type) { type_ = type; } |
| 41 Type type() const { return type_; } | 37 Type type() const { return type_; } |
| 42 | 38 |
| 43 // Consults the user's third-party cookie blocking preferences to determine | 39 // Consults the user's third-party cookie blocking preferences to determine |
| 44 // whether the URL's cookies can be read. | 40 // whether the URL's cookies can be read. |
| 45 int CanGetCookies(const GURL& url, const GURL& first_party_for_cookies) const; | 41 int CanGetCookies(const GURL& url, const GURL& first_party_for_cookies) const; |
| 46 | 42 |
| 47 // Consults the user's third-party cookie blocking preferences to determine | 43 // Consults the user's third-party cookie blocking preferences to determine |
| 48 // whether the URL's cookies can be set. | 44 // whether the URL's cookies can be set. |
| 49 int CanSetCookie(const GURL& url, | 45 int CanSetCookie(const GURL& url, const GURL& first_party_for_cookies) const; |
| 50 const GURL& first_party_for_cookies) const; | |
| 51 | 46 |
| 52 private: | 47 private: |
| 53 Type type_; | 48 Type type_; |
| 54 | 49 |
| 55 DISALLOW_COPY_AND_ASSIGN(StaticCookiePolicy); | 50 DISALLOW_COPY_AND_ASSIGN(StaticCookiePolicy); |
| 56 }; | 51 }; |
| 57 | 52 |
| 58 } // namespace net | 53 } // namespace net |
| 59 | 54 |
| 60 #endif // NET_BASE_STATIC_COOKIE_POLICY_H_ | 55 #endif // NET_BASE_STATIC_COOKIE_POLICY_H_ |
| OLD | NEW |