| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/static_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/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 10 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 int StaticCookiePolicy::CanGetCookies( | 14 int StaticCookiePolicy::CanGetCookies( |
| 15 const GURL& url, | 15 const GURL& url, |
| 16 const GURL& first_party_for_cookies) const { | 16 const GURL& first_party_for_cookies) const { |
| 17 switch (type_) { | 17 switch (type_) { |
| 18 case StaticCookiePolicy::ALLOW_ALL_COOKIES: | 18 case StaticCookiePolicy::ALLOW_ALL_COOKIES: |
| 19 case StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES: | 19 case StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES: |
| 20 return OK; | 20 return OK; |
| 21 case StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES: | 21 case StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES: |
| 22 if (first_party_for_cookies.is_empty()) | 22 if (first_party_for_cookies.is_empty()) |
| 23 return OK; // Empty first-party URL indicates a first-party request. | 23 return OK; // Empty first-party URL indicates a first-party request. |
| 24 return RegistryControlledDomainService::SameDomainOrHost( | 24 return RegistryControlledDomainService::SameDomainOrHost( |
| 25 url, first_party_for_cookies) ? OK : ERR_ACCESS_DENIED; | 25 url, first_party_for_cookies, RCDS::EXCLUDE_PRIVATE_REGISTRIES) ? |
| 26 OK : ERR_ACCESS_DENIED; |
| 26 case StaticCookiePolicy::BLOCK_ALL_COOKIES: | 27 case StaticCookiePolicy::BLOCK_ALL_COOKIES: |
| 27 return ERR_ACCESS_DENIED; | 28 return ERR_ACCESS_DENIED; |
| 28 default: | 29 default: |
| 29 NOTREACHED(); | 30 NOTREACHED(); |
| 30 return ERR_ACCESS_DENIED; | 31 return ERR_ACCESS_DENIED; |
| 31 } | 32 } |
| 32 } | 33 } |
| 33 | 34 |
| 34 int StaticCookiePolicy::CanSetCookie( | 35 int StaticCookiePolicy::CanSetCookie( |
| 35 const GURL& url, | 36 const GURL& url, |
| 36 const GURL& first_party_for_cookies) const { | 37 const GURL& first_party_for_cookies) const { |
| 37 switch (type_) { | 38 switch (type_) { |
| 38 case StaticCookiePolicy::ALLOW_ALL_COOKIES: | 39 case StaticCookiePolicy::ALLOW_ALL_COOKIES: |
| 39 return OK; | 40 return OK; |
| 40 case StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES: | 41 case StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES: |
| 41 case StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES: | 42 case StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES: |
| 42 if (first_party_for_cookies.is_empty()) | 43 if (first_party_for_cookies.is_empty()) |
| 43 return OK; // Empty first-party URL indicates a first-party request. | 44 return OK; // Empty first-party URL indicates a first-party request. |
| 44 return RegistryControlledDomainService::SameDomainOrHost( | 45 return RegistryControlledDomainService::SameDomainOrHost( |
| 45 url, first_party_for_cookies) ? OK : ERR_ACCESS_DENIED; | 46 url, first_party_for_cookies, RCDS::EXCLUDE_PRIVATE_REGISTRIES) ? |
| 47 OK : ERR_ACCESS_DENIED; |
| 46 case StaticCookiePolicy::BLOCK_ALL_COOKIES: | 48 case StaticCookiePolicy::BLOCK_ALL_COOKIES: |
| 47 return ERR_ACCESS_DENIED; | 49 return ERR_ACCESS_DENIED; |
| 48 default: | 50 default: |
| 49 NOTREACHED(); | 51 NOTREACHED(); |
| 50 return ERR_ACCESS_DENIED; | 52 return ERR_ACCESS_DENIED; |
| 51 } | 53 } |
| 52 } | 54 } |
| 53 | 55 |
| 54 } // namespace net | 56 } // namespace net |
| OLD | NEW |