Files
cromite/build/patches/Move-some-account-settings-back-to-privacy-settings.patch

123 lines
7.0 KiB
Diff

From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Sun, 4 Oct 2020 12:58:17 +0200
Subject: Move some account settings back to privacy settings
Search suggestions, autofill assistant and contextual search
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
.../java/res/xml/privacy_preferences.xml | 13 ++++++++
.../privacy/settings/PrivacySettings.java | 33 +++++++++++++++++++
.../strings/android_chrome_strings.grd | 4 +++
3 files changed, 50 insertions(+)
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
@@ -77,6 +77,19 @@ found in the LICENSE file.
android:key="secure_dns"
android:title="@string/settings_secure_dns_title"
android:fragment="org.chromium.chrome.browser.privacy.secure_dns.SecureDnsSettings" />
+ <PreferenceCategory
+ android:key="services_category"
+ android:title="@string/services_category_title">
+ <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"/>
+ <org.chromium.components.browser_ui.settings.ChromeBasePreference
+ android:key="contextual_search"
+ android:title="@string/contextual_search_title"
+ android:fragment="org.chromium.chrome.browser.contextualsearch.ContextualSearchSettingsFragment"/>
+ </PreferenceCategory>
<org.chromium.components.browser_ui.settings.ChromeBasePreference
android:key="javascript_optimizer"
android:title="@string/website_settings_privacy_and_security_javascript_optimizer_row_label"
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
@@ -86,6 +86,13 @@ import org.chromium.ui.widget.ChromeBulletSpan;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
+import androidx.preference.PreferenceCategory;
+import org.chromium.chrome.browser.contextualsearch.ContextualSearchManager;
+import org.chromium.base.shared_preferences.SharedPreferencesManager;
+import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
+import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
+import org.chromium.components.browser_ui.settings.ManagedPreferenceDelegate;
+
/** Fragment to keep track of the all the privacy related preferences. */
@NullMarked
public class PrivacySettings extends ChromeBaseSettingsFragment
@@ -105,6 +112,16 @@ public class PrivacySettings extends ChromeBaseSettingsFragment
private static final String PREF_INCOGNITO_LOCK = "incognito_lock";
private static final String PREF_JAVASCRIPT_OPTIMIZER = "javascript_optimizer";
@VisibleForTesting static final String PREF_DO_NOT_TRACK = "do_not_track";
+ // moved from SyncAndServicesSettings.java
+ private static final String PREF_SERVICES_CATEGORY = "services_category";
+ private static final String PREF_SEARCH_SUGGESTIONS = "search_suggestions";
+ private static final String PREF_CONTEXTUAL_SEARCH = "contextual_search";
+ private ChromeSwitchPreference mSearchSuggestions;
+ private @Nullable Preference mContextualSearch;
+ private final SharedPreferencesManager mSharedPreferencesManager =
+ ChromeSharedPreferences.getInstance();
+
+ private ManagedPreferenceDelegate mManagedPreferenceDelegate;
@VisibleForTesting static final String PREF_THIRD_PARTY_COOKIES = "third_party_cookies";
private static final String PREF_ADVANCED_PROTECTION_INFO = "advanced_protection_info";
private static final int SECURE_CONNECTIONS_MESSAGE_ID =
@@ -219,6 +236,16 @@ public class PrivacySettings extends ChromeBaseSettingsFragment
(ChromeSwitchPreference) findPreference(PREF_PASSWORD_LEAK_DETECTION);
passwordLeakTogglePref.setOnPreferenceChangeListener(this);
+ mSearchSuggestions = (ChromeSwitchPreference) findPreference(PREF_SEARCH_SUGGESTIONS);
+ mSearchSuggestions.setOnPreferenceChangeListener(this);
+ mSearchSuggestions.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
+
+ mContextualSearch = findPreference(PREF_CONTEXTUAL_SEARCH);
+ boolean isContextualSearchEnabled =
+ !ContextualSearchManager.isContextualSearchDisabled(getProfile());
+ mContextualSearch.setSummary(
+ isContextualSearchEnabled ? R.string.text_on : R.string.text_off);
+
ChromeSwitchPreference canMakePaymentPref =
(ChromeSwitchPreference) findPreference(PREF_CAN_MAKE_PAYMENT);
canMakePaymentPref.setOnPreferenceChangeListener(this);
@@ -401,6 +428,9 @@ public class PrivacySettings extends ChromeBaseSettingsFragment
} else if (PREF_PASSWORD_LEAK_DETECTION.equals(key)) {
UserPrefs.get(getProfile())
.setBoolean(Pref.PASSWORD_LEAK_DETECTION_ENABLED, (boolean) newValue);
+ } else if (PREF_SEARCH_SUGGESTIONS.equals(key)) {
+ UserPrefs.get(getProfile())
+ .setBoolean(Pref.SEARCH_SUGGEST_ENABLED, (boolean) newValue);
}
return true;
}
@@ -413,6 +443,9 @@ public class PrivacySettings extends ChromeBaseSettingsFragment
/** Updates the preferences. */
public void updatePreferences() {
+ mSearchSuggestions.setChecked(
+ UserPrefs.get(getProfile()).getBoolean(Pref.SEARCH_SUGGEST_ENABLED));
+
ChromeSwitchPreference passwordLeakTogglePref =
(ChromeSwitchPreference) findPreference(PREF_PASSWORD_LEAK_DETECTION);
if (passwordLeakTogglePref != null) {
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd
--- a/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -470,6 +470,10 @@ For more settings that use data to improve your Chrome experience, go to <ph nam
Automatically sends usage statistics and crash reports to Google
</message>
+ <message name="IDS_SERVICES_CATEGORY_TITLE" desc="Title for the group of preferences that control non-personalized Google services. This group contains preferences for data that is not tied to user's Google Account.">
+ Other services
+ </message>
+
<!-- Search engine settings -->
<message name="IDS_SEARCH_ENGINE_SETTINGS" desc="Title for Search Engine settings. [CHAR_LIMIT=32]">
Search engine
--