LeOSium_old/patches/0001-Vanadium/0071-Move-search-suggestion...

82 lines
3.9 KiB
Diff
Raw Normal View History

2023-11-18 11:23:04 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: fgei <fgei@gmail.com>
Date: Fri, 20 Aug 2021 16:13:42 +0000
Subject: [PATCH] Move search suggestions back to privacy section.
---
.../java/res/xml/privacy_preferences_ext.xml | 5 +++++
.../privacy/settings/PrivacySettingsExt.java | 20 +++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/chrome/android/java/res/xml/privacy_preferences_ext.xml b/chrome/android/java/res/xml/privacy_preferences_ext.xml
index a352cd657b1b9..01e8c8217afed 100644
--- a/chrome/android/java/res/xml/privacy_preferences_ext.xml
+++ b/chrome/android/java/res/xml/privacy_preferences_ext.xml
@@ -5,5 +5,10 @@ that can be found in the LICENSE file.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
+ <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
+ android:key="search_suggestions"
+ android:title="@string/improve_search_suggestions_title"
+ android:summary="@string/improve_search_suggestions_summary"
+ android:persistent="false"/>
</PreferenceScreen>
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettingsExt.java b/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettingsExt.java
index 00a65cf922353..d627ead5ee9d0 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettingsExt.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/privacy/settings/PrivacySettingsExt.java
@@ -25,6 +25,8 @@ import org.chromium.components.user_prefs.UserPrefs;
final class PrivacySettingsExt {
+ private static final String PREF_SEARCH_SUGGESTIONS = "search_suggestions";
+
private static final Preference.OnPreferenceChangeListener LISTENER =
(pref, val) -> {
PrefService prefService = UserPrefs.get(Profile.getLastUsedRegularProfile());
@@ -32,6 +34,9 @@ final class PrivacySettingsExt {
return false;
}
String key = pref.getKey();
+ if (PREF_SEARCH_SUGGESTIONS.equals(key)) {
+ prefService.setBoolean(Pref.SEARCH_SUGGEST_ENABLED, (boolean) val);
+ }
return true;
};
@@ -42,6 +47,9 @@ final class PrivacySettingsExt {
return false;
}
String key = pref.getKey();
+ if (PREF_SEARCH_SUGGESTIONS.equals(key)) {
+ return prefService.isManagedPreference(Pref.SEARCH_SUGGEST_ENABLED);
+ }
return false;
};
@@ -58,10 +66,22 @@ final class PrivacySettingsExt {
int SECURITY_PREFERENCES_ORDER =
ChromeFeatureList.isEnabled(ChromeFeatureList.PRIVACY_SANDBOX_SETTINGS_4) ? 2 : 9999;
SettingsUtils.addPreferencesFromResource(prefFragment, R.xml.privacy_preferences_ext);
+ ChromeSwitchPreference searchSuggestionsPref =
+ (ChromeSwitchPreference) prefFragment.findPreference(PREF_SEARCH_SUGGESTIONS);
+ if (searchSuggestionsPref != null) {
+ searchSuggestionsPref.setOrder(PRIVACY_PREFERENCES_ORDER);
+ searchSuggestionsPref.setOnPreferenceChangeListener(LISTENER);
+ searchSuggestionsPref.setManagedPreferenceDelegate(DELEGATE);
+ }
}
static void updatePreferences(@NonNull PreferenceFragmentCompat prefFragment) {
ThreadUtils.checkUiThread();
PrefService prefService = UserPrefs.get(Profile.getLastUsedRegularProfile());
+ ChromeSwitchPreference searchSuggestionsPref =
+ (ChromeSwitchPreference) prefFragment.findPreference(PREF_SEARCH_SUGGESTIONS);
+ SettingsExtUtils.safelyUpdateSwitchPreference(/* switchPref */ searchSuggestionsPref,
+ /* newSummary*/ null,
+ /* newCheckedValue*/ prefService.getBoolean(Pref.SEARCH_SUGGEST_ENABLED));
}
}