Disable privacy sandbox
This commit is contained in:
parent
43dbb5e70b
commit
dcce2c16e3
1 changed files with 143 additions and 0 deletions
143
build/patches/Disable-privacy-sandbox.patch
Normal file
143
build/patches/Disable-privacy-sandbox.patch
Normal file
|
@ -0,0 +1,143 @@
|
|||
From: uazo <uazo@users.noreply.github.com>
|
||||
Date: Sat, 13 Nov 2021 09:17:06 +0000
|
||||
Subject: Disable privacy sandbox
|
||||
|
||||
Remove the ui from the settings and set the flags to inactive
|
||||
---
|
||||
.../java/res/xml/privacy_preferences.xml | 4 ---
|
||||
.../privacy/settings/PrivacySettings.java | 19 -----------
|
||||
.../privacy_sandbox_settings.cc | 34 +++++++++----------
|
||||
3 files changed, 16 insertions(+), 41 deletions(-)
|
||||
|
||||
diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/android/java/res/xml/privacy_preferences.xml
|
||||
--- a/chrome/android/java/res/xml/privacy_preferences.xml
|
||||
+++ b/chrome/android/java/res/xml/privacy_preferences.xml
|
||||
@@ -70,10 +70,6 @@
|
||||
android:title="@string/open_external_links_incognito_title"
|
||||
android:summary="@string/open_external_links_incognito_summary"
|
||||
android:defaultValue="false" />
|
||||
- <Preference
|
||||
- android:key="privacy_sandbox"
|
||||
- android:title="@string/prefs_privacy_sandbox"
|
||||
- android:fragment="org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsFragment"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="services_category"
|
||||
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java b/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java
|
||||
--- a/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java
|
||||
+++ b/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettings.java
|
||||
@@ -70,7 +70,6 @@ public class PrivacySettings
|
||||
private static final String PREF_SECURE_DNS = "secure_dns";
|
||||
private static final String PREF_DO_NOT_TRACK = "do_not_track";
|
||||
private static final String PREF_CLEAR_BROWSING_DATA = "clear_browsing_data";
|
||||
- private static final String PREF_PRIVACY_SANDBOX = "privacy_sandbox";
|
||||
private static final String PREF_PRIVACY_REVIEW = "privacy_review";
|
||||
|
||||
private static final String PREF_CLOSE_TABS_ON_EXIT = "close_tabs_on_exit";
|
||||
@@ -100,18 +99,6 @@ public class PrivacySettings
|
||||
SettingsUtils.addPreferencesFromResource(this, R.xml.privacy_preferences);
|
||||
getActivity().setTitle(R.string.prefs_privacy_security);
|
||||
|
||||
- findPreference(PREF_PRIVACY_SANDBOX)
|
||||
- .setSummary(PrivacySandboxSettingsFragment.getStatusString(getContext()));
|
||||
- // Overwrite the click listener to pass a correct referrer to the fragment.
|
||||
- findPreference(PREF_PRIVACY_SANDBOX).setOnPreferenceClickListener(preference -> {
|
||||
- Bundle fragmentArgs = new Bundle();
|
||||
- fragmentArgs.putInt(PrivacySandboxSettingsFragment.PRIVACY_SANDBOX_REFERRER,
|
||||
- PrivacySandboxReferrer.PRIVACY_SETTINGS);
|
||||
- new SettingsLauncherImpl().launchSettingsActivity(
|
||||
- getContext(), PrivacySandboxSettingsFragment.class, fragmentArgs);
|
||||
- return true;
|
||||
- });
|
||||
-
|
||||
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.PRIVACY_REVIEW)) {
|
||||
getPreferenceScreen().removePreference(findPreference(PREF_PRIVACY_REVIEW));
|
||||
}
|
||||
@@ -292,12 +279,6 @@ public class PrivacySettings
|
||||
secureDnsPref.setSummary(SecureDnsSettings.getSummary(getContext()));
|
||||
}
|
||||
|
||||
- Preference privacySandboxPreference = findPreference(PREF_PRIVACY_SANDBOX);
|
||||
- if (privacySandboxPreference != null) {
|
||||
- privacySandboxPreference.setSummary(
|
||||
- PrivacySandboxSettingsFragment.getStatusString(getContext()));
|
||||
- }
|
||||
-
|
||||
ChromeSwitchPreference closeTabsOnExitPref =
|
||||
(ChromeSwitchPreference) findPreference(PREF_CLOSE_TABS_ON_EXIT);
|
||||
closeTabsOnExitPref.setOnPreferenceChangeListener(this);
|
||||
diff --git a/chrome/browser/privacy_sandbox/privacy_sandbox_settings.cc b/chrome/browser/privacy_sandbox/privacy_sandbox_settings.cc
|
||||
--- a/chrome/browser/privacy_sandbox/privacy_sandbox_settings.cc
|
||||
+++ b/chrome/browser/privacy_sandbox/privacy_sandbox_settings.cc
|
||||
@@ -111,23 +111,8 @@ bool ThirdPartyCookiesDisabledByPolicy(
|
||||
bool ShouldDisablePrivacySandbox(
|
||||
content_settings::CookieSettings* cookie_settings,
|
||||
PrefService* prefs) {
|
||||
- // If a user has already expressed control over the Privacy Sandbox preference
|
||||
- // on any of their devices there is no need to disable it.
|
||||
- if (prefs->GetBoolean(prefs::kPrivacySandboxManuallyControlled))
|
||||
- return false;
|
||||
-
|
||||
- auto cookie_controls_mode_value =
|
||||
- static_cast<content_settings::CookieControlsMode>(
|
||||
- prefs->GetInteger(prefs::kCookieControlsMode));
|
||||
-
|
||||
- auto default_cookie_setting =
|
||||
- cookie_settings->GetDefaultCookieSetting(/*provider_id=*/nullptr);
|
||||
-
|
||||
- // The Privacy Sandbox preference should be disabled if 3P cookies or all
|
||||
- // cookies are blocked.
|
||||
- return (cookie_controls_mode_value ==
|
||||
- content_settings::CookieControlsMode::kBlockThirdParty ||
|
||||
- default_cookie_setting == ContentSetting::CONTENT_SETTING_BLOCK);
|
||||
+ // privacy sandbox is always disabled
|
||||
+ return true;
|
||||
}
|
||||
|
||||
// Returns whether FLoC is allowable by the current state of |pref_service|.
|
||||
@@ -195,6 +180,8 @@ PrivacySandboxSettings::PrivacySandboxSettings(
|
||||
base::BindRepeating(&PrivacySandboxSettings::OnPrivacySandboxPrefChanged,
|
||||
base::Unretained(this)));
|
||||
|
||||
+ // as default, privacy sandbox is disabled
|
||||
+ pref_service_->SetBoolean(prefs::kPrivacySandboxApisEnabled, false);
|
||||
// On first entering the privacy sandbox experiment, users may have the
|
||||
// privacy sandbox disabled (or "reconciled") based on their current cookie
|
||||
// settings (e.g. blocking 3P cookies). Depending on the state of the sync
|
||||
@@ -393,7 +380,8 @@ bool PrivacySandboxSettings::IsPrivacySandboxManaged() {
|
||||
|
||||
void PrivacySandboxSettings::SetPrivacySandboxEnabled(bool enabled) {
|
||||
pref_service_->SetBoolean(prefs::kPrivacySandboxManuallyControlled, true);
|
||||
- pref_service_->SetBoolean(prefs::kPrivacySandboxApisEnabled, enabled);
|
||||
+ // never enable privacy sandbox
|
||||
+ pref_service_->SetBoolean(prefs::kPrivacySandboxApisEnabled, false);
|
||||
}
|
||||
|
||||
void PrivacySandboxSettings::OnCookiesCleared() {
|
||||
@@ -447,6 +435,10 @@ bool PrivacySandboxSettings::IsPrivacySandboxAllowedForContext(
|
||||
const GURL& url,
|
||||
const absl::optional<url::Origin>& top_frame_origin,
|
||||
const ContentSettingsForOneType& cookie_settings) const {
|
||||
+ // even if prefs::kPrivacySandboxApisEnabled and
|
||||
+ // prefs::kPrivacySandboxFlocEnabled are always false
|
||||
+ if ((true))
|
||||
+ return false; // guard this code path
|
||||
if (!pref_service_->GetBoolean(prefs::kPrivacySandboxApisEnabled))
|
||||
return false;
|
||||
|
||||
@@ -459,6 +451,12 @@ bool PrivacySandboxSettings::IsPrivacySandboxAllowedForContext(
|
||||
}
|
||||
|
||||
void PrivacySandboxSettings::MaybeReconcilePrivacySandboxPref() {
|
||||
+ // this code could be eliminated in the future, as initially
|
||||
+ // the feauture was tied to the cookies flag
|
||||
+ pref_service_->SetBoolean(prefs::kPrivacySandboxApisEnabled, false);
|
||||
+ if((true))
|
||||
+ return;
|
||||
+
|
||||
// No need to reconcile preferences if it has already happened.
|
||||
if (pref_service_->GetBoolean(prefs::kPrivacySandboxPreferencesReconciled)) {
|
||||
LogPrivacySandboxState();
|
||||
--
|
||||
2.20.1
|
||||
|
Loading…
Add table
Reference in a new issue