pref::kPrivacySandboxFlocEnabled deprecated

This pref will possibly be removed in future, and when that occurs, this
local implementation can be removed too.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/784166ebb585a9f6e12eb2ed4ba1209375b94b3b

commit 784166ebb585a9f6e12eb2ed4ba1209375b94b3b
Author: Mariam Ali <alimariam@google.com>
Date:   Tue Jul 5 16:03:18 2022 +0000

    Remove FLoC dead code from Privacy Sandbox Service

    As FLoC the feature is removed from the codebase, this CL removes all
    the logic of string selection for FLoC state as it cannot be changed
    by the user.

    - remove FLoC state retrieval methods.
    - move the string retrieval to the Privacy Sandbox Bridge for android.
    - deprecate FLoC prefs.
    - remove unit tests for FLoC states that are no longer valid.

    A CL to remove all FLoC code along with its UI elements will follow once Privacy Sandbox Settings 3 is launched.

    Bug: 1299720
This commit is contained in:
Claudio DeSouza
2022-08-23 00:18:37 -04:00
committed by mkarolin
parent 10371449ba
commit cbaeb3d044
3 changed files with 15 additions and 22 deletions
-4
View File
@@ -328,10 +328,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->SetDefaultPrefValue(prefs::kPrivacySandboxApisEnabledV2,
base::Value(false));
// Disable Chromium's privacy sandbox
registry->SetDefaultPrefValue(prefs::kPrivacySandboxFlocEnabled,
base::Value(false));
// Importer: selected data types
registry->RegisterBooleanPref(kImportDialogExtensions, true);
registry->RegisterBooleanPref(kImportDialogPayments, true);
@@ -520,18 +520,14 @@ TEST_F(PrivacySandboxSettingsTest, IsTopicsAllowed) {
/*managed_cookie_setting=*/privacy_sandbox_test_util::kNoSetting,
/*managed_cookie_exceptions=*/{});
// FLoC should be disabled since the privacy sandbox APIs can't be enabled.
prefs()->SetBoolean(prefs::kPrivacySandboxFlocEnabled, true);
EXPECT_FALSE(privacy_sandbox_settings()->IsTopicsAllowed());
// Check that even bypassing PrivacySandboxSettings::SetFlocPrefEnabled,
// and manually updating the preferences, we still don't get this enabled.
// Check that even manually updating the preferences, we still don't get this
// enabled.
profile()->GetTestingPrefService()->SetBoolean(
prefs::kPrivacySandboxApisEnabled, true);
profile()->GetTestingPrefService()->SetBoolean(
prefs::kPrivacySandboxApisEnabledV2, true);
profile()->GetTestingPrefService()->SetBoolean(
prefs::kPrivacySandboxFlocEnabled, true);
EXPECT_FALSE(privacy_sandbox_settings()->IsTopicsAllowed());
privacy_sandbox_test_util::SetupTestState(
@@ -542,7 +538,10 @@ TEST_F(PrivacySandboxSettingsTest, IsTopicsAllowed) {
/*user_cookie_exceptions=*/{},
/*managed_cookie_setting=*/privacy_sandbox_test_util::kNoSetting,
/*managed_cookie_exceptions=*/{});
prefs()->SetBoolean(prefs::kPrivacySandboxFlocEnabled, true);
profile()->GetTestingPrefService()->SetBoolean(
prefs::kPrivacySandboxApisEnabled, true);
profile()->GetTestingPrefService()->SetBoolean(
prefs::kPrivacySandboxApisEnabledV2, true);
EXPECT_FALSE(privacy_sandbox_settings()->IsTopicsAllowed());
privacy_sandbox_test_util::SetupTestState(
@@ -553,7 +552,10 @@ TEST_F(PrivacySandboxSettingsTest, IsTopicsAllowed) {
/*user_cookie_exceptions=*/{},
/*managed_cookie_setting=*/privacy_sandbox_test_util::kNoSetting,
/*managed_cookie_exceptions=*/{});
prefs()->SetBoolean(prefs::kPrivacySandboxFlocEnabled, true);
profile()->GetTestingPrefService()->SetBoolean(
prefs::kPrivacySandboxApisEnabled, true);
profile()->GetTestingPrefService()->SetBoolean(
prefs::kPrivacySandboxApisEnabledV2, true);
EXPECT_FALSE(privacy_sandbox_settings()->IsTopicsAllowed());
privacy_sandbox_test_util::SetupTestState(
@@ -564,7 +566,10 @@ TEST_F(PrivacySandboxSettingsTest, IsTopicsAllowed) {
/*user_cookie_exceptions=*/{},
/*managed_cookie_setting=*/privacy_sandbox_test_util::kNoSetting,
/*managed_cookie_exceptions=*/{});
prefs()->SetBoolean(prefs::kPrivacySandboxFlocEnabled, true);
profile()->GetTestingPrefService()->SetBoolean(
prefs::kPrivacySandboxApisEnabled, true);
profile()->GetTestingPrefService()->SetBoolean(
prefs::kPrivacySandboxApisEnabledV2, true);
EXPECT_FALSE(privacy_sandbox_settings()->IsTopicsAllowed());
}
class PrivacySandboxSettingsTestCookiesClearOnExitTurnedOff
@@ -25,7 +25,7 @@ BravePrivacySandboxSettings::BravePrivacySandboxSettings(
pref_service,
incognito_profile),
pref_service_(pref_service) {
// Register observers for the Privacy Sandbox & FLoC preferences.
// Register observers for the Privacy Sandbox.
user_prefs_registrar_.Init(pref_service_);
user_prefs_registrar_.Add(
prefs::kPrivacySandboxApisEnabled,
@@ -37,11 +37,6 @@ BravePrivacySandboxSettings::BravePrivacySandboxSettings(
base::BindRepeating(
&BravePrivacySandboxSettings::OnPrivacySandboxPrefChanged,
base::Unretained(this)));
user_prefs_registrar_.Add(
prefs::kPrivacySandboxFlocEnabled,
base::BindRepeating(
&BravePrivacySandboxSettings::OnPrivacySandboxPrefChanged,
base::Unretained(this)));
}
BravePrivacySandboxSettings::~BravePrivacySandboxSettings() = default;
@@ -55,7 +50,4 @@ void BravePrivacySandboxSettings::OnPrivacySandboxPrefChanged() {
if (pref_service_->GetBoolean(prefs::kPrivacySandboxApisEnabledV2)) {
pref_service_->SetBoolean(prefs::kPrivacySandboxApisEnabledV2, false);
}
if (pref_service_->GetBoolean(prefs::kPrivacySandboxFlocEnabled)) {
pref_service_->SetBoolean(prefs::kPrivacySandboxFlocEnabled, false);
}
}