OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/base/cookie_policy.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "googleurl/src/gurl.h" | |
9 #include "net/base/registry_controlled_domain.h" | |
10 | |
11 namespace net { | |
12 | |
13 bool CookiePolicy::CanGetCookies(const GURL& url, | |
14 const GURL& first_party_for_cookies) { | |
15 switch (type_) { | |
16 case CookiePolicy::ALLOW_ALL_COOKIES: | |
17 return true; | |
18 case CookiePolicy::BLOCK_THIRD_PARTY_COOKIES: | |
19 return true; | |
20 case CookiePolicy::BLOCK_ALL_COOKIES: | |
21 return false; | |
22 default: | |
23 NOTREACHED(); | |
24 return false; | |
25 } | |
26 } | |
27 | |
28 bool CookiePolicy::CanSetCookie(const GURL& url, | |
29 const GURL& first_party_for_cookies) { | |
30 switch (type_) { | |
31 case CookiePolicy::ALLOW_ALL_COOKIES: | |
32 return true; | |
33 case CookiePolicy::BLOCK_THIRD_PARTY_COOKIES: | |
34 if (first_party_for_cookies.is_empty()) | |
35 return true; // Empty first-party URL indicates a first-party request. | |
36 return net::RegistryControlledDomainService::SameDomainOrHost( | |
37 url, first_party_for_cookies); | |
38 case CookiePolicy::BLOCK_ALL_COOKIES: | |
39 return false; | |
40 default: | |
41 NOTREACHED(); | |
42 return false; | |
43 } | |
44 } | |
45 | |
46 CookiePolicy::CookiePolicy() : type_(CookiePolicy::ALLOW_ALL_COOKIES) { | |
47 } | |
48 | |
49 } // namespace net | |
OLD | NEW |