summaryrefslogtreecommitdiff
path: root/chromium/net/cookies/static_cookie_policy.cc
blob: 25c6e4118260a3f27ab9d219837c10157c3b06c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/cookies/static_cookie_policy.h"

#include "base/logging.h"
#include "net/base/net_errors.h"
#include "net/cookies/site_for_cookies.h"
#include "url/gurl.h"

namespace net {

int StaticCookiePolicy::CanAccessCookies(
    const GURL& url,
    const net::SiteForCookies& site_for_cookies) const {
  switch (type_) {
    case StaticCookiePolicy::ALLOW_ALL_COOKIES:
      return OK;
    case StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES:
      return site_for_cookies.IsFirstParty(url) ? OK : ERR_ACCESS_DENIED;
    case StaticCookiePolicy::BLOCK_ALL_COOKIES:
      return ERR_ACCESS_DENIED;
    default:
      NOTREACHED();
      return ERR_ACCESS_DENIED;
  }
}

}  // namespace net