Pass in full Options to SetCanonicalCookieAsync
This will be used to check whether same site cookies are being set
in the proper context. This change alters all the callsites to
include whether it should be trusted to set such cookies or not,
so it's not a simple/mechanical transformation.
(The old bool for httponly gets passed inside the options object as well,
like it would be for the get).
Bug: 837412
Change-Id: Ie7faf4e7cbc80706720e6ad20f6a46c759621f0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1471244
Reviewed-by: Mihai Sardarescu <[email protected]>
Reviewed-by: Mohammad Refaat <[email protected]>
Reviewed-by: Dominick Ng <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Matt Menke <[email protected]>
Reviewed-by: Richard Coles <[email protected]>
Reviewed-by: Jeremy Klein <[email protected]>
Reviewed-by: Andrey Kosyakov <[email protected]>
Commit-Queue: Maks Orlovich <[email protected]>
Cr-Commit-Position: refs/heads/master@{#641695}
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
index eef8c494..15a8a67 100644
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -398,7 +398,7 @@
void CookieMonster::SetCanonicalCookieAsync(
std::unique_ptr<CanonicalCookie> cookie,
std::string source_scheme,
- bool modify_http_only,
+ const CookieOptions& options,
SetCookiesCallback callback) {
DCHECK(cookie->IsCanonical());
@@ -409,7 +409,7 @@
// the callback on |*this|, so the callback will not outlive
// the object.
&CookieMonster::SetCanonicalCookie, base::Unretained(this),
- std::move(cookie), std::move(source_scheme), modify_http_only,
+ std::move(cookie), std::move(source_scheme), options,
std::move(callback)),
domain);
}
@@ -702,8 +702,7 @@
}
DCHECK(cc);
- SetCanonicalCookie(std::move(cc), url.scheme(), !options.exclude_httponly(),
- std::move(callback));
+ SetCanonicalCookie(std::move(cc), url.scheme(), options, std::move(callback));
}
void CookieMonster::DeleteCanonicalCookie(const CanonicalCookie& cookie,
@@ -1177,7 +1176,7 @@
void CookieMonster::SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc,
std::string source_scheme,
- bool modify_http_only,
+ const CookieOptions& options,
SetCookiesCallback callback) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -1190,7 +1189,7 @@
return;
}
- if ((cc->IsHttpOnly() && !modify_http_only)) {
+ if (cc->IsHttpOnly() && options.exclude_httponly()) {
MaybeRunCookieCallback(
std::move(callback),
CanonicalCookie::CookieInclusionStatus::EXCLUDE_HTTP_ONLY);
@@ -1215,9 +1214,9 @@
base::Time creation_date_to_inherit;
- CanonicalCookie::CookieInclusionStatus status =
- DeleteAnyEquivalentCookie(key, *cc, secure_source, !modify_http_only,
- already_expired, &creation_date_to_inherit);
+ CanonicalCookie::CookieInclusionStatus status = DeleteAnyEquivalentCookie(
+ key, *cc, secure_source, options.exclude_httponly(), already_expired,
+ &creation_date_to_inherit);
if (status != CanonicalCookie::CookieInclusionStatus::INCLUDE) {
std::string error;