0

[3PCD] Not sending labels in incognito mode

This CL also makes ContentBrowserClient to return false by default,
and override in ShellContentBrowserClient for testing.

Bug: 1485124
Change-Id: I676ed302464e9af9d6e37fe77c08983b9969a4d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4876981
Reviewed-by: Anthony Garant <anthonygarant@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Commit-Queue: Nan Lin <linnan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1199168}
This commit is contained in:
Nan Lin
2023-09-20 19:28:41 +00:00
committed by Chromium LUCI CQ
parent 5dd2b8ff5f
commit dbfc369db7
6 changed files with 41 additions and 5 deletions

@@ -520,6 +520,21 @@ IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
"label_test");
}
IN_PROC_BROWSER_TEST_F(CookieDeprecationLabelEnabledBrowserTest,
Incognito_LabelError) {
auto https_server = CreateTestServer(EmbeddedTestServer::TYPE_HTTPS);
ASSERT_TRUE(https_server->Start());
auto* incognito_shell = CreateOffTheRecordBrowser();
EXPECT_TRUE(NavigateToURL(incognito_shell,
https_server->GetURL("a.test", "/hello.html")));
EXPECT_EQ(EvalJs(incognito_shell, R"((async () => {
return await navigator.cookieDeprecationLabel.getValue()
.catch(() => 'error'); })())"),
"error");
}
} // namespace
} // namespace content

@@ -1452,8 +1452,10 @@ void StoragePartitionImpl::Initialize(
std::make_unique<BluetoothAllowedDevicesMap>();
// Must be initialized before the `url_loader_factory_getter_`.
// Cookie deprecation traffic labels should not be sent in incognito mode.
if (base::FeatureList::IsEnabled(
features::kCookieDeprecationFacilitatedTesting)) {
features::kCookieDeprecationFacilitatedTesting) &&
!is_in_memory()) {
cookie_deprecation_label_manager_ =
std::make_unique<CookieDeprecationLabelManagerImpl>(browser_context_);
}

@@ -598,14 +598,14 @@ bool ContentBrowserClient::IsPrivateAggregationDebugModeAllowed(
bool ContentBrowserClient::IsCookieDeprecationLabelAllowed(
content::BrowserContext* browser_context) {
return true;
return false;
}
bool ContentBrowserClient::IsCookieDeprecationLabelAllowedForContext(
content::BrowserContext* browser_context,
const url::Origin& top_frame_origin,
const url::Origin& context_origin) {
return true;
return false;
}
bool ContentBrowserClient::CanSendSCTAuditingReport(

@@ -985,12 +985,13 @@ class CONTENT_EXPORT ContentBrowserClient {
const url::Origin& reporting_origin);
// Returns whether cookie deprecation label should be allowed for the
// profile.
// profile. Defaults to false to ensure no traffic label is sent by default.
virtual bool IsCookieDeprecationLabelAllowed(
content::BrowserContext* browser_context);
// Returns whether cookie deprecation label should be allowed for the
// profile in a given context.
// profile in a given context. Defaults to false to ensure no traffic label
// is sent by default.
virtual bool IsCookieDeprecationLabelAllowedForContext(
content::BrowserContext* browser_context,
const url::Origin& top_frame_origin,

@@ -481,6 +481,18 @@ bool ShellContentBrowserClient::IsSharedStorageSelectURLAllowed(
return true;
}
bool ShellContentBrowserClient::IsCookieDeprecationLabelAllowed(
content::BrowserContext* browser_context) {
return true;
}
bool ShellContentBrowserClient::IsCookieDeprecationLabelAllowedForContext(
content::BrowserContext* browser_context,
const url::Origin& top_frame_origin,
const url::Origin& context_origin) {
return true;
}
GeneratedCodeCacheSettings
ShellContentBrowserClient::GetGeneratedCodeCacheSettings(
content::BrowserContext* context) {

@@ -75,6 +75,12 @@ class ShellContentBrowserClient : public ContentBrowserClient {
content::BrowserContext* browser_context,
const url::Origin& top_frame_origin,
const url::Origin& accessing_origin) override;
bool IsCookieDeprecationLabelAllowed(
content::BrowserContext* browser_context) override;
bool IsCookieDeprecationLabelAllowedForContext(
content::BrowserContext* browser_context,
const url::Origin& top_frame_origin,
const url::Origin& context_origin) override;
GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
content::BrowserContext* context) override;
base::OnceClosure SelectClientCertificate(