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

Unified Diff: net/cookies/cookie_monster.cc

Issue 876973003: Implement the "first-party-only" cookie flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: FirstPartyOnly. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cookies/cookie_monster.h ('k') | net/cookies/cookie_monster_store_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_monster.cc
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
index 7c2a14c6d60e96c3c41e6d8f4b1e0cf9e5fd76c5..e5a5ce594b83a8d34db29d1818ea9531b1f96665 100644
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -414,6 +414,7 @@ class CookieMonster::SetCookieWithDetailsTask : public CookieMonsterTask {
const base::Time& expiration_time,
bool secure,
bool http_only,
+ bool first_party_only,
CookiePriority priority,
const SetCookiesCallback& callback)
: CookieMonsterTask(cookie_monster),
@@ -425,6 +426,7 @@ class CookieMonster::SetCookieWithDetailsTask : public CookieMonsterTask {
expiration_time_(expiration_time),
secure_(secure),
http_only_(http_only),
+ first_party_only_(first_party_only),
priority_(priority),
callback_(callback) {}
@@ -443,6 +445,7 @@ class CookieMonster::SetCookieWithDetailsTask : public CookieMonsterTask {
base::Time expiration_time_;
bool secure_;
bool http_only_;
+ bool first_party_only_;
CookiePriority priority_;
SetCookiesCallback callback_;
@@ -452,7 +455,7 @@ class CookieMonster::SetCookieWithDetailsTask : public CookieMonsterTask {
void CookieMonster::SetCookieWithDetailsTask::Run() {
bool success = this->cookie_monster()->SetCookieWithDetails(
url_, name_, value_, domain_, path_, expiration_time_, secure_,
- http_only_, priority_);
+ http_only_, first_party_only_, priority_);
if (!callback_.is_null()) {
this->InvokeCallback(base::Bind(&SetCookiesCallback::Run,
base::Unretained(&callback_), success));
@@ -884,11 +887,12 @@ void CookieMonster::SetCookieWithDetailsAsync(
const Time& expiration_time,
bool secure,
bool http_only,
+ bool first_party_only,
CookiePriority priority,
const SetCookiesCallback& callback) {
scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask(
this, url, name, value, domain, path, expiration_time, secure, http_only,
- priority, callback);
+ first_party_only, priority, callback);
DoCookieTaskForURL(task, url);
}
@@ -913,6 +917,7 @@ void CookieMonster::GetAllCookiesForURLAsync(
const GetCookieListCallback& callback) {
CookieOptions options;
options.set_include_httponly();
+ options.set_include_first_party_only();
scoped_refptr<GetAllCookiesForURLWithOptionsTask> task =
new GetAllCookiesForURLWithOptionsTask(this, url, options, callback);
@@ -1065,6 +1070,7 @@ bool CookieMonster::SetCookieWithDetails(const GURL& url,
const base::Time& expiration_time,
bool secure,
bool http_only,
+ bool first_party_only,
CookiePriority priority) {
base::AutoLock autolock(lock_);
@@ -1077,13 +1083,14 @@ bool CookieMonster::SetCookieWithDetails(const GURL& url,
scoped_ptr<CanonicalCookie> cc;
cc.reset(CanonicalCookie::Create(url, name, value, domain, path,
creation_time, expiration_time, secure,
- http_only, priority));
+ http_only, first_party_only, priority));
if (!cc.get())
return false;
CookieOptions options;
options.set_include_httponly();
+ options.set_include_first_party_only();
return SetCanonicalCookie(&cc, creation_time, options);
}
@@ -1095,6 +1102,7 @@ bool CookieMonster::ImportCookies(const CookieList& list) {
scoped_ptr<CanonicalCookie> cookie(new CanonicalCookie(*iter));
net::CookieOptions options;
options.set_include_httponly();
+ options.set_include_first_party_only();
if (!SetCanonicalCookie(&cookie, cookie->CreationDate(), options))
return false;
}
@@ -1153,6 +1161,7 @@ CookieList CookieMonster::GetAllCookiesForURLWithOptions(
CookieList CookieMonster::GetAllCookiesForURL(const GURL& url) {
CookieOptions options;
options.set_include_httponly();
+ options.set_first_party_url(url);
return GetAllCookiesForURLWithOptions(url, options);
}
@@ -1319,6 +1328,7 @@ void CookieMonster::DeleteCookie(const GURL& url,
CookieOptions options;
options.set_include_httponly();
+ options.set_include_first_party_only();
// Get the cookies for this host and its domain(s).
std::vector<CanonicalCookie*> cookies;
FindCookiesForHostAndDomain(url, options, true, &cookies);
@@ -2295,6 +2305,7 @@ void CookieMonster::RunCallbacks(const CanonicalCookie& cookie, bool removed) {
lock_.AssertAcquired();
CookieOptions opts;
opts.set_include_httponly();
+ opts.set_include_first_party_only();
// Note that the callbacks in hook_map_ are wrapped with MakeAsync(), so they
// are guaranteed to not take long - they just post a RunAsync task back to
// the appropriate thread's message loop and return. It is important that this
« no previous file with comments | « net/cookies/cookie_monster.h ('k') | net/cookies/cookie_monster_store_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698