OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/base/cookie_policy.h" | 5 #include "net/base/static_cookie_policy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "net/base/registry_controlled_domain.h" | 9 #include "net/base/registry_controlled_domain.h" |
10 | 10 |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 bool CookiePolicy::CanGetCookies(const GURL& url, | 13 bool StaticCookiePolicy::CanGetCookies(const GURL& url, |
14 const GURL& first_party_for_cookies) { | 14 const GURL& first_party_for_cookies) { |
15 switch (type_) { | 15 switch (type_) { |
16 case CookiePolicy::ALLOW_ALL_COOKIES: | 16 case StaticCookiePolicy::ALLOW_ALL_COOKIES: |
17 return true; | 17 return true; |
18 case CookiePolicy::BLOCK_THIRD_PARTY_COOKIES: | 18 case StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES: |
19 return true; | 19 return true; |
20 case CookiePolicy::BLOCK_ALL_COOKIES: | 20 case StaticCookiePolicy::BLOCK_ALL_COOKIES: |
21 return false; | 21 return false; |
22 default: | 22 default: |
23 NOTREACHED(); | 23 NOTREACHED(); |
24 return false; | 24 return false; |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 bool CookiePolicy::CanSetCookie(const GURL& url, | 28 bool StaticCookiePolicy::CanSetCookie(const GURL& url, |
29 const GURL& first_party_for_cookies) { | 29 const GURL& first_party_for_cookies) { |
30 switch (type_) { | 30 switch (type_) { |
31 case CookiePolicy::ALLOW_ALL_COOKIES: | 31 case StaticCookiePolicy::ALLOW_ALL_COOKIES: |
32 return true; | 32 return true; |
33 case CookiePolicy::BLOCK_THIRD_PARTY_COOKIES: | 33 case StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES: |
34 if (first_party_for_cookies.is_empty()) | 34 if (first_party_for_cookies.is_empty()) |
35 return true; // Empty first-party URL indicates a first-party request. | 35 return true; // Empty first-party URL indicates a first-party request. |
36 return net::RegistryControlledDomainService::SameDomainOrHost( | 36 return net::RegistryControlledDomainService::SameDomainOrHost( |
37 url, first_party_for_cookies); | 37 url, first_party_for_cookies); |
38 case CookiePolicy::BLOCK_ALL_COOKIES: | 38 case StaticCookiePolicy::BLOCK_ALL_COOKIES: |
39 return false; | 39 return false; |
40 default: | 40 default: |
41 NOTREACHED(); | 41 NOTREACHED(); |
42 return false; | 42 return false; |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 CookiePolicy::CookiePolicy() : type_(CookiePolicy::ALLOW_ALL_COOKIES) { | |
47 } | |
48 | |
49 } // namespace net | 46 } // namespace net |
OLD | NEW |