Maks Orlovich | 87f4f89 | 2020-02-14 22:22:14 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/cookies/static_cookie_policy.h" |
| 6 | |
Hans Wennborg | 0924470b | 2020-04-27 21:08:05 | [diff] [blame] | 7 | #include "base/notreached.h" |
Maks Orlovich | 87f4f89 | 2020-02-14 22:22:14 | [diff] [blame] | 8 | #include "net/base/net_errors.h" |
| 9 | #include "net/cookies/site_for_cookies.h" |
| 10 | #include "url/gurl.h" |
| 11 | |
| 12 | namespace net { |
| 13 | |
| 14 | int StaticCookiePolicy::CanAccessCookies( |
| 15 | const GURL& url, |
| 16 | const net::SiteForCookies& site_for_cookies) const { |
| 17 | switch (type_) { |
| 18 | case StaticCookiePolicy::ALLOW_ALL_COOKIES: |
| 19 | return OK; |
| 20 | case StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES: |
| 21 | return site_for_cookies.IsFirstParty(url) ? OK : ERR_ACCESS_DENIED; |
| 22 | case StaticCookiePolicy::BLOCK_ALL_COOKIES: |
| 23 | return ERR_ACCESS_DENIED; |
| 24 | default: |
| 25 | NOTREACHED(); |
| 26 | return ERR_ACCESS_DENIED; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | } // namespace net |