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

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

Issue 6207005: Clarify wording around blocking 3rd party cookies and add lab to block reading of 3rd party cookies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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
OLDNEW
1 // Copyright (c) 2010 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/static_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/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/base/registry_controlled_domain.h" 10 #include "net/base/registry_controlled_domain.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 int StaticCookiePolicy::CanGetCookies(const GURL& url, 14 int StaticCookiePolicy::CanGetCookies(const GURL& url,
15 const GURL& first_party_for_cookies, 15 const GURL& first_party_for_cookies,
16 CompletionCallback* callback) { 16 CompletionCallback* callback) {
17 switch (type_) { 17 switch (type_) {
18 case StaticCookiePolicy::ALLOW_ALL_COOKIES: 18 case StaticCookiePolicy::ALLOW_ALL_COOKIES:
19 case StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES:
19 return OK; 20 return OK;
20 case StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES: 21 case StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES:
21 return OK; 22 if (first_party_for_cookies.is_empty())
23 return OK; // Empty first-party URL indicates a first-party request.
24 return RegistryControlledDomainService::SameDomainOrHost(
25 url, first_party_for_cookies) ? OK : ERR_ACCESS_DENIED;
22 case StaticCookiePolicy::BLOCK_ALL_COOKIES: 26 case StaticCookiePolicy::BLOCK_ALL_COOKIES:
23 return ERR_ACCESS_DENIED; 27 return ERR_ACCESS_DENIED;
24 default: 28 default:
25 NOTREACHED(); 29 NOTREACHED();
26 return ERR_ACCESS_DENIED; 30 return ERR_ACCESS_DENIED;
27 } 31 }
28 } 32 }
29 33
30 int StaticCookiePolicy::CanSetCookie(const GURL& url, 34 int StaticCookiePolicy::CanSetCookie(const GURL& url,
31 const GURL& first_party_for_cookies, 35 const GURL& first_party_for_cookies,
32 const std::string& cookie_line, 36 const std::string& cookie_line,
33 CompletionCallback* callback) { 37 CompletionCallback* callback) {
34 switch (type_) { 38 switch (type_) {
35 case StaticCookiePolicy::ALLOW_ALL_COOKIES: 39 case StaticCookiePolicy::ALLOW_ALL_COOKIES:
36 return OK; 40 return OK;
37 case StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES: 41 case StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES:
42 case StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES:
38 if (first_party_for_cookies.is_empty()) 43 if (first_party_for_cookies.is_empty())
39 return OK; // Empty first-party URL indicates a first-party request. 44 return OK; // Empty first-party URL indicates a first-party request.
40 return RegistryControlledDomainService::SameDomainOrHost( 45 return RegistryControlledDomainService::SameDomainOrHost(
41 url, first_party_for_cookies) ? OK : ERR_ACCESS_DENIED; 46 url, first_party_for_cookies) ? OK : ERR_ACCESS_DENIED;
42 case StaticCookiePolicy::BLOCK_ALL_COOKIES: 47 case StaticCookiePolicy::BLOCK_ALL_COOKIES:
43 return ERR_ACCESS_DENIED; 48 return ERR_ACCESS_DENIED;
44 default: 49 default:
45 NOTREACHED(); 50 NOTREACHED();
46 return ERR_ACCESS_DENIED; 51 return ERR_ACCESS_DENIED;
47 } 52 }
48 } 53 }
49 54
50 } // namespace net 55 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698