1 // Copyright 2012 The Chromium Authors 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 7 #include "base/notreached.h" 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 CanAccessCookies(const GURL & url,const net::SiteForCookies & site_for_cookies) const14int 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 31