blob: 96a45759a5fc46bb909e7e7d32179df20d32d353 [file] [log] [blame]
Maks Orlovich87f4f892020-02-14 22:22:141// 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 Wennborg0924470b2020-04-27 21:08:057#include "base/notreached.h"
Maks Orlovich87f4f892020-02-14 22:22:148#include "net/base/net_errors.h"
9#include "net/cookies/site_for_cookies.h"
10#include "url/gurl.h"
11
12namespace net {
13
14int 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