Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: net/base/static_cookie_policy.cc

Issue 556095: Changes to support new cookie policy.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/static_cookie_policy.h ('k') | net/base/static_cookie_policy_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/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/registry_controlled_domain.h" 9 #include "net/base/registry_controlled_domain.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 bool CookiePolicy::CanGetCookies(const GURL& url, 13 bool StaticCookiePolicy::CanGetCookies(const GURL& url,
14 const GURL& first_party_for_cookies) { 14 const GURL& first_party_for_cookies) {
15 switch (type_) { 15 switch (type_) {
16 case CookiePolicy::ALLOW_ALL_COOKIES: 16 case StaticCookiePolicy::ALLOW_ALL_COOKIES:
17 return true; 17 return true;
18 case CookiePolicy::BLOCK_THIRD_PARTY_COOKIES: 18 case StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES:
19 return true; 19 return true;
20 case CookiePolicy::BLOCK_ALL_COOKIES: 20 case StaticCookiePolicy::BLOCK_ALL_COOKIES:
21 return false; 21 return false;
22 default: 22 default:
23 NOTREACHED(); 23 NOTREACHED();
24 return false; 24 return false;
25 } 25 }
26 } 26 }
27 27
28 bool CookiePolicy::CanSetCookie(const GURL& url, 28 bool StaticCookiePolicy::CanSetCookie(const GURL& url,
29 const GURL& first_party_for_cookies) { 29 const GURL& first_party_for_cookies) {
30 switch (type_) { 30 switch (type_) {
31 case CookiePolicy::ALLOW_ALL_COOKIES: 31 case StaticCookiePolicy::ALLOW_ALL_COOKIES:
32 return true; 32 return true;
33 case CookiePolicy::BLOCK_THIRD_PARTY_COOKIES: 33 case StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES:
34 if (first_party_for_cookies.is_empty()) 34 if (first_party_for_cookies.is_empty())
35 return true; // Empty first-party URL indicates a first-party request. 35 return true; // Empty first-party URL indicates a first-party request.
36 return net::RegistryControlledDomainService::SameDomainOrHost( 36 return net::RegistryControlledDomainService::SameDomainOrHost(
37 url, first_party_for_cookies); 37 url, first_party_for_cookies);
38 case CookiePolicy::BLOCK_ALL_COOKIES: 38 case StaticCookiePolicy::BLOCK_ALL_COOKIES:
39 return false; 39 return false;
40 default: 40 default:
41 NOTREACHED(); 41 NOTREACHED();
42 return false; 42 return false;
43 } 43 }
44 } 44 }
45 45
46 CookiePolicy::CookiePolicy() : type_(CookiePolicy::ALLOW_ALL_COOKIES) {
47 }
48
49 } // namespace net 46 } // namespace net
OLDNEW
« no previous file with comments | « net/base/static_cookie_policy.h ('k') | net/base/static_cookie_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698