Commit d95c245f authored by Maks Orlovich's avatar Maks Orlovich Committed by Commit Bot

AW: Use proper context for CookieManager.SetCookie

It should be treated as a 1st party context, not 3rd party one.

Bug: 1012742
Change-Id: Ic8ceb0c7f2e60e15b4517550c50ab67c637b492c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1853044
Commit-Queue: Maksim Orlovich <morlovich@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704748}
parent 8690a726
...@@ -405,9 +405,6 @@ void CookieManager::SetCookieSync(JNIEnv* env, ...@@ -405,9 +405,6 @@ void CookieManager::SetCookieSync(JNIEnv* env,
void CookieManager::SetCookieHelper(const GURL& host, void CookieManager::SetCookieHelper(const GURL& host,
const std::string& value, const std::string& value,
base::OnceCallback<void(bool)> callback) { base::OnceCallback<void(bool)> callback) {
net::CookieOptions options;
options.set_include_httponly();
const GURL& new_host = MaybeFixUpSchemeForSecureCookie(host, value); const GURL& new_host = MaybeFixUpSchemeForSecureCookie(host, value);
net::CanonicalCookie::CookieInclusionStatus status; net::CanonicalCookie::CookieInclusionStatus status;
...@@ -429,12 +426,13 @@ void CookieManager::SetCookieHelper(const GURL& host, ...@@ -429,12 +426,13 @@ void CookieManager::SetCookieHelper(const GURL& host,
// *cc.get() is safe, because network::CookieManager::SetCanonicalCookie // *cc.get() is safe, because network::CookieManager::SetCanonicalCookie
// will make a copy before our smart pointer goes out of scope. // will make a copy before our smart pointer goes out of scope.
GetMojoCookieManager()->SetCanonicalCookie( GetMojoCookieManager()->SetCanonicalCookie(
*cc.get(), new_host.scheme(), options, *cc.get(), new_host.scheme(), net::CookieOptions::MakeAllInclusive(),
net::cookie_util::AdaptCookieInclusionStatusToBool( net::cookie_util::AdaptCookieInclusionStatusToBool(
std::move(callback))); std::move(callback)));
} else { } else {
GetCookieStore()->SetCanonicalCookieAsync( GetCookieStore()->SetCanonicalCookieAsync(
std::move(cc), new_host.scheme(), options, std::move(cc), new_host.scheme(),
net::CookieOptions::MakeAllInclusive(),
net::cookie_util::AdaptCookieInclusionStatusToBool( net::cookie_util::AdaptCookieInclusionStatusToBool(
std::move(callback))); std::move(callback)));
} }
...@@ -458,10 +456,7 @@ ScopedJavaLocalRef<jstring> CookieManager::GetCookie( ...@@ -458,10 +456,7 @@ ScopedJavaLocalRef<jstring> CookieManager::GetCookie(
void CookieManager::GetCookieListAsyncHelper(const GURL& host, void CookieManager::GetCookieListAsyncHelper(const GURL& host,
net::CookieList* result, net::CookieList* result,
base::OnceClosure complete) { base::OnceClosure complete) {
net::CookieOptions options; net::CookieOptions options = net::CookieOptions::MakeAllInclusive();
options.set_include_httponly();
options.set_same_site_cookie_context(
net::CookieOptions::SameSiteCookieContext::SAME_SITE_STRICT);
if (GetMojoCookieManager()) { if (GetMojoCookieManager()) {
GetMojoCookieManager()->GetCookieList( GetMojoCookieManager()->GetCookieList(
......
...@@ -322,6 +322,16 @@ public class CookieManagerTest { ...@@ -322,6 +322,16 @@ public class CookieManagerTest {
SECURE_COOKIE_HISTOGRAM_NAME, 3 /* kNotASecureCookie */)); SECURE_COOKIE_HISTOGRAM_NAME, 3 /* kNotASecureCookie */));
} }
@Test
@MediumTest
@Feature({"AndroidWebView", "Privacy"})
public void testSetCookieSameSite() {
String url = "http://www.example.com";
String cookie = "name=test";
mCookieManager.setCookie(url, cookie + "; SameSite=Lax");
assertCookieEquals(cookie, url);
}
@Test @Test
@MediumTest @MediumTest
@Feature({"AndroidWebView", "Privacy"}) @Feature({"AndroidWebView", "Privacy"})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment