OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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/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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 bool CookiePolicy::CanSetCookie(const GURL& url, const GURL& policy_url) { | 27 bool CookiePolicy::CanSetCookie(const GURL& url, const GURL& policy_url) { |
28 switch (type_) { | 28 switch (type_) { |
29 case CookiePolicy::ALLOW_ALL_COOKIES: | 29 case CookiePolicy::ALLOW_ALL_COOKIES: |
30 return true; | 30 return true; |
31 case CookiePolicy::BLOCK_THIRD_PARTY_COOKIES: | 31 case CookiePolicy::BLOCK_THIRD_PARTY_COOKIES: |
32 if (policy_url.is_empty()) | 32 if (policy_url.is_empty()) |
33 return true; // Empty policy URL should indicate a first-party request | 33 return true; // Empty policy URL should indicate a first-party request |
34 | 34 return net::RegistryControlledDomainService::SameDomainOrHost(url, |
35 return net::RegistryControlledDomainService::SameDomainOrHost(url, policy_
url); | 35 policy_url); |
36 case CookiePolicy::BLOCK_ALL_COOKIES: | 36 case CookiePolicy::BLOCK_ALL_COOKIES: |
37 return false; | 37 return false; |
38 default: | 38 default: |
39 NOTREACHED(); | 39 NOTREACHED(); |
40 return false; | 40 return false; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 CookiePolicy::CookiePolicy() : type_(CookiePolicy::ALLOW_ALL_COOKIES) { | 44 CookiePolicy::CookiePolicy() : type_(CookiePolicy::ALLOW_ALL_COOKIES) { |
45 } | 45 } |
46 | 46 |
47 } // namespace net | 47 } // namespace net |
48 | 48 |
OLD | NEW |