[First Party Sets UI] Deprecate duplicate UI facing preference
The UI and FPS backends each had their own preference to represent the
state of FPS.
This CL deprecates the front-end preference, and re-connects it to the
FPS backend pref, which had so far only been used to apply policy.
Using the same pref object for policy, and user, control is standard
practice, as a single pref object can encapsulate both levels of
control.
The user initialization logic, and associated pref, remain, but now
affect the pref used by the FPS backend.
Bug: 1349370
Change-Id: I9ed6a2a7205718c78e8f6e2817076eabff9fa6fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3871264
Reviewed-by: Demetrios Papadopoulos <[email protected]>
Commit-Queue: Theodore Olsauskas-Warren <[email protected]>
Reviewed-by: Shuran Huang <[email protected]>
Reviewed-by: Marc Treib <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1044436}
diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc
index e5b9e65..fdc56ba 100644
--- a/chrome/browser/extensions/api/settings_private/prefs_util.cc
+++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/extensions/api/settings_private/generated_prefs.h"
#include "chrome/browser/extensions/api/settings_private/generated_prefs_factory.h"
#include "chrome/browser/extensions/settings_api_helpers.h"
+#include "chrome/browser/first_party_sets/first_party_sets_pref_names.h"
#include "chrome/browser/metrics/profile_pref_names.h"
#include "chrome/browser/nearby_sharing/common/nearby_share_prefs.h"
#include "chrome/browser/password_manager/generated_password_leak_detection_pref.h"
@@ -325,7 +326,7 @@
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_allowlist)[::prefs::kCookieControlsMode] =
settings_api::PrefType::PREF_TYPE_NUMBER;
- (*s_allowlist)[::prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed] =
+ (*s_allowlist)[::first_party_sets::kFirstPartySetsEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
// Sync and personalization page.
diff --git a/chrome/browser/first_party_sets/first_party_sets_policy_service_factory.cc b/chrome/browser/first_party_sets/first_party_sets_policy_service_factory.cc
index df80df7..2de8aac 100644
--- a/chrome/browser/first_party_sets/first_party_sets_policy_service_factory.cc
+++ b/chrome/browser/first_party_sets/first_party_sets_policy_service_factory.cc
@@ -98,7 +98,9 @@
void FirstPartySetsPolicyServiceFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
- registry->RegisterBooleanPref(kFirstPartySetsEnabled, true);
+ registry->RegisterBooleanPref(
+ kFirstPartySetsEnabled, true,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterDictionaryPref(kFirstPartySetsOverrides,
base::DictionaryValue());
}
diff --git a/chrome/browser/first_party_sets/first_party_sets_pref_names.cc b/chrome/browser/first_party_sets/first_party_sets_pref_names.cc
index 6e7d4f2f..bd6743c3 100644
--- a/chrome/browser/first_party_sets/first_party_sets_pref_names.cc
+++ b/chrome/browser/first_party_sets/first_party_sets_pref_names.cc
@@ -12,8 +12,8 @@
// *************** PROFILE PREFS ***************
-// A boolean pref indicating whether First-Party Sets is enabled by enterprise
-// policy.
+// A boolean pref indicating whether First-Party Sets is enabled. Exposed to the
+// user via Chrome UI, and to enterprise via policy.
const char kFirstPartySetsEnabled[] = "first_party_sets.enabled";
// A dictionary pref that can contain up to two lists of First-Party Sets that
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 984cafb..9611537 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -767,6 +767,10 @@
constexpr char kUsersLastInputMethod[] = "UsersLRUInputMethod";
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+// Deprecated 09/2022.
+const char kPrivacySandboxFirstPartySetsDataAccessAllowed[] =
+ "privacy_sandbox.first_party_sets_data_access_allowed";
+
// Register local state used only for migration (clearing or moving to a new
// key).
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
@@ -1010,6 +1014,10 @@
// Deprecated 08/2022.
registry->RegisterBooleanPref(prefs::kUsesSystemThemeDeprecated, false);
#endif
+
+ // Deprecated 09/2022
+ registry->RegisterBooleanPref(kPrivacySandboxFirstPartySetsDataAccessAllowed,
+ true);
}
} // namespace
@@ -1980,6 +1988,9 @@
profile_prefs->ClearPref(prefs::kUsesSystemThemeDeprecated);
#endif
+ // Added 09/2022.
+ profile_prefs->ClearPref(kPrivacySandboxFirstPartySetsDataAccessAllowed);
+
// Please don't delete the following line. It is used by PRESUBMIT.py.
// END_MIGRATE_OBSOLETE_PROFILE_PREFS
diff --git a/chrome/browser/privacy_sandbox/privacy_sandbox_service.cc b/chrome/browser/privacy_sandbox/privacy_sandbox_service.cc
index 5b38a48f..153cddc 100644
--- a/chrome/browser/privacy_sandbox/privacy_sandbox_service.cc
+++ b/chrome/browser/privacy_sandbox/privacy_sandbox_service.cc
@@ -16,6 +16,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
+#include "chrome/browser/first_party_sets/first_party_sets_pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "components/browsing_topics/browsing_topics_service.h"
#include "components/content_settings/core/browser/cookie_settings.h"
@@ -309,18 +310,16 @@
}
bool PrivacySandboxService::IsFirstPartySetsDataAccessEnabled() {
- return pref_service_->GetBoolean(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed);
+ return pref_service_->GetBoolean(first_party_sets::kFirstPartySetsEnabled);
}
bool PrivacySandboxService::IsFirstPartySetsDataAccessManaged() {
return pref_service_->IsManagedPreference(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed);
+ first_party_sets::kFirstPartySetsEnabled);
}
void PrivacySandboxService::SetFirstPartySetsDataAccessEnabled(bool enabled) {
- pref_service_->SetBoolean(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed, enabled);
+ pref_service_->SetBoolean(first_party_sets::kFirstPartySetsEnabled, enabled);
}
void PrivacySandboxService::GetFledgeJoiningEtldPlusOneForDisplay(
@@ -623,8 +622,7 @@
if (!(cookie_settings_->ShouldBlockThirdPartyCookies() &&
cookie_settings_->GetDefaultCookieSetting(/*provider_id=*/nullptr) !=
CONTENT_SETTING_BLOCK &&
- pref_service_->GetBoolean(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed) &&
+ pref_service_->GetBoolean(first_party_sets::kFirstPartySetsEnabled) &&
base::FeatureList::IsEnabled(
privacy_sandbox::kPrivacySandboxFirstPartySetsUI))) {
return {};
@@ -875,8 +873,7 @@
// init has been run is not synced). If any of the user's devices local state
// would disable the pref, it is disabled across all devices.
if (AreThirdPartyCookiesBlocked(cookie_settings_)) {
- pref_service_->SetBoolean(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed, false);
+ pref_service_->SetBoolean(first_party_sets::kFirstPartySetsEnabled, false);
}
pref_service_->SetBoolean(
diff --git a/chrome/browser/privacy_sandbox/privacy_sandbox_service_unittest.cc b/chrome/browser/privacy_sandbox/privacy_sandbox_service_unittest.cc
index 5e6dfe6..1acf95c 100644
--- a/chrome/browser/privacy_sandbox/privacy_sandbox_service_unittest.cc
+++ b/chrome/browser/privacy_sandbox/privacy_sandbox_service_unittest.cc
@@ -13,6 +13,7 @@
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
+#include "chrome/browser/first_party_sets/first_party_sets_pref_names.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/common/chrome_features.h"
@@ -661,8 +662,7 @@
// returning them to their default value.
void ClearFpsUserPrefs(
sync_preferences::TestingPrefServiceSyncable* pref_service) {
- pref_service->RemoveUserPref(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed);
+ pref_service->RemoveUserPref(first_party_sets::kFirstPartySetsEnabled);
pref_service->RemoveUserPref(
prefs::kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized);
}
@@ -1984,8 +1984,7 @@
prefs::kCookieControlsMode,
std::make_unique<base::Value>(static_cast<int>(
content_settings::CookieControlsMode::kBlockThirdParty)));
- prefs()->SetBoolean(prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed,
- true);
+ prefs()->SetBoolean(first_party_sets::kFirstPartySetsEnabled, true);
EXPECT_EQ(u"google.com",
privacy_sandbox_service()->GetFirstPartySetOwnerForDisplay(
@@ -2011,8 +2010,7 @@
privacy_sandbox::kPrivacySandboxFirstPartySetsUI);
CreateService();
- EXPECT_TRUE(prefs()->GetBoolean(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed));
+ EXPECT_TRUE(prefs()->GetBoolean(first_party_sets::kFirstPartySetsEnabled));
EXPECT_FALSE(prefs()->GetBoolean(
prefs::kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized));
@@ -2024,8 +2022,7 @@
privacy_sandbox::kPrivacySandboxFirstPartySetsUI);
CreateService();
- EXPECT_FALSE(prefs()->GetBoolean(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed));
+ EXPECT_FALSE(prefs()->GetBoolean(first_party_sets::kFirstPartySetsEnabled));
EXPECT_TRUE(prefs()->GetBoolean(
prefs::kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized));
@@ -2037,8 +2034,7 @@
content_settings::CookieControlsMode::kOff)));
CreateService();
- EXPECT_TRUE(prefs()->GetBoolean(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed));
+ EXPECT_TRUE(prefs()->GetBoolean(first_party_sets::kFirstPartySetsEnabled));
EXPECT_TRUE(prefs()->GetBoolean(
prefs::kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized));
@@ -2047,8 +2043,7 @@
std::make_unique<base::Value>(static_cast<int>(
content_settings::CookieControlsMode::kBlockThirdParty)));
CreateService();
- EXPECT_TRUE(prefs()->GetBoolean(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed));
+ EXPECT_TRUE(prefs()->GetBoolean(first_party_sets::kFirstPartySetsEnabled));
EXPECT_TRUE(prefs()->GetBoolean(
prefs::kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized));
@@ -2060,8 +2055,7 @@
cookie_settings()->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
CreateService();
- EXPECT_FALSE(prefs()->GetBoolean(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed));
+ EXPECT_FALSE(prefs()->GetBoolean(first_party_sets::kFirstPartySetsEnabled));
EXPECT_TRUE(prefs()->GetBoolean(
prefs::kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized));
}
@@ -2080,8 +2074,7 @@
std::make_unique<base::Value>(static_cast<int>(
content_settings::CookieControlsMode::kBlockThirdParty)));
cookie_settings()->SetDefaultCookieSetting(CONTENT_SETTING_ALLOW);
- prefs()->SetBoolean(prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed,
- true);
+ prefs()->SetBoolean(first_party_sets::kFirstPartySetsEnabled, true);
EXPECT_GT(privacy_sandbox_service()->GetFirstPartySets().size(), 0u);
// When 3PC are enabled, no sets should be returned.
@@ -2101,8 +2094,7 @@
// When FPS is disabled, no sets should be returned.
cookie_settings()->SetDefaultCookieSetting(CONTENT_SETTING_ALLOW);
- prefs()->SetBoolean(prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed,
- false);
+ prefs()->SetBoolean(first_party_sets::kFirstPartySetsEnabled, false);
EXPECT_EQ(0u, privacy_sandbox_service()->GetFirstPartySets().size());
@@ -2110,8 +2102,7 @@
feature_list()->Reset();
feature_list()->InitAndDisableFeature(
privacy_sandbox::kPrivacySandboxFirstPartySetsUI);
- prefs()->SetBoolean(prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed,
- true);
+ prefs()->SetBoolean(first_party_sets::kFirstPartySetsEnabled, true);
EXPECT_EQ(0u, privacy_sandbox_service()->GetFirstPartySets().size());
}
diff --git a/chrome/browser/resources/settings/privacy_page/cookies_page.html b/chrome/browser/resources/settings/privacy_page/cookies_page.html
index f97c322..3d7bca6 100644
--- a/chrome/browser/resources/settings/privacy_page/cookies_page.html
+++ b/chrome/browser/resources/settings/privacy_page/cookies_page.html
@@ -111,9 +111,7 @@
<template is="dom-if" if="[[enableFirstPartySetsUI_]]">
<settings-toggle-button
id="firstPartySetsToggle"
- pref="{{
- prefs.privacy_sandbox.first_party_sets_data_access_allowed
- }}"
+ pref="{{prefs.first_party_sets.enabled}}"
label="$i18n{cookiePageFpsLabel}"
sub-label="$i18n{cookiePageFpsSubLabel}"
disabled="[[firstPartySetsToggleDisabled_(
diff --git a/components/privacy_sandbox/privacy_sandbox_prefs.cc b/components/privacy_sandbox/privacy_sandbox_prefs.cc
index da5327e..281d829 100644
--- a/components/privacy_sandbox/privacy_sandbox_prefs.cc
+++ b/components/privacy_sandbox/privacy_sandbox_prefs.cc
@@ -54,9 +54,6 @@
extern const char kPrivacySandboxDisabledInsufficientConfirmation[] =
"privacy_sandbox.disabled_insufficient_confirmation";
-extern const char kPrivacySandboxFirstPartySetsDataAccessAllowed[] =
- "privacy_sandbox.first_party_sets_data_access_allowed";
-
extern const char kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized[] =
"privacy_sandbox.first_party_sets_data_access_allowed_initialized";
@@ -95,9 +92,6 @@
registry->RegisterBooleanPref(
prefs::kPrivacySandboxDisabledInsufficientConfirmation, false);
registry->RegisterBooleanPref(
- prefs::kPrivacySandboxFirstPartySetsDataAccessAllowed, true,
- user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
- registry->RegisterBooleanPref(
prefs::kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized, false);
}
diff --git a/components/privacy_sandbox/privacy_sandbox_prefs.h b/components/privacy_sandbox/privacy_sandbox_prefs.h
index 4c682458..601d2ff6 100644
--- a/components/privacy_sandbox/privacy_sandbox_prefs.h
+++ b/components/privacy_sandbox/privacy_sandbox_prefs.h
@@ -84,11 +84,10 @@
// automatically because they do not have the correct level of confirmation.
extern const char kPrivacySandboxDisabledInsufficientConfirmation[];
-// Synced boolean pref. Controls whether First Party Set enabled data access is
-// enabled, e.g. Storage Access API auto grants, or partitioning access by FPS.
-extern const char kPrivacySandboxFirstPartySetsDataAccessAllowed[];
-
-// Boolean that indicates the user's FPS data access preference has been init.
+// Boolean that indicates the user's FPS data access preference has been init,
+// so named because of the user intent it intends to represent. Currently there
+// is no distinction between FPS for data access, and FPS for other purposes, so
+// this init is applied to the first_party_sets.enabled pref.
extern const char kPrivacySandboxFirstPartySetsDataAccessAllowedInitialized[];
} // namespace prefs