Reland "Take scheme in CookieStore::SetCanonicalCookieAsync, not just whether it's secure."
This reverts commit 90c86f0ce7
.
Justification for revert of revert: Fixed build/merged with a trunk change
Bug:850044
Change-Id: Ie96c714b34aad37684692cf1a644cf15e1fae8ea
Reviewed-on: https://chromium-review.googlesource.com/c/1482562
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Maks Orlovich <morlovich@chromium.org>
Commit-Queue: Maks Orlovich <morlovich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635098}
This commit is contained in:

committed by
Commit Bot

parent
7cca647e18
commit
44525ced66
android_webview/browser
chrome/browser
android
cookies
browsing_data
browsing_data_cookie_helper_unittest.ccbrowsing_data_remover_browsertest.ccchrome_browsing_data_remover_delegate_unittest.cc
counters
chromeos
android_sms
login
extensions
net
profile_resetter
ui
webui
chromeos
components/signin/core/browser
content
browser
browsing_data
cookie_store
devtools
frame_host
public
ios
chrome
browser
net
net/cookies
cookie_monster.cccookie_monster.hcookie_monster_unittest.cccookie_store.hcookie_store_test_helpers.cccookie_store_test_helpers.hcookie_store_unittest.h
services/network
cookie_manager.cccookie_manager.hcookie_manager_unittest.ccnetwork_context_unittest.ccrestricted_cookie_manager.ccrestricted_cookie_manager_unittest.cc
public
mojom
test
url
@ -379,13 +379,13 @@ void CookieManager::SetCookieHelper(
|
||||
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
|
||||
// *cc.get() is safe, because network::CookieManager::SetCanonicalCookie
|
||||
// will make a copy before our smart pointer goes out of scope.
|
||||
GetCookieManagerWrapper()->SetCanonicalCookie(
|
||||
*cc.get(), new_host.SchemeIsCryptographic(),
|
||||
!options.exclude_httponly(), std::move(callback));
|
||||
GetCookieManagerWrapper()->SetCanonicalCookie(*cc.get(), new_host.scheme(),
|
||||
!options.exclude_httponly(),
|
||||
std::move(callback));
|
||||
} else {
|
||||
GetCookieStore()->SetCanonicalCookieAsync(
|
||||
std::move(cc), new_host.SchemeIsCryptographic(),
|
||||
!options.exclude_httponly(), StatusToBool(callback));
|
||||
GetCookieStore()->SetCanonicalCookieAsync(std::move(cc), new_host.scheme(),
|
||||
!options.exclude_httponly(),
|
||||
StatusToBool(callback));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,12 @@ void SetCookieWithOptionsAsyncOnCookieThread(
|
||||
|
||||
void SetCanonicalCookieAsyncOnCookieThread(
|
||||
std::unique_ptr<net::CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
net::CookieStore::SetCookiesCallback callback) {
|
||||
GetCookieStore()->SetCanonicalCookieAsync(
|
||||
std::move(cookie), secure_source, modify_http_only, std::move(callback));
|
||||
std::move(cookie), std::move(source_scheme), modify_http_only,
|
||||
std::move(callback));
|
||||
}
|
||||
|
||||
void GetCookieListWithOptionsAsyncOnCookieThread(
|
||||
@ -102,13 +103,13 @@ void AwCookieStoreWrapper::SetCookieWithOptionsAsync(
|
||||
|
||||
void AwCookieStoreWrapper::SetCanonicalCookieAsync(
|
||||
std::unique_ptr<net::CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) {
|
||||
DCHECK(client_task_runner_->RunsTasksInCurrentSequence());
|
||||
PostTaskToCookieStoreTaskRunner(base::BindOnce(
|
||||
&SetCanonicalCookieAsyncOnCookieThread, std::move(cookie), secure_source,
|
||||
modify_http_only,
|
||||
&SetCanonicalCookieAsyncOnCookieThread, std::move(cookie),
|
||||
std::move(source_scheme), modify_http_only,
|
||||
CreateWrappedCallback<net::CanonicalCookie::CookieInclusionStatus>(
|
||||
std::move(callback))));
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class AwCookieStoreWrapper : public net::CookieStore {
|
||||
const net::CookieOptions& options,
|
||||
SetCookiesCallback callback) override;
|
||||
void SetCanonicalCookieAsync(std::unique_ptr<net::CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) override;
|
||||
void GetCookieListWithOptionsAsync(const GURL& url,
|
||||
|
@ -32,13 +32,13 @@ void AwCookieManagerWrapper::GetCookieList(
|
||||
|
||||
void AwCookieManagerWrapper::SetCanonicalCookie(
|
||||
const net::CanonicalCookie& cc,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCanonicalCookieCallback callback) {
|
||||
// TODO(ntfschr): handle the case where content layer isn't initialized yet
|
||||
// (http://crbug.com/933461).
|
||||
cookie_manager_->SetCanonicalCookie(cc, secure_source, modify_http_only,
|
||||
std::move(callback));
|
||||
cookie_manager_->SetCanonicalCookie(cc, std::move(source_scheme),
|
||||
modify_http_only, std::move(callback));
|
||||
}
|
||||
|
||||
void AwCookieManagerWrapper::DeleteCookies(
|
||||
|
@ -43,7 +43,7 @@ class AwCookieManagerWrapper {
|
||||
GetCookieListCallback callback);
|
||||
|
||||
void SetCanonicalCookie(const net::CanonicalCookie& cc,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCanonicalCookieCallback);
|
||||
|
||||
|
@ -111,6 +111,6 @@ static void JNI_CookiesFetcher_RestoreCookies(
|
||||
// Assume HTTPS - since the cookies are being restored from another store,
|
||||
// they have already gone through the strict secure check.
|
||||
GetCookieServiceClient()->SetCanonicalCookie(
|
||||
*cookie, true /* secure_source */, true /* modify_http_only */,
|
||||
*cookie, "https", true /* modify_http_only */,
|
||||
network::mojom::CookieManager::SetCanonicalCookieCallback());
|
||||
}
|
||||
|
@ -112,38 +112,34 @@ class BrowsingDataCookieHelperTest : public testing::Test {
|
||||
|
||||
void CreateCookiesForTest() {
|
||||
auto cookie1 =
|
||||
net::CanonicalCookie::Create(GURL("http://www.google.com"), "A=1",
|
||||
base::Time::Now(), net::CookieOptions());
|
||||
auto cookie2 =
|
||||
net::CanonicalCookie::Create(GURL("http://www.gmail.google.com"), "B=1",
|
||||
net::CanonicalCookie::Create(GURL("https://www.google.com"), "A=1",
|
||||
base::Time::Now(), net::CookieOptions());
|
||||
auto cookie2 = net::CanonicalCookie::Create(
|
||||
GURL("https://www.gmail.google.com"), "B=1", base::Time::Now(),
|
||||
net::CookieOptions());
|
||||
|
||||
network::mojom::CookieManager* cookie_manager =
|
||||
storage_partition()->GetCookieManagerForBrowserProcess();
|
||||
cookie_manager->SetCanonicalCookie(*cookie1, true /* secure_source */,
|
||||
false /* modify_http_only */,
|
||||
base::DoNothing());
|
||||
cookie_manager->SetCanonicalCookie(*cookie2, true /* secure_source */,
|
||||
false /* modify_http_only */,
|
||||
base::DoNothing());
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
*cookie1, "https", false /* modify_http_only */, base::DoNothing());
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
*cookie2, "https", false /* modify_http_only */, base::DoNothing());
|
||||
}
|
||||
|
||||
void CreateCookiesForDomainCookieTest() {
|
||||
auto cookie1 =
|
||||
net::CanonicalCookie::Create(GURL("http://www.google.com"), "A=1",
|
||||
net::CanonicalCookie::Create(GURL("https://www.google.com"), "A=1",
|
||||
base::Time::Now(), net::CookieOptions());
|
||||
auto cookie2 = net::CanonicalCookie::Create(
|
||||
GURL("http://www.google.com"), "A=2; Domain=.www.google.com ",
|
||||
GURL("https://www.google.com"), "A=2; Domain=.www.google.com ",
|
||||
base::Time::Now(), net::CookieOptions());
|
||||
|
||||
network::mojom::CookieManager* cookie_manager =
|
||||
storage_partition()->GetCookieManagerForBrowserProcess();
|
||||
cookie_manager->SetCanonicalCookie(*cookie1, true /* secure_source */,
|
||||
false /* modify_http_only */,
|
||||
base::DoNothing());
|
||||
cookie_manager->SetCanonicalCookie(*cookie2, true /* secure_source */,
|
||||
false /* modify_http_only */,
|
||||
base::DoNothing());
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
*cookie1, "https", false /* modify_http_only */, base::DoNothing());
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
*cookie2, "https", false /* modify_http_only */, base::DoNothing());
|
||||
}
|
||||
|
||||
void FetchCallback(const net::CookieList& cookies) {
|
||||
|
@ -282,7 +282,8 @@ bool SetGaiaCookieForProfile(Profile* profile) {
|
||||
network::mojom::CookieManager* cookie_manager =
|
||||
content::BrowserContext::GetDefaultStoragePartition(profile)
|
||||
->GetCookieManagerForBrowserProcess();
|
||||
cookie_manager->SetCanonicalCookie(cookie, true, true, std::move(callback));
|
||||
cookie_manager->SetCanonicalCookie(cookie, "https", true,
|
||||
std::move(callback));
|
||||
loop.Run();
|
||||
return success;
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ class RemoveCookieTester {
|
||||
auto cookie = net::CanonicalCookie::Create(
|
||||
kOrigin1, "A=1", base::Time::Now(), net::CookieOptions());
|
||||
cookie_manager_->SetCanonicalCookie(
|
||||
*cookie, /*secure_source=*/false, /*modify_http_only=*/false,
|
||||
*cookie, "http", /*modify_http_only=*/false,
|
||||
base::BindLambdaForTesting([&](bool result) {
|
||||
EXPECT_TRUE(result);
|
||||
run_loop.Quit();
|
||||
|
@ -57,7 +57,7 @@ class SiteDataCountingHelperTest : public testing::Test {
|
||||
time, url.SchemeIsCryptographic(), false,
|
||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT);
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
*cookie, url.SchemeIsCryptographic(), true /*modify_http_only*/,
|
||||
*cookie, url.scheme(), true /*modify_http_only*/,
|
||||
base::BindLambdaForTesting([&](bool result) {
|
||||
if (--tasks == 0)
|
||||
run_loop.Quit();
|
||||
|
@ -88,7 +88,7 @@ void AndroidSmsAppSetupControllerImpl::SetUpApp(const GURL& app_url,
|
||||
base::Time::Now() /* last_access_time */, true /* secure */,
|
||||
false /* http_only */, net::CookieSameSite::STRICT_MODE,
|
||||
net::COOKIE_PRIORITY_DEFAULT),
|
||||
true /* secure_source */, false /* modify_http_only */,
|
||||
"https", false /* modify_http_only */,
|
||||
base::BindOnce(&AndroidSmsAppSetupControllerImpl::
|
||||
OnSetRememberDeviceByDefaultCookieResult,
|
||||
weak_ptr_factory_.GetWeakPtr(), app_url, install_url,
|
||||
@ -275,7 +275,7 @@ void AndroidSmsAppSetupControllerImpl::OnAppUninstallResult(
|
||||
base::Time::Now() /* last_access_time */, true /* secure */,
|
||||
false /* http_only */, net::CookieSameSite::STRICT_MODE,
|
||||
net::COOKIE_PRIORITY_DEFAULT),
|
||||
true /* secure_source */, false /* modify_http_only */,
|
||||
"https", false /* modify_http_only */,
|
||||
base::BindOnce(
|
||||
&AndroidSmsAppSetupControllerImpl::OnSetMigrationCookieResult,
|
||||
weak_ptr_factory_.GetWeakPtr(), app_url, std::move(callback)));
|
||||
|
@ -61,7 +61,7 @@ class FakeCookieManager : public network::TestCookieManager {
|
||||
void InvokePendingSetCanonicalCookieCallback(
|
||||
const std::string& expected_cookie_name,
|
||||
const std::string& expected_cookie_value,
|
||||
bool expected_secure_source,
|
||||
const std::string& expected_source_scheme,
|
||||
bool expected_modify_http_only,
|
||||
bool success) {
|
||||
ASSERT_FALSE(set_canonical_cookie_calls_.empty());
|
||||
@ -70,7 +70,7 @@ class FakeCookieManager : public network::TestCookieManager {
|
||||
|
||||
EXPECT_EQ(expected_cookie_name, std::get<0>(params).Name());
|
||||
EXPECT_EQ(expected_cookie_value, std::get<0>(params).Value());
|
||||
EXPECT_EQ(expected_secure_source, std::get<1>(params));
|
||||
EXPECT_EQ(expected_source_scheme, std::get<1>(params));
|
||||
EXPECT_EQ(expected_modify_http_only, std::get<2>(params));
|
||||
|
||||
std::move(std::get<3>(params)).Run(success);
|
||||
@ -92,11 +92,11 @@ class FakeCookieManager : public network::TestCookieManager {
|
||||
|
||||
// network::mojom::CookieManager
|
||||
void SetCanonicalCookie(const net::CanonicalCookie& cookie,
|
||||
bool secure_source,
|
||||
const std::string& source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCanonicalCookieCallback callback) override {
|
||||
set_canonical_cookie_calls_.emplace_back(
|
||||
cookie, secure_source, modify_http_only, std::move(callback));
|
||||
cookie, source_scheme, modify_http_only, std::move(callback));
|
||||
}
|
||||
|
||||
void DeleteCookies(network::mojom::CookieDeletionFilterPtr filter,
|
||||
@ -105,8 +105,10 @@ class FakeCookieManager : public network::TestCookieManager {
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<
|
||||
std::tuple<net::CanonicalCookie, bool, bool, SetCanonicalCookieCallback>>
|
||||
std::vector<std::tuple<net::CanonicalCookie,
|
||||
std::string,
|
||||
bool,
|
||||
SetCanonicalCookieCallback>>
|
||||
set_canonical_cookie_calls_;
|
||||
std::vector<
|
||||
std::pair<network::mojom::CookieDeletionFilterPtr, DeleteCookiesCallback>>
|
||||
@ -206,7 +208,8 @@ class AndroidSmsAppSetupControllerImplTest : public testing::Test {
|
||||
|
||||
fake_cookie_manager_->InvokePendingSetCanonicalCookieCallback(
|
||||
"default_to_persist" /* expected_cookie_name */,
|
||||
"true" /* expected_cookie_value */, true /* expected_secure_source */,
|
||||
"true" /* expected_cookie_value */,
|
||||
"https" /* expected_source_scheme */,
|
||||
false /* expected_modify_http_only */, true /* success */);
|
||||
|
||||
fake_cookie_manager_->InvokePendingDeleteCookiesCallback(
|
||||
@ -278,7 +281,7 @@ class AndroidSmsAppSetupControllerImplTest : public testing::Test {
|
||||
fake_cookie_manager_->InvokePendingSetCanonicalCookieCallback(
|
||||
"cros_migrated_to" /* expected_cookie_name */,
|
||||
migrated_to_app_url.GetContent() /* expected_cookie_value */,
|
||||
true /* expected_secure_source */,
|
||||
"https" /* expected_source_scheme */,
|
||||
false /* expected_modify_http_only */, true /* success */);
|
||||
|
||||
fake_cookie_manager_->InvokePendingDeleteCookiesCallback(
|
||||
|
@ -81,7 +81,7 @@ void ImportCookies(base::RepeatingClosure completion_callback,
|
||||
// another store, they have already gone through the strict secure check.
|
||||
DCHECK(cookie.IsCanonical());
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
cookie, true /*secure_source*/, true /*modify_http_only*/,
|
||||
cookie, "https", true /*modify_http_only*/,
|
||||
base::BindOnce(&OnCookieSet, cookie_completion_callback));
|
||||
}
|
||||
}
|
||||
|
@ -187,21 +187,21 @@ void ProfileAuthDataTest::PopulateBrowserContext(
|
||||
kSAMLIdPCookieDomainWithWildcard, std::string(), base::Time(),
|
||||
base::Time(), base::Time(), true, false,
|
||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT),
|
||||
true /*secure_source*/, true /*modify_http_only*/, base::DoNothing());
|
||||
"https", true /*modify_http_only*/, base::DoNothing());
|
||||
|
||||
cookies->SetCanonicalCookie(
|
||||
*net::CanonicalCookie::CreateSanitizedCookie(
|
||||
GURL(kSAMLIdPCookieURL), kCookieName, cookie_value, std::string(),
|
||||
std::string(), base::Time(), base::Time(), base::Time(), true, false,
|
||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT),
|
||||
true /*secure_source*/, true /*modify_http_only*/, base::DoNothing());
|
||||
"https", true /*modify_http_only*/, base::DoNothing());
|
||||
|
||||
cookies->SetCanonicalCookie(
|
||||
*net::CanonicalCookie::CreateSanitizedCookie(
|
||||
GURL(kGAIACookieURL), kCookieName, cookie_value, std::string(),
|
||||
std::string(), base::Time(), base::Time(), base::Time(), true, false,
|
||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT),
|
||||
true /*secure_source*/, true /*modify_http_only*/, base::DoNothing());
|
||||
"https", true /*modify_http_only*/, base::DoNothing());
|
||||
}
|
||||
|
||||
net::URLRequestContext* ProfileAuthDataTest::GetRequestContext(
|
||||
|
@ -90,7 +90,7 @@ void InjectCookie(content::StoragePartition* storage_partition) {
|
||||
"/", base::Time(), base::Time(), base::Time(), false,
|
||||
false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
false, false,
|
||||
"http", false,
|
||||
base::Bind(&InjectCookieDoneCallback, run_loop.QuitClosure()));
|
||||
run_loop.Run();
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ bool SetGaiaCookieForProfile(Profile* profile) {
|
||||
content::BrowserContext::GetDefaultStoragePartition(profile)
|
||||
->GetCookieManagerForBrowserProcess();
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
cookie, true, true,
|
||||
cookie, google_url.scheme(), true,
|
||||
mojo::WrapCallbackWithDefaultInvokeIfNotRun(std::move(callback), false));
|
||||
loop.Run();
|
||||
return success;
|
||||
|
@ -369,7 +369,7 @@ ExtensionFunction::ResponseAction CookiesSetFunction::Run() {
|
||||
// plus FIFO ordering on the cookie_manager_ pipe means that no
|
||||
// other extension function will affect the get result.
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
*cc, url_.SchemeIsCryptographic(), true /*modify_http_only*/,
|
||||
*cc, url_.scheme(), true /*modify_http_only*/,
|
||||
base::BindOnce(&CookiesSetFunction::SetCanonicalCookieCallback, this));
|
||||
cookies_helpers::GetCookieListFromManager(
|
||||
cookie_manager, url_,
|
||||
|
@ -4992,7 +4992,7 @@ TEST_F(ExtensionServiceTest, ClearAppData) {
|
||||
bool set_result = false;
|
||||
base::RunLoop run_loop;
|
||||
cookie_manager_ptr->SetCanonicalCookie(
|
||||
*cc.get(), origin1.SchemeIsCryptographic(), true /* modify_http_only */,
|
||||
*cc.get(), origin1.scheme(), true /* modify_http_only */,
|
||||
base::BindOnce(&SetCookieSaveData, &set_result,
|
||||
run_loop.QuitClosure()));
|
||||
run_loop.Run();
|
||||
|
@ -48,7 +48,7 @@ void SetCookie(const network::mojom::CookieManagerPtr& cookie_manager) {
|
||||
net::COOKIE_PRIORITY_DEFAULT);
|
||||
base::RunLoop run_loop;
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
cookie, false, false,
|
||||
cookie, "http", false,
|
||||
base::BindLambdaForTesting([&](bool success) { run_loop.Quit(); }));
|
||||
run_loop.Run();
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void RemoveCookieTester::AddCookie(const std::string& host,
|
||||
base::Time(), false, false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
false /* secure_source */, true /* modify_http_only */,
|
||||
"http", true /* modify_http_only */,
|
||||
base::BindOnce(&RemoveCookieTester::SetCanonicalCookieCallback,
|
||||
base::Unretained(this)));
|
||||
BlockUntilNotified();
|
||||
|
@ -379,8 +379,7 @@ void GaiaScreenHandler::LoadGaiaWithPartition(
|
||||
net::CookieOptions()));
|
||||
|
||||
partition->GetCookieManagerForBrowserProcess()->SetCanonicalCookie(
|
||||
*cc.get(), true /* secure_source */, true /* modify_http_only */,
|
||||
std::move(callback));
|
||||
*cc.get(), "https", true /* modify_http_only */, std::move(callback));
|
||||
}
|
||||
|
||||
void GaiaScreenHandler::OnSetCookieForLoadGaiaWithPartition(
|
||||
|
@ -1171,7 +1171,7 @@ void GaiaCookieManagerService::StartSettingCookies(
|
||||
&GaiaCookieManagerService::OnCookieSet,
|
||||
weak_ptr_factory_.GetWeakPtr(), cookie.Name(), cookie.Domain());
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
cookie, true, true,
|
||||
cookie, "https", true,
|
||||
mojo::WrapCallbackWithDefaultInvokeIfNotRun(std::move(callback),
|
||||
false));
|
||||
} else {
|
||||
|
@ -228,7 +228,7 @@ class ClearSiteDataHandlerBrowserTest : public ContentBrowserTest {
|
||||
|
||||
base::RunLoop run_loop;
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
*cookie, true /* secure_source */, false /* modify_http_only */,
|
||||
*cookie, url.scheme(), false /* modify_http_only */,
|
||||
base::BindOnce(&ClearSiteDataHandlerBrowserTest::AddCookieCallback,
|
||||
run_loop.QuitClosure()));
|
||||
run_loop.Run();
|
||||
|
@ -319,7 +319,7 @@ class CookieStoreManagerTest
|
||||
base::RunLoop run_loop;
|
||||
bool success = false;
|
||||
cookie_manager_->SetCanonicalCookie(
|
||||
cookie, /* secure_source = */ true, /* can_modify_httponly = */ true,
|
||||
cookie, "https", /* can_modify_httponly = */ true,
|
||||
base::BindOnce(
|
||||
[](base::RunLoop* run_loop, bool* success, bool service_success) {
|
||||
*success = success;
|
||||
|
@ -1080,7 +1080,7 @@ void DevToolsURLInterceptorRequestJob::ProcessInterceptionResponse(
|
||||
|
||||
auto* store = request_details_.url_request_context->cookie_store();
|
||||
store->SetCanonicalCookieAsync(
|
||||
std::move(cookie), request_details_.url.SchemeIsCryptographic(),
|
||||
std::move(cookie), request_details_.url.scheme(),
|
||||
!options.exclude_httponly(), net::CookieStore::SetCookiesCallback());
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1060,9 @@ void InterceptionJob::ProcessSetCookies(const net::HttpResponseHeaders& headers,
|
||||
[](base::RepeatingClosure closure, bool) { closure.Run(); },
|
||||
base::BarrierClosure(cookies.size(), std::move(callback)));
|
||||
for (auto& cookie : cookies) {
|
||||
cookie_manager_->SetCanonicalCookie(*cookie, true, true, on_cookie_set);
|
||||
cookie_manager_->SetCanonicalCookie(
|
||||
*cookie, create_loader_params_->request.url.scheme(), true,
|
||||
on_cookie_set);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ void SetCookieOnIO(
|
||||
context_getter->GetURLRequestContext();
|
||||
|
||||
request_context->cookie_store()->SetCanonicalCookieAsync(
|
||||
std::move(cookie), true /* secure_source */, true /*modify_http_only*/,
|
||||
std::move(cookie), "https" /* source_scheme */, true /*modify_http_only*/,
|
||||
std::move(callback));
|
||||
}
|
||||
|
||||
@ -1249,7 +1249,7 @@ void NetworkHandler::SetCookie(const std::string& name,
|
||||
}
|
||||
|
||||
storage_partition_->GetCookieManagerForBrowserProcess()->SetCanonicalCookie(
|
||||
*cookie, true /* secure_source */, true /* modify_http_only */,
|
||||
*cookie, "https", true /* modify_http_only */,
|
||||
base::BindOnce(&SetCookieCallback::sendSuccess, std::move(callback)));
|
||||
}
|
||||
|
||||
@ -1296,7 +1296,7 @@ void NetworkHandler::SetCookies(
|
||||
storage_partition_->GetCookieManagerForBrowserProcess();
|
||||
for (const auto& cookie : net_cookies) {
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
*cookie, true, true,
|
||||
*cookie, "https", true,
|
||||
base::BindOnce(
|
||||
[](base::RepeatingClosure callback, bool) { callback.Run(); },
|
||||
barrier_closure));
|
||||
|
@ -613,8 +613,8 @@ void RenderFrameMessageFilter::SetCookie(int32_t render_frame_id,
|
||||
|
||||
// Pass a null callback since we don't care about when the 'set' completes.
|
||||
cookie_store->SetCanonicalCookieAsync(
|
||||
std::move(cookie), url.SchemeIsCryptographic(),
|
||||
!options.exclude_httponly(), net::CookieStore::SetCookiesCallback());
|
||||
std::move(cookie), url.scheme(), !options.exclude_httponly(),
|
||||
net::CookieStore::SetCookiesCallback());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -627,8 +627,7 @@ void RenderFrameMessageFilter::SetCookie(int32_t render_frame_id,
|
||||
std::move(callback)),
|
||||
false);
|
||||
(*GetCookieManager())
|
||||
->SetCanonicalCookie(*cookie, url.SchemeIsCryptographic(),
|
||||
!options.exclude_httponly(),
|
||||
->SetCanonicalCookie(*cookie, url.scheme(), !options.exclude_httponly(),
|
||||
std::move(net_callback));
|
||||
}
|
||||
|
||||
|
@ -1785,7 +1785,7 @@ bool SetCookie(BrowserContext* browser_context,
|
||||
DCHECK(cc.get());
|
||||
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
*cc.get(), true /* secure_source */, true /* modify_http_only */,
|
||||
*cc.get(), url.scheme(), true /* modify_http_only */,
|
||||
base::BindOnce(
|
||||
[](bool* result, base::RunLoop* run_loop, bool success) {
|
||||
*result = success;
|
||||
|
@ -118,8 +118,8 @@ void GaiaAuthFetcherIOSNSURLSessionBridge::SetCanonicalCookiesFromResponse(
|
||||
for (NSHTTPCookie* cookie : cookies) {
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
net::CanonicalCookieFromSystemCookie(cookie, base::Time::Now()),
|
||||
/*secure_source=*/true,
|
||||
/*modify_http_only=*/true, base::DoNothing());
|
||||
base::SysNSStringToUTF8(response.URL.scheme), /*modify_http_only=*/true,
|
||||
base::DoNothing());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,8 +261,7 @@ void GaiaAuthFetcherIOSNSURLSessionBridgeTest::AddCookiesToCookieManager(
|
||||
for (NSHTTPCookie* cookie in cookies) {
|
||||
cookie_manager->SetCanonicalCookie(
|
||||
net::CanonicalCookieFromSystemCookie(cookie, base::Time::Now()),
|
||||
/*secure_source=*/true,
|
||||
/*modify_http_only=*/true, base::DoNothing());
|
||||
"https", /*modify_http_only=*/true, base::DoNothing());
|
||||
}
|
||||
WaitForBackgroundTasks();
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class CookieStoreIOS : public net::CookieStore,
|
||||
const net::CookieOptions& options,
|
||||
SetCookiesCallback callback) override;
|
||||
void SetCanonicalCookieAsync(std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) override;
|
||||
void GetCookieListWithOptionsAsync(const GURL& url,
|
||||
|
@ -340,7 +340,7 @@ void CookieStoreIOS::SetCookieWithOptionsAsync(
|
||||
|
||||
void CookieStoreIOS::SetCanonicalCookieAsync(
|
||||
std::unique_ptr<net::CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) {
|
||||
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
||||
@ -354,6 +354,9 @@ void CookieStoreIOS::SetCanonicalCookieAsync(
|
||||
// engine.
|
||||
DCHECK(modify_http_only);
|
||||
|
||||
bool secure_source =
|
||||
GURL::SchemeIsCryptographic(base::ToLowerASCII(source_scheme));
|
||||
|
||||
if (cookie->IsSecure() && !secure_source) {
|
||||
if (!callback.is_null())
|
||||
std::move(callback).Run(
|
||||
|
@ -47,7 +47,7 @@ class CookieStoreIOSPersistent : public CookieStoreIOS {
|
||||
const net::CookieOptions& options,
|
||||
SetCookiesCallback callback) override;
|
||||
void SetCanonicalCookieAsync(std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) override;
|
||||
void GetCookieListWithOptionsAsync(const GURL& url,
|
||||
|
@ -70,13 +70,13 @@ void CookieStoreIOSPersistent::SetCookieWithOptionsAsync(
|
||||
|
||||
void CookieStoreIOSPersistent::SetCanonicalCookieAsync(
|
||||
std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) {
|
||||
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
||||
|
||||
cookie_monster()->SetCanonicalCookieAsync(
|
||||
std::move(cookie), secure_source, modify_http_only,
|
||||
std::move(cookie), std::move(source_scheme), modify_http_only,
|
||||
WrapSetCallback(std::move(callback)));
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ void CookieMonster::SetAllCookiesAsync(const CookieList& list,
|
||||
|
||||
void CookieMonster::SetCanonicalCookieAsync(
|
||||
std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) {
|
||||
DCHECK(cookie->IsCanonical());
|
||||
@ -431,7 +431,7 @@ void CookieMonster::SetCanonicalCookieAsync(
|
||||
// the callback on |*this|, so the callback will not outlive
|
||||
// the object.
|
||||
&CookieMonster::SetCanonicalCookie, base::Unretained(this),
|
||||
std::move(cookie), secure_source, modify_http_only,
|
||||
std::move(cookie), std::move(source_scheme), modify_http_only,
|
||||
std::move(callback)),
|
||||
domain);
|
||||
}
|
||||
@ -728,8 +728,8 @@ void CookieMonster::SetCookieWithOptions(const GURL& url,
|
||||
}
|
||||
|
||||
DCHECK(cc);
|
||||
SetCanonicalCookie(std::move(cc), url.SchemeIsCryptographic(),
|
||||
!options.exclude_httponly(), std::move(callback));
|
||||
SetCanonicalCookie(std::move(cc), url.scheme(), !options.exclude_httponly(),
|
||||
std::move(callback));
|
||||
}
|
||||
|
||||
void CookieMonster::DeleteCanonicalCookie(const CanonicalCookie& cookie,
|
||||
@ -1202,11 +1202,13 @@ CookieMonster::CookieMap::iterator CookieMonster::InternalInsertCookie(
|
||||
}
|
||||
|
||||
void CookieMonster::SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) {
|
||||
DCHECK(thread_checker_.CalledOnValidThread());
|
||||
|
||||
std::string scheme_lower = base::ToLowerASCII(source_scheme);
|
||||
bool secure_source = GURL::SchemeIsCryptographic(scheme_lower);
|
||||
if ((cc->IsSecure() && !secure_source)) {
|
||||
MaybeRunCookieCallback(
|
||||
std::move(callback),
|
||||
@ -1221,6 +1223,13 @@ void CookieMonster::SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsCookieableScheme(scheme_lower)) {
|
||||
MaybeRunCookieCallback(
|
||||
std::move(callback),
|
||||
CanonicalCookie::CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME);
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string key(GetKey(cc->Domain()));
|
||||
|
||||
base::Time creation_date = cc->CreationDate();
|
||||
|
@ -161,7 +161,7 @@ class NET_EXPORT CookieMonster : public CookieStore {
|
||||
const CookieOptions& options,
|
||||
SetCookiesCallback callback) override;
|
||||
void SetCanonicalCookieAsync(std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) override;
|
||||
void GetCookieListWithOptionsAsync(const GURL& url,
|
||||
@ -364,7 +364,7 @@ class NET_EXPORT CookieMonster : public CookieStore {
|
||||
// |modify_http_only| indicates if this setting operation is allowed
|
||||
// to affect http_only cookies.
|
||||
void SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool can_modify_httponly,
|
||||
SetCookiesCallback callback);
|
||||
|
||||
|
@ -188,7 +188,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
cm->SetCanonicalCookieAsync(
|
||||
CanonicalCookie::Create(url, cookie_line, creation_time,
|
||||
CookieOptions()),
|
||||
url.SchemeIsCryptographic(), /* modify_httponly = */ false,
|
||||
url.scheme(), /* modify_httponly = */ false,
|
||||
base::BindOnce(&ResultSavingCookieCallback<
|
||||
CanonicalCookie::CookieInclusionStatus>::Run,
|
||||
base::Unretained(&callback)));
|
||||
@ -246,21 +246,21 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
"dom_1", "A", ".harvard.edu", "/", base::Time(), base::Time(),
|
||||
base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
|
||||
COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cm,
|
||||
std::make_unique<CanonicalCookie>(
|
||||
"dom_2", "B", ".math.harvard.edu", "/", base::Time(), base::Time(),
|
||||
base::Time(), false, false, CookieSameSite::DEFAULT_MODE,
|
||||
COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cm,
|
||||
std::make_unique<CanonicalCookie>(
|
||||
"dom_3", "C", ".bourbaki.math.harvard.edu", "/", base::Time(),
|
||||
base::Time(), base::Time(), false, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
|
||||
// Host cookies
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
@ -269,21 +269,21 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
"host_1", "A", url_top_level_domain_plus_1, "/", base::Time(),
|
||||
base::Time(), base::Time(), false, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cm,
|
||||
std::make_unique<CanonicalCookie>(
|
||||
"host_2", "B", url_top_level_domain_plus_2, "/", base::Time(),
|
||||
base::Time(), base::Time(), false, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cm,
|
||||
std::make_unique<CanonicalCookie>(
|
||||
"host_3", "C", url_top_level_domain_plus_3, "/", base::Time(),
|
||||
base::Time(), base::Time(), false, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
|
||||
// http_only cookie
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
@ -292,7 +292,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
"httpo_check", "A", url_top_level_domain_plus_2, "/", base::Time(),
|
||||
base::Time(), base::Time(), false, true,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
|
||||
// same-site cookie
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
@ -301,7 +301,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
"firstp_check", "A", url_top_level_domain_plus_2, "/", base::Time(),
|
||||
base::Time(), base::Time(), false, false,
|
||||
CookieSameSite::STRICT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
|
||||
// Secure cookies
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
@ -310,7 +310,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
"sec_dom", "A", ".math.harvard.edu", "/", base::Time(),
|
||||
base::Time(), base::Time(), true, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cm,
|
||||
@ -318,7 +318,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
"sec_host", "B", url_top_level_domain_plus_2, "/", base::Time(),
|
||||
base::Time(), base::Time(), true, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Domain path cookies
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
@ -327,14 +327,14 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
"dom_path_1", "A", ".math.harvard.edu", "/dir1", base::Time(),
|
||||
base::Time(), base::Time(), false, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cm,
|
||||
std::make_unique<CanonicalCookie>(
|
||||
"dom_path_2", "B", ".math.harvard.edu", "/dir1/dir2", base::Time(),
|
||||
base::Time(), base::Time(), false, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
|
||||
// Host path cookies
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
@ -343,7 +343,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
"host_path_1", "A", url_top_level_domain_plus_2, "/dir1",
|
||||
base::Time(), base::Time(), base::Time(), false, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cm,
|
||||
@ -351,7 +351,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
|
||||
"host_path_2", "B", url_top_level_domain_plus_2, "/dir1/dir2",
|
||||
base::Time(), base::Time(), base::Time(), false, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
|
||||
EXPECT_EQ(14U, this->GetAllCookies(cm).size());
|
||||
}
|
||||
@ -1556,16 +1556,42 @@ TEST_F(CookieMonsterTest, SetCookieableSchemes) {
|
||||
GURL foo_url("foo://host/path");
|
||||
GURL http_url("http://host/path");
|
||||
|
||||
base::Time now = base::Time::Now();
|
||||
EXPECT_EQ(CanonicalCookie::CookieInclusionStatus::INCLUDE,
|
||||
SetCookieReturnStatus(cm.get(), http_url, "x=1"));
|
||||
EXPECT_EQ(CanonicalCookie::CookieInclusionStatus::INCLUDE,
|
||||
SetCanonicalCookieReturnStatus(
|
||||
cm.get(),
|
||||
CanonicalCookie::Create(http_url, "y=1", now, CookieOptions()),
|
||||
"http", false /*modify_httponly*/));
|
||||
|
||||
EXPECT_EQ(
|
||||
CanonicalCookie::CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME,
|
||||
SetCookieReturnStatus(cm.get(), foo_url, "x=1"));
|
||||
EXPECT_EQ(
|
||||
CanonicalCookie::CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME,
|
||||
SetCanonicalCookieReturnStatus(
|
||||
cm.get(),
|
||||
CanonicalCookie::Create(foo_url, "y=1", now, CookieOptions()), "foo",
|
||||
false /*modify_httponly*/));
|
||||
|
||||
EXPECT_EQ(CanonicalCookie::CookieInclusionStatus::INCLUDE,
|
||||
SetCookieReturnStatus(cm_foo.get(), foo_url, "x=1"));
|
||||
EXPECT_EQ(CanonicalCookie::CookieInclusionStatus::INCLUDE,
|
||||
SetCanonicalCookieReturnStatus(
|
||||
cm_foo.get(),
|
||||
CanonicalCookie::Create(foo_url, "y=1", now, CookieOptions()),
|
||||
"foo", false /*modify_httponly*/));
|
||||
|
||||
EXPECT_EQ(
|
||||
CanonicalCookie::CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME,
|
||||
SetCookieReturnStatus(cm_foo.get(), http_url, "x=1"));
|
||||
EXPECT_EQ(
|
||||
CanonicalCookie::CookieInclusionStatus::EXCLUDE_NONCOOKIEABLE_SCHEME,
|
||||
SetCanonicalCookieReturnStatus(
|
||||
cm_foo.get(),
|
||||
CanonicalCookie::Create(http_url, "y=1", now, CookieOptions()),
|
||||
"http", false /*modify_httponly*/));
|
||||
}
|
||||
|
||||
TEST_F(CookieMonsterTest, GetAllCookiesForURL) {
|
||||
@ -2067,7 +2093,7 @@ TEST_F(CookieMonsterTest, BackingStoreCommunication) {
|
||||
cookie.name, cookie.value, cookie.domain, cookie.path,
|
||||
base::Time(), cookie.expiration_time, base::Time(), cookie.secure,
|
||||
cookie.http_only, cookie.same_site, cookie.priority),
|
||||
cookie.url.SchemeIsCryptographic(), true /*modify_httponly*/));
|
||||
cookie.url.scheme(), true /*modify_httponly*/));
|
||||
}
|
||||
|
||||
EXPECT_TRUE(FindAndDeleteCookie(cmout.get(),
|
||||
@ -2659,7 +2685,7 @@ TEST_F(CookieMonsterTest, HistogramCheck) {
|
||||
"a", "b", "a.url", "/", base::Time(),
|
||||
base::Time::Now() + base::TimeDelta::FromMinutes(59), base::Time(),
|
||||
false, false, CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
|
||||
std::unique_ptr<base::HistogramSamples> samples2(
|
||||
expired_histogram->SnapshotSamples());
|
||||
@ -3275,7 +3301,7 @@ TEST_F(CookieMonsterTest, SetCanonicalCookieDoesNotBlockForLoadAll) {
|
||||
cm.SetCanonicalCookieAsync(
|
||||
CanonicalCookie::Create(GURL("http://a.com/"), "A=B", base::Time::Now(),
|
||||
CookieOptions()),
|
||||
false /* secure_source */, false /* modify_httponly */,
|
||||
"http", false /* modify_httponly */,
|
||||
base::BindOnce(&ResultSavingCookieCallback<
|
||||
CanonicalCookie::CookieInclusionStatus>::Run,
|
||||
base::Unretained(&callback_set)));
|
||||
@ -3359,8 +3385,7 @@ TEST_F(CookieMonsterTest, DeleteCookieWithInheritedTimestamps) {
|
||||
ResultSavingCookieCallback<CanonicalCookie::CookieInclusionStatus>
|
||||
set_callback_1;
|
||||
cm.SetCanonicalCookieAsync(
|
||||
std::move(cookie), url.SchemeIsCryptographic(),
|
||||
!options.exclude_httponly(),
|
||||
std::move(cookie), url.scheme(), !options.exclude_httponly(),
|
||||
base::BindOnce(&ResultSavingCookieCallback<
|
||||
CanonicalCookie::CookieInclusionStatus>::Run,
|
||||
base::Unretained(&set_callback_1)));
|
||||
@ -3371,8 +3396,7 @@ TEST_F(CookieMonsterTest, DeleteCookieWithInheritedTimestamps) {
|
||||
ResultSavingCookieCallback<CanonicalCookie::CookieInclusionStatus>
|
||||
set_callback_2;
|
||||
cm.SetCanonicalCookieAsync(
|
||||
std::move(cookie), url.SchemeIsCryptographic(),
|
||||
!options.exclude_httponly(),
|
||||
std::move(cookie), url.scheme(), !options.exclude_httponly(),
|
||||
base::BindOnce(&ResultSavingCookieCallback<
|
||||
CanonicalCookie::CookieInclusionStatus>::Run,
|
||||
base::Unretained(&set_callback_2)));
|
||||
|
@ -65,13 +65,12 @@ class NET_EXPORT CookieStore {
|
||||
SetCookiesCallback callback) = 0;
|
||||
|
||||
// Set the cookie on the cookie store. |cookie.IsCanonical()| must
|
||||
// be true. |secure_source| indicates if the source of the setting
|
||||
// may be considered secure (if from a URL, the scheme is
|
||||
// cryptographic), and |modify_http_only| indicates if the source of
|
||||
// the setting may modify http_only cookies. The current time will
|
||||
// be used in place of a null creation time.
|
||||
// be true. |source_scheme| denotes the scheme of the resource setting this,
|
||||
// and |modify_http_only| indicates if the source of the setting may modify
|
||||
// http_only cookies. The current time will be used in place of a null
|
||||
// creation time.
|
||||
virtual void SetCanonicalCookieAsync(std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) = 0;
|
||||
|
||||
|
@ -106,12 +106,12 @@ void DelayedCookieMonster::SetCookieWithOptionsAsync(
|
||||
|
||||
void DelayedCookieMonster::SetCanonicalCookieAsync(
|
||||
std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) {
|
||||
did_run_ = false;
|
||||
cookie_monster_->SetCanonicalCookieAsync(
|
||||
std::move(cookie), secure_source, modify_http_only,
|
||||
std::move(cookie), std::move(source_scheme), modify_http_only,
|
||||
base::Bind(&DelayedCookieMonster::SetCookiesInternalCallback,
|
||||
base::Unretained(this)));
|
||||
DCHECK_EQ(did_run_, true);
|
||||
|
@ -58,7 +58,7 @@ class DelayedCookieMonster : public CookieStore {
|
||||
CookieMonster::SetCookiesCallback callback) override;
|
||||
|
||||
void SetCanonicalCookieAsync(std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCookiesCallback callback) override;
|
||||
|
||||
|
@ -211,12 +211,12 @@ class CookieStoreTest : public testing::Test {
|
||||
|
||||
bool SetCanonicalCookie(CookieStore* cs,
|
||||
std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool can_modify_httponly) {
|
||||
DCHECK(cs);
|
||||
ResultSavingCookieCallback<CanonicalCookie::CookieInclusionStatus> callback;
|
||||
cs->SetCanonicalCookieAsync(
|
||||
std::move(cookie), secure_source, can_modify_httponly,
|
||||
std::move(cookie), std::move(source_scheme), can_modify_httponly,
|
||||
base::BindOnce(&ResultSavingCookieCallback<
|
||||
CanonicalCookie::CookieInclusionStatus>::Run,
|
||||
base::Unretained(&callback)));
|
||||
@ -266,12 +266,12 @@ class CookieStoreTest : public testing::Test {
|
||||
CanonicalCookie::CookieInclusionStatus SetCanonicalCookieReturnStatus(
|
||||
CookieStore* cs,
|
||||
std::unique_ptr<CanonicalCookie> cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool can_modify_httponly) {
|
||||
DCHECK(cs);
|
||||
ResultSavingCookieCallback<CanonicalCookie::CookieInclusionStatus> callback;
|
||||
cs->SetCanonicalCookieAsync(
|
||||
std::move(cookie), secure_source, can_modify_httponly,
|
||||
std::move(cookie), std::move(source_scheme), can_modify_httponly,
|
||||
base::BindOnce(&ResultSavingCookieCallback<
|
||||
CanonicalCookie::CookieInclusionStatus>::Run,
|
||||
base::Unretained(&callback)));
|
||||
@ -420,8 +420,8 @@ TYPED_TEST_P(CookieStoreTest, FilterTest) {
|
||||
one_hour_from_now, base::Time(), false, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT));
|
||||
ASSERT_TRUE(cc);
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cs, std::move(cc), true /*secure_source*/, true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(cs, std::move(cc), "https",
|
||||
true /*modify_httponly*/));
|
||||
|
||||
// Note that for the creation time to be set exactly, without modification,
|
||||
// it must be different from the one set by the line above.
|
||||
@ -430,8 +430,8 @@ TYPED_TEST_P(CookieStoreTest, FilterTest) {
|
||||
two_hours_ago, base::Time(), one_hour_ago, false, true,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT);
|
||||
ASSERT_TRUE(cc);
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cs, std::move(cc), true /*secure_source*/, true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(cs, std::move(cc), "https",
|
||||
true /*modify_httponly*/));
|
||||
|
||||
// Because of strict secure cookies, it should not be possible to create
|
||||
// a secure cookie with an HTTP URL.
|
||||
@ -447,8 +447,8 @@ TYPED_TEST_P(CookieStoreTest, FilterTest) {
|
||||
base::Time(), base::Time(), base::Time(), true, false,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT);
|
||||
ASSERT_TRUE(cc);
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cs, std::move(cc), true /*secure_source*/, true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(cs, std::move(cc), "https",
|
||||
true /*modify_httponly*/));
|
||||
|
||||
// Get all the cookies for a given URL, regardless of properties. This 'get()'
|
||||
// operation shouldn't update the access time, as the test checks that the
|
||||
@ -552,7 +552,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
|
||||
"A", "B", foo_foo_host, "/foo", one_hour_ago, one_hour_from_now,
|
||||
base::Time(), false /* secure */, false /* httponly */,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /* secure_source */, true));
|
||||
"http", true));
|
||||
// Note that for the creation time to be set exactly, without modification,
|
||||
// it must be different from the one set by the line above.
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
@ -561,7 +561,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
|
||||
"C", "D", "." + foo_bar_domain, "/bar", two_hours_ago, base::Time(),
|
||||
one_hour_ago, false, true, CookieSameSite::DEFAULT_MODE,
|
||||
COOKIE_PRIORITY_DEFAULT),
|
||||
false /* secure_source */, true));
|
||||
"http", true));
|
||||
|
||||
// A secure source is required for creating secure cookies.
|
||||
EXPECT_EQ(CanonicalCookie::CookieInclusionStatus::EXCLUDE_SECURE_ONLY,
|
||||
@ -571,7 +571,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
|
||||
"E", "F", http_foo_host, "/", base::Time(), base::Time(),
|
||||
base::Time(), true, false, CookieSameSite::DEFAULT_MODE,
|
||||
COOKIE_PRIORITY_DEFAULT),
|
||||
false /* secure_source */, true));
|
||||
"http", true));
|
||||
|
||||
// A secure source is also required for overwriting secure cookies. Writing
|
||||
// a secure cookie then overwriting it from a non-secure source should fail.
|
||||
@ -581,7 +581,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
|
||||
"E", "F", http_foo_host, "/", base::Time(), base::Time(),
|
||||
base::Time(), true /* secure */, false /* httponly */,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
true /* secure_source */, true /* modify_http_only */));
|
||||
"https", true /* modify_http_only */));
|
||||
|
||||
EXPECT_EQ(CanonicalCookie::CookieInclusionStatus::EXCLUDE_SECURE_ONLY,
|
||||
this->SetCanonicalCookieReturnStatus(
|
||||
@ -590,7 +590,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
|
||||
"E", "F", http_foo_host, "/", base::Time(), base::Time(),
|
||||
base::Time(), true /* secure */, false /* httponly */,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /* secure_source */, true /* modify_http_only */));
|
||||
"http", true /* modify_http_only */));
|
||||
|
||||
if (TypeParam::supports_http_only) {
|
||||
// Permission to modify http only cookies is required to create an
|
||||
@ -603,7 +603,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
|
||||
"G", "H", http_foo_host, "/unique", base::Time(), base::Time(),
|
||||
base::Time(), false /* secure */, true /* httponly */,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /* secure_source */, false /* modify_http_only */));
|
||||
"http", false /* modify_http_only */));
|
||||
|
||||
// Permission to modify httponly cookies is also required to overwrite
|
||||
// an httponly cookie.
|
||||
@ -613,7 +613,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
|
||||
"G", "H", http_foo_host, "/unique", base::Time(), base::Time(),
|
||||
base::Time(), false /* secure */, true /* httponly */,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /* secure_source */, true /* modify_http_only */));
|
||||
"http", true /* modify_http_only */));
|
||||
|
||||
EXPECT_EQ(
|
||||
CanonicalCookie::CookieInclusionStatus::EXCLUDE_HTTP_ONLY,
|
||||
@ -623,7 +623,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
|
||||
"G", "H", http_foo_host, "/unique", base::Time(), base::Time(),
|
||||
base::Time(), false /* secure */, true /* httponly */,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /* secure_source */, false /* modify_http_only */));
|
||||
"http", false /* modify_http_only */));
|
||||
} else {
|
||||
// Leave store in same state as if the above tests had been run.
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
@ -632,7 +632,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) {
|
||||
"G", "H", http_foo_host, "/unique", base::Time(), base::Time(),
|
||||
base::Time(), false /* secure */, true /* httponly */,
|
||||
CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT),
|
||||
false /* secure_source */, true /* modify_http_only */));
|
||||
"http", true /* modify_http_only */));
|
||||
}
|
||||
|
||||
// Get all the cookies for a given URL, regardless of properties. This 'get()'
|
||||
@ -719,28 +719,28 @@ TYPED_TEST_P(CookieStoreTest, SecureEnforcement) {
|
||||
"A", "B", http_domain, "/", base::Time::Now(), base::Time(),
|
||||
base::Time(), true, false, CookieSameSite::NO_RESTRICTION,
|
||||
COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cs,
|
||||
std::make_unique<CanonicalCookie>(
|
||||
"A", "B", http_domain, "/", base::Time::Now(), base::Time(),
|
||||
base::Time(), true, false, CookieSameSite::NO_RESTRICTION,
|
||||
COOKIE_PRIORITY_DEFAULT),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cs,
|
||||
std::make_unique<CanonicalCookie>(
|
||||
"A", "B", http_domain, "/", base::Time::Now(), base::Time(),
|
||||
base::Time(), false, false, CookieSameSite::NO_RESTRICTION,
|
||||
COOKIE_PRIORITY_DEFAULT),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
EXPECT_TRUE(this->SetCanonicalCookie(
|
||||
cs,
|
||||
std::make_unique<CanonicalCookie>(
|
||||
"A", "B", http_domain, "/", base::Time::Now(), base::Time(),
|
||||
base::Time(), false, false, CookieSameSite::NO_RESTRICTION,
|
||||
COOKIE_PRIORITY_DEFAULT),
|
||||
false /*secure_source*/, true /*modify_httponly*/));
|
||||
"http", true /*modify_httponly*/));
|
||||
}
|
||||
|
||||
// The iOS networking stack uses the iOS cookie parser, which we do not
|
||||
|
@ -135,11 +135,11 @@ void CookieManager::GetCookieList(const GURL& url,
|
||||
}
|
||||
|
||||
void CookieManager::SetCanonicalCookie(const net::CanonicalCookie& cookie,
|
||||
bool secure_source,
|
||||
const std::string& source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCanonicalCookieCallback callback) {
|
||||
cookie_store_->SetCanonicalCookieAsync(
|
||||
std::make_unique<net::CanonicalCookie>(cookie), secure_source,
|
||||
std::make_unique<net::CanonicalCookie>(cookie), source_scheme,
|
||||
modify_http_only, StatusToBool(std::move(callback)));
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CookieManager
|
||||
const net::CookieOptions& cookie_options,
|
||||
GetCookieListCallback callback) override;
|
||||
void SetCanonicalCookie(const net::CanonicalCookie& cookie,
|
||||
bool secure_source,
|
||||
const std::string& source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCanonicalCookieCallback callback) override;
|
||||
void DeleteCanonicalCookie(const net::CanonicalCookie& cookie,
|
||||
|
@ -92,12 +92,12 @@ class SynchronousCookieManager {
|
||||
}
|
||||
|
||||
bool SetCanonicalCookie(const net::CanonicalCookie& cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool modify_http_only) {
|
||||
base::RunLoop run_loop;
|
||||
bool result = false;
|
||||
cookie_service_->SetCanonicalCookie(
|
||||
cookie, secure_source, modify_http_only,
|
||||
cookie, std::move(source_scheme), modify_http_only,
|
||||
base::BindOnce(&SynchronousCookieManager::SetCookieCallback, &run_loop,
|
||||
&result));
|
||||
run_loop.Run();
|
||||
@ -181,13 +181,13 @@ class CookieManagerTest : public testing::Test {
|
||||
|
||||
// Set a canonical cookie directly into the store.
|
||||
bool SetCanonicalCookie(const net::CanonicalCookie& cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool can_modify_httponly) {
|
||||
net::ResultSavingCookieCallback<net::CanonicalCookie::CookieInclusionStatus>
|
||||
callback;
|
||||
cookie_monster_->SetCanonicalCookieAsync(
|
||||
std::make_unique<net::CanonicalCookie>(cookie), secure_source,
|
||||
can_modify_httponly,
|
||||
std::make_unique<net::CanonicalCookie>(cookie),
|
||||
std::move(source_scheme), can_modify_httponly,
|
||||
base::BindOnce(&net::ResultSavingCookieCallback<
|
||||
net::CanonicalCookie::CookieInclusionStatus>::Run,
|
||||
base::Unretained(&callback)));
|
||||
@ -289,27 +289,27 @@ TEST_F(CookieManagerTest, GetAllCookies) {
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"C", "D", "foo_host2", "/with/path", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"Secure", "E", kCookieDomain, "/with/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/true,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"HttpOnly", "F", kCookieDomain, "/with/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/true, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
base::Time after_creation(base::Time::Now());
|
||||
|
||||
@ -384,27 +384,27 @@ TEST_F(CookieManagerTest, GetCookieList) {
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"C", "D", "foo_host2", "/with/path", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"Secure", "E", kCookieDomain, "/with/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/true,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"HttpOnly", "F", kCookieDomain, "/with/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/true, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
std::vector<net::CanonicalCookie> cookies = service_wrapper()->GetCookieList(
|
||||
GURL("https://foo_host.com/with/path"), net::CookieOptions());
|
||||
@ -428,7 +428,7 @@ TEST_F(CookieManagerTest, GetCookieListHttpOnly) {
|
||||
/*secure=*/false, /*httponly=*/true,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
ASSERT_TRUE(result);
|
||||
result = SetCanonicalCookie(
|
||||
net::CanonicalCookie("C", "D", kCookieDomain, "/", base::Time(),
|
||||
@ -436,7 +436,7 @@ TEST_F(CookieManagerTest, GetCookieListHttpOnly) {
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
// Retrieve without httponly cookies (default)
|
||||
@ -467,21 +467,21 @@ TEST_F(CookieManagerTest, GetCookieListSameSite) {
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
ASSERT_TRUE(result);
|
||||
result = SetCanonicalCookie(
|
||||
net::CanonicalCookie("C", "D", kCookieDomain, "/", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::LAX_MODE,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
ASSERT_TRUE(result);
|
||||
result = SetCanonicalCookie(
|
||||
net::CanonicalCookie("E", "F", kCookieDomain, "/", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::STRICT_MODE,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
// Retrieve only unrestricted cookies.
|
||||
@ -522,7 +522,7 @@ TEST_F(CookieManagerTest, GetCookieListAccessTime) {
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
// Get the cookie without updating the access time and check
|
||||
@ -554,7 +554,7 @@ TEST_F(CookieManagerTest, DeleteCanonicalCookie) {
|
||||
"A", "B", "foo_host", "/", base::Time(), base::Time(), base::Time(),
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
std::vector<net::CanonicalCookie> cookies =
|
||||
service_wrapper()->GetAllCookies();
|
||||
ASSERT_EQ(1U, cookies.size());
|
||||
@ -570,27 +570,27 @@ TEST_F(CookieManagerTest, DeleteThroughSet) {
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"C", "D", "foo_host2", "/with/path", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"Secure", "E", kCookieDomain, "/with/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/true,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"HttpOnly", "F", kCookieDomain, "/with/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/true, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
base::Time yesterday = base::Time::Now() - base::TimeDelta::FromDays(1);
|
||||
EXPECT_TRUE(service_wrapper()->SetCanonicalCookie(
|
||||
@ -598,7 +598,7 @@ TEST_F(CookieManagerTest, DeleteThroughSet) {
|
||||
"A", "E", kCookieDomain, "/", base::Time(), yesterday, base::Time(),
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
false, false));
|
||||
"http", false));
|
||||
|
||||
std::vector<net::CanonicalCookie> cookies =
|
||||
service_wrapper()->GetAllCookies();
|
||||
@ -623,7 +623,7 @@ TEST_F(CookieManagerTest, ConfirmSecureSetFails) {
|
||||
/*secure=*/true, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
false, false));
|
||||
"http", false));
|
||||
std::vector<net::CanonicalCookie> cookies =
|
||||
service_wrapper()->GetAllCookies();
|
||||
|
||||
@ -637,7 +637,7 @@ TEST_F(CookieManagerTest, ConfirmHttpOnlySetFails) {
|
||||
/*secure=*/false, /*httponly=*/true,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
false, false));
|
||||
"http", false));
|
||||
std::vector<net::CanonicalCookie> cookies =
|
||||
service_wrapper()->GetAllCookies();
|
||||
|
||||
@ -651,7 +651,7 @@ TEST_F(CookieManagerTest, ConfirmHttpOnlyOverwriteFails) {
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/true, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_FALSE(service_wrapper()->SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
@ -659,7 +659,7 @@ TEST_F(CookieManagerTest, ConfirmHttpOnlyOverwriteFails) {
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/true, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
false, false));
|
||||
"http", false));
|
||||
|
||||
std::vector<net::CanonicalCookie> cookies =
|
||||
service_wrapper()->GetAllCookies();
|
||||
@ -677,27 +677,27 @@ TEST_F(CookieManagerTest, DeleteEverything) {
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"C", "D", "foo_host2", "/with/path", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"Secure", "E", kCookieDomain, "/with/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/true,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"HttpOnly", "F", kCookieDomain, "/with/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/true, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
EXPECT_EQ(4u, service_wrapper()->DeleteCookies(filter));
|
||||
@ -717,7 +717,7 @@ TEST_F(CookieManagerTest, DeleteByTime) {
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
@ -725,7 +725,7 @@ TEST_F(CookieManagerTest, DeleteByTime) {
|
||||
now - base::TimeDelta::FromMinutes(120), base::Time(), base::Time(),
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
@ -733,7 +733,7 @@ TEST_F(CookieManagerTest, DeleteByTime) {
|
||||
now - base::TimeDelta::FromMinutes(180), base::Time(), base::Time(),
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.created_after_time = now - base::TimeDelta::FromMinutes(150);
|
||||
@ -754,21 +754,21 @@ TEST_F(CookieManagerTest, DeleteByExcludingDomains) {
|
||||
"A1", "val", "foo_host1", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A2", "val", "foo_host2", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A3", "val", "foo_host3", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.excluding_domains = std::vector<std::string>();
|
||||
@ -787,21 +787,21 @@ TEST_F(CookieManagerTest, DeleteByIncludingDomains) {
|
||||
"A1", "val", "foo_host1", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A2", "val", "foo_host2", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A3", "val", "foo_host3", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.including_domains = std::vector<std::string>();
|
||||
@ -822,19 +822,19 @@ TEST_F(CookieManagerTest, DeleteDetails_eTLD) {
|
||||
"A1", "val", "example.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A2", "val", "www.example.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A3", "val", "www.nonexample.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.including_domains = std::vector<std::string>();
|
||||
@ -853,19 +853,19 @@ TEST_F(CookieManagerTest, DeleteDetails_eTLD) {
|
||||
"A1", "val", "example.co.uk", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A2", "val", "www.example.co.uk", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A3", "val", "www.nonexample.co.uk", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
filter.including_domains = std::vector<std::string>();
|
||||
filter.including_domains->push_back("example.co.uk");
|
||||
EXPECT_EQ(2u, service_wrapper()->DeleteCookies(filter));
|
||||
@ -882,19 +882,19 @@ TEST_F(CookieManagerTest, DeleteDetails_eTLD) {
|
||||
"A1", "val", "example.co.uk", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A2", "val", "www.example.co.uk", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A3", "val", "www.nonexample.co.uk", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
filter.including_domains = std::vector<std::string>();
|
||||
filter.including_domains->push_back("co.uk");
|
||||
EXPECT_EQ(0u, service_wrapper()->DeleteCookies(filter));
|
||||
@ -915,25 +915,25 @@ TEST_F(CookieManagerTest, DeleteDetails_HostDomain) {
|
||||
"A1", "val", "foo_host.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A2", "val", ".foo_host.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A3", "val", "bar.host.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A4", "val", ".bar.host.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.including_domains = std::vector<std::string>();
|
||||
@ -953,31 +953,31 @@ TEST_F(CookieManagerTest, DeleteDetails_eTLDvsPrivateRegistry) {
|
||||
"A1", "val", "random.co.uk", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A2", "val", "sub.domain.random.co.uk", "/", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A3", "val", "random.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A4", "val", "random", "/", base::Time(), base::Time(), base::Time(),
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A5", "val", "normal.co.uk", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.including_domains = std::vector<std::string>();
|
||||
@ -998,7 +998,7 @@ TEST_F(CookieManagerTest, DeleteDetails_PrivateRegistry) {
|
||||
"A1", "val", "privatedomain", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
@ -1007,7 +1007,7 @@ TEST_F(CookieManagerTest, DeleteDetails_PrivateRegistry) {
|
||||
"A2", "val", "privatedomain.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
@ -1016,7 +1016,7 @@ TEST_F(CookieManagerTest, DeleteDetails_PrivateRegistry) {
|
||||
"A3", "val", "subdomain.privatedomain", "/", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.including_domains = std::vector<std::string>();
|
||||
@ -1050,13 +1050,13 @@ TEST_F(CookieManagerTest, DeleteDetails_IgnoredFields) {
|
||||
"A01", "RandomValue", "example.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A02", "RandomValue", "canonical.com", "/", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Path
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1064,13 +1064,13 @@ TEST_F(CookieManagerTest, DeleteDetails_IgnoredFields) {
|
||||
"A03", "val", "example.com", "/this/is/a/long/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A04", "val", "canonical.com", "/this/is/a/long/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Last_access
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1080,7 +1080,7 @@ TEST_F(CookieManagerTest, DeleteDetails_IgnoredFields) {
|
||||
base::Time::Now() - base::TimeDelta::FromDays(3), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A06", "val", "canonical.com", "/",
|
||||
@ -1088,7 +1088,7 @@ TEST_F(CookieManagerTest, DeleteDetails_IgnoredFields) {
|
||||
base::Time::Now() - base::TimeDelta::FromDays(3), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Same_site
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1096,13 +1096,13 @@ TEST_F(CookieManagerTest, DeleteDetails_IgnoredFields) {
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::STRICT_MODE,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie("A08", "val", "canonical.com", "/", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::STRICT_MODE,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Priority
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1110,13 +1110,13 @@ TEST_F(CookieManagerTest, DeleteDetails_IgnoredFields) {
|
||||
"A09", "val", "example.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_HIGH),
|
||||
true, true));
|
||||
"https", true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A10", "val", "canonical.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_HIGH),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Use the filter and make sure the result is the expected set.
|
||||
EXPECT_EQ(5u, service_wrapper()->DeleteCookies(filter));
|
||||
@ -1210,7 +1210,7 @@ TEST_F(CookieManagerTest, DeleteDetails_Consumer) {
|
||||
"A1", "val", test_cases[i].domain, test_cases[i].path, base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
if (!exclude_domain_cookie) {
|
||||
// Host cookie
|
||||
@ -1220,7 +1220,7 @@ TEST_F(CookieManagerTest, DeleteDetails_Consumer) {
|
||||
base::Time(), base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
}
|
||||
|
||||
// Httponly cookie
|
||||
@ -1229,7 +1229,7 @@ TEST_F(CookieManagerTest, DeleteDetails_Consumer) {
|
||||
"A3", "val", test_cases[i].domain, test_cases[i].path, base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/true,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Httponly and secure cookie
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1237,7 +1237,7 @@ TEST_F(CookieManagerTest, DeleteDetails_Consumer) {
|
||||
"A4", "val", test_cases[i].domain, test_cases[i].path, base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/true,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
const uint32_t number_cookies = exclude_domain_cookie ? 3u : 4u;
|
||||
EXPECT_EQ(number_cookies, service_wrapper()->GetAllCookies().size());
|
||||
@ -1258,28 +1258,28 @@ TEST_F(CookieManagerTest, DeleteByName) {
|
||||
"A1", "val", kCookieDomain, "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A1", "val", "bar_host", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A2", "val", kCookieDomain, "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A3", "val", "bar_host", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.cookie_name = std::string("A1");
|
||||
@ -1302,7 +1302,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A01", "val", "www.example.com", "/path", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/true, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Cookie that should not be deleted because it's a host cookie in a
|
||||
// subdomain that doesn't exactly match the passed URL.
|
||||
@ -1311,7 +1311,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A02", "val", "sub.www.example.com", "/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Cookie that shouldn't be deleted because the path doesn't match.
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1319,7 +1319,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A03", "val", "www.example.com", "/otherpath", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Cookie that shouldn't be deleted because the path is more specific
|
||||
// than the URL.
|
||||
@ -1328,7 +1328,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A04", "val", "www.example.com", "/path/path2", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Cookie that shouldn't be deleted because it's at a host cookie domain that
|
||||
// doesn't exactly match the url's host.
|
||||
@ -1337,7 +1337,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A05", "val", "example.com", "/path", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Cookie that should not be deleted because it's not a host cookie and
|
||||
// has a domain that's more specific than the URL
|
||||
@ -1346,7 +1346,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A06", "val", ".sub.www.example.com", "/path", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Cookie that should be deleted because it's not a host cookie and has a
|
||||
// domain that matches the URL
|
||||
@ -1355,7 +1355,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A07", "val", ".www.example.com", "/path", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Cookie that should be deleted because it's not a host cookie and has a
|
||||
// domain that domain matches the URL.
|
||||
@ -1364,7 +1364,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A08", "val", ".example.com", "/path", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Cookie that should be deleted because it matches exactly.
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1372,7 +1372,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A09", "val", "www.example.com", "/path", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
// Cookie that should be deleted because it applies to a larger set
|
||||
// of paths than the URL path.
|
||||
@ -1381,7 +1381,7 @@ TEST_F(CookieManagerTest, DeleteByURL) {
|
||||
"A10", "val", "www.example.com", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true /*secure_source*/, true /*modify_httponly*/));
|
||||
"https", true /*modify_httponly*/));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.url = filter_url;
|
||||
@ -1408,7 +1408,7 @@ TEST_F(CookieManagerTest, DeleteBySessionStatus) {
|
||||
"A1", "val", kCookieDomain, "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie("A2", "val", kCookieDomain, "/", base::Time(),
|
||||
@ -1416,14 +1416,14 @@ TEST_F(CookieManagerTest, DeleteBySessionStatus) {
|
||||
/*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
net::CanonicalCookie(
|
||||
"A3", "val", kCookieDomain, "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
mojom::CookieDeletionFilter filter;
|
||||
filter.session_control =
|
||||
@ -1476,7 +1476,7 @@ TEST_F(CookieManagerTest, DeleteByAll) {
|
||||
now + base::TimeDelta::FromDays(3), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Too old cookie.
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1485,7 +1485,7 @@ TEST_F(CookieManagerTest, DeleteByAll) {
|
||||
now + base::TimeDelta::FromDays(3), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Too young cookie.
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1494,7 +1494,7 @@ TEST_F(CookieManagerTest, DeleteByAll) {
|
||||
now + base::TimeDelta::FromDays(3), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Not in domains_and_ips_to_delete.
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1504,7 +1504,7 @@ TEST_F(CookieManagerTest, DeleteByAll) {
|
||||
now + base::TimeDelta::FromDays(3), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// In domains_and_ips_to_ignore.
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1513,7 +1513,7 @@ TEST_F(CookieManagerTest, DeleteByAll) {
|
||||
now + base::TimeDelta::FromDays(3), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Doesn't match URL (by path).
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1523,7 +1523,7 @@ TEST_F(CookieManagerTest, DeleteByAll) {
|
||||
now + base::TimeDelta::FromDays(3), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
// Session
|
||||
EXPECT_TRUE(SetCanonicalCookie(
|
||||
@ -1531,7 +1531,7 @@ TEST_F(CookieManagerTest, DeleteByAll) {
|
||||
"A7", "val7", "nope.com", "/path", now - base::TimeDelta::FromDays(3),
|
||||
base::Time(), base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_EQ(1u, service_wrapper()->DeleteCookies(filter));
|
||||
std::vector<net::CanonicalCookie> cookies =
|
||||
@ -1619,7 +1619,7 @@ TEST_F(CookieManagerTest, AddCookieChangeListener) {
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(0u, listener.observed_changes().size());
|
||||
|
||||
@ -1631,7 +1631,7 @@ TEST_F(CookieManagerTest, AddCookieChangeListener) {
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(0u, listener.observed_changes().size());
|
||||
@ -1643,7 +1643,7 @@ TEST_F(CookieManagerTest, AddCookieChangeListener) {
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
|
||||
// Expect asynchrony
|
||||
EXPECT_EQ(0u, listener.observed_changes().size());
|
||||
@ -1699,7 +1699,7 @@ TEST_F(CookieManagerTest, AddGlobalChangeListener) {
|
||||
/*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
|
||||
// Expect asynchrony
|
||||
EXPECT_EQ(0u, listener.observed_changes().size());
|
||||
@ -1723,14 +1723,14 @@ TEST_F(CookieManagerTest, AddGlobalChangeListener) {
|
||||
/*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
service_wrapper()->SetCanonicalCookie(
|
||||
net::CanonicalCookie("Thing2", "val", kThatHost, "/", base::Time(),
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
|
||||
base::RunLoop().RunUntilIdle();
|
||||
observed_changes = listener.observed_changes();
|
||||
@ -1788,7 +1788,7 @@ TEST_F(CookieManagerTest, ListenerDestroyed) {
|
||||
base::Time(), base::Time(), /*secure=*/false,
|
||||
/*httponly=*/false, net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true);
|
||||
"https", true);
|
||||
|
||||
EXPECT_EQ(0u, listener1->observed_changes().size());
|
||||
EXPECT_EQ(0u, listener2->observed_changes().size());
|
||||
@ -1840,7 +1840,7 @@ TEST_F(CookieManagerTest, CloningAndClientDestructVisible) {
|
||||
"X", "Y", "www.other.host", "/", base::Time(), base::Time(),
|
||||
base::Time(), /*secure=*/false, /*httponly=*/false,
|
||||
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_MEDIUM),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
std::vector<net::CanonicalCookie> cookies = service_wrapper()->GetCookieList(
|
||||
GURL("http://www.other.host/"), net::CookieOptions());
|
||||
@ -2015,7 +2015,7 @@ class SessionCleanupCookieManagerTest : public CookieManagerTest {
|
||||
};
|
||||
|
||||
TEST_F(SessionCleanupCookieManagerTest, PersistSessionCookies) {
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), true, true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), "https", true));
|
||||
|
||||
EXPECT_EQ(1u, service_wrapper()->GetAllCookies().size());
|
||||
|
||||
@ -2027,7 +2027,7 @@ TEST_F(SessionCleanupCookieManagerTest, PersistSessionCookies) {
|
||||
}
|
||||
|
||||
TEST_F(SessionCleanupCookieManagerTest, DeleteSessionCookies) {
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), true, true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), "https", true));
|
||||
|
||||
EXPECT_EQ(1u, service_wrapper()->GetAllCookies().size());
|
||||
|
||||
@ -2042,7 +2042,7 @@ TEST_F(SessionCleanupCookieManagerTest, DeleteSessionCookies) {
|
||||
}
|
||||
|
||||
TEST_F(SessionCleanupCookieManagerTest, SettingMustMatchDomain) {
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), true, true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), "https", true));
|
||||
|
||||
EXPECT_EQ(1u, service_wrapper()->GetAllCookies().size());
|
||||
|
||||
@ -2057,7 +2057,7 @@ TEST_F(SessionCleanupCookieManagerTest, SettingMustMatchDomain) {
|
||||
}
|
||||
|
||||
TEST_F(SessionCleanupCookieManagerTest, FirstSettingTakesPrecedence) {
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), true, true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), "https", true));
|
||||
|
||||
EXPECT_EQ(1u, service_wrapper()->GetAllCookies().size());
|
||||
|
||||
@ -2075,7 +2075,7 @@ TEST_F(SessionCleanupCookieManagerTest, FirstSettingTakesPrecedence) {
|
||||
}
|
||||
|
||||
TEST_F(SessionCleanupCookieManagerTest, ForceKeepSessionState) {
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), true, true));
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(), "https", true));
|
||||
|
||||
EXPECT_EQ(1u, service_wrapper()->GetAllCookies().size());
|
||||
|
||||
@ -2092,7 +2092,7 @@ TEST_F(SessionCleanupCookieManagerTest, ForceKeepSessionState) {
|
||||
|
||||
TEST_F(SessionCleanupCookieManagerTest, HttpCookieAllowedOnHttps) {
|
||||
EXPECT_TRUE(SetCanonicalCookie(CreateCookie(StrCat({"www.", kCookieDomain})),
|
||||
true, true));
|
||||
"https", true));
|
||||
|
||||
EXPECT_EQ(1u, service_wrapper()->GetAllCookies().size());
|
||||
|
||||
|
@ -2037,7 +2037,7 @@ TEST_F(NetworkContextTest, CookieManager) {
|
||||
base::Time(), base::Time(), false, false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_LOW),
|
||||
true, true, base::BindOnce(&SetCookieCallback, &run_loop1, &result));
|
||||
"https", true, base::BindOnce(&SetCookieCallback, &run_loop1, &result));
|
||||
run_loop1.Run();
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
|
@ -181,12 +181,13 @@ interface CookieManager {
|
||||
GetCookieList(url.mojom.Url url, CookieOptions cookie_options) =>
|
||||
(array<CanonicalCookie> cookies);
|
||||
|
||||
// Set a cookie. |secure_source| indicates whether existing secure
|
||||
// Set a cookie. |source_scheme| is used to check whether existing secure
|
||||
// cookies can be overwritten (secure cookies may be created from a
|
||||
// non-secure source). |modify_http_only| indicates whether http_only
|
||||
// non-secure source), and whether the scheme is permitted to use cookies in
|
||||
// the first place. |modify_http_only| indicates whether http_only
|
||||
// cookies may be overwritten.
|
||||
SetCanonicalCookie(
|
||||
CanonicalCookie cookie, bool secure_source, bool modify_http_only) =>
|
||||
CanonicalCookie cookie, string source_scheme, bool modify_http_only) =>
|
||||
(bool success);
|
||||
|
||||
// Delete a cookie. Returns true if a cookie was deleted.
|
||||
|
@ -219,12 +219,10 @@ void RestrictedCookieManager::SetCanonicalCookie(
|
||||
cookie.ExpiryDate(), now, cookie.IsSecure(), cookie.IsHttpOnly(),
|
||||
cookie.SameSite(), cookie.Priority());
|
||||
|
||||
// TODO(pwnall): secure_source should depend on url, and might depend on the
|
||||
// renderer.
|
||||
bool secure_source = true;
|
||||
// TODO(pwnall): source_scheme might depend on the renderer.
|
||||
bool modify_http_only = false;
|
||||
cookie_store_->SetCanonicalCookieAsync(std::move(sanitized_cookie),
|
||||
secure_source, modify_http_only,
|
||||
origin_.scheme(), modify_http_only,
|
||||
StatusToBool(std::move(callback)));
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,13 @@ class RestrictedCookieManagerTest : public testing::Test {
|
||||
|
||||
// Set a canonical cookie directly into the store.
|
||||
bool SetCanonicalCookie(const net::CanonicalCookie& cookie,
|
||||
bool secure_source,
|
||||
std::string source_scheme,
|
||||
bool can_modify_httponly) {
|
||||
net::ResultSavingCookieCallback<net::CanonicalCookie::CookieInclusionStatus>
|
||||
callback;
|
||||
cookie_monster_.SetCanonicalCookieAsync(
|
||||
std::make_unique<net::CanonicalCookie>(cookie), secure_source,
|
||||
can_modify_httponly,
|
||||
std::make_unique<net::CanonicalCookie>(cookie),
|
||||
std::move(source_scheme), can_modify_httponly,
|
||||
base::BindOnce(&net::ResultSavingCookieCallback<
|
||||
net::CanonicalCookie::CookieInclusionStatus>::Run,
|
||||
base::Unretained(&callback)));
|
||||
@ -134,7 +134,7 @@ class RestrictedCookieManagerTest : public testing::Test {
|
||||
/* httponly = */ false,
|
||||
net::CookieSameSite::NO_RESTRICTION,
|
||||
net::COOKIE_PRIORITY_DEFAULT),
|
||||
/* secure_source = */ true, /* can_modify_httponly = */ true));
|
||||
"https", /* can_modify_httponly = */ true));
|
||||
}
|
||||
|
||||
void ExpectBadMessage() { expecting_bad_message_ = true; }
|
||||
|
@ -14,7 +14,7 @@ TestCookieManager::~TestCookieManager() = default;
|
||||
|
||||
void TestCookieManager::SetCanonicalCookie(
|
||||
const net::CanonicalCookie& cookie,
|
||||
bool secure_source,
|
||||
const std::string& source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCanonicalCookieCallback callback) {
|
||||
std::move(callback).Run(false);
|
||||
|
@ -22,7 +22,7 @@ class TestCookieManager : public network::mojom::CookieManager {
|
||||
~TestCookieManager() override;
|
||||
|
||||
void SetCanonicalCookie(const net::CanonicalCookie& cookie,
|
||||
bool secure_source,
|
||||
const std::string& source_scheme,
|
||||
bool modify_http_only,
|
||||
SetCanonicalCookieCallback callback) override;
|
||||
void GetAllCookies(GetAllCookiesCallback callback) override {}
|
||||
|
14
url/gurl.cc
14
url/gurl.cc
@ -372,6 +372,20 @@ bool GURL::SchemeIsWSOrWSS() const {
|
||||
return SchemeIs(url::kWsScheme) || SchemeIs(url::kWssScheme);
|
||||
}
|
||||
|
||||
bool GURL::SchemeIsCryptographic() const {
|
||||
if (parsed_.scheme.len <= 0)
|
||||
return false;
|
||||
return SchemeIsCryptographic(scheme_piece());
|
||||
}
|
||||
|
||||
bool GURL::SchemeIsCryptographic(base::StringPiece lower_ascii_scheme) {
|
||||
DCHECK(base::IsStringASCII(lower_ascii_scheme));
|
||||
DCHECK(base::ToLowerASCII(lower_ascii_scheme) == lower_ascii_scheme);
|
||||
|
||||
return lower_ascii_scheme == url::kHttpsScheme ||
|
||||
lower_ascii_scheme == url::kWssScheme;
|
||||
}
|
||||
|
||||
int GURL::IntPort() const {
|
||||
if (parsed_.port.is_nonempty())
|
||||
return url::ParsePort(spec_.data(), parsed_.port);
|
||||
|
@ -249,9 +249,10 @@ class COMPONENT_EXPORT(URL) GURL {
|
||||
// is minimally trustworthy. For that, see Chromium's |IsOriginSecure| for a
|
||||
// higher-level and more complete semantics. See that function's documentation
|
||||
// for more detail.
|
||||
bool SchemeIsCryptographic() const {
|
||||
return SchemeIs(url::kHttpsScheme) || SchemeIs(url::kWssScheme);
|
||||
}
|
||||
bool SchemeIsCryptographic() const;
|
||||
|
||||
// As above, but static. Parameter should be lower-case ASCII.
|
||||
static bool SchemeIsCryptographic(base::StringPiece lower_ascii_scheme);
|
||||
|
||||
// Returns true if the scheme is "blob".
|
||||
bool SchemeIsBlob() const {
|
||||
|
@ -765,6 +765,14 @@ TEST(GURLTest, SchemeIsCryptographic) {
|
||||
EXPECT_FALSE(GURL("ws://foo.bar.com/").SchemeIsCryptographic());
|
||||
}
|
||||
|
||||
TEST(GURLTest, SchemeIsCryptographicStatic) {
|
||||
EXPECT_TRUE(GURL::SchemeIsCryptographic("https"));
|
||||
EXPECT_TRUE(GURL::SchemeIsCryptographic("wss"));
|
||||
EXPECT_FALSE(GURL::SchemeIsCryptographic("http"));
|
||||
EXPECT_FALSE(GURL::SchemeIsCryptographic("ws"));
|
||||
EXPECT_FALSE(GURL::SchemeIsCryptographic("ftp"));
|
||||
}
|
||||
|
||||
TEST(GURLTest, SchemeIsBlob) {
|
||||
EXPECT_TRUE(GURL("BLOB://BAR/").SchemeIsBlob());
|
||||
EXPECT_TRUE(GURL("blob://bar/").SchemeIsBlob());
|
||||
|
Reference in New Issue
Block a user