Skip to content

Commit

Permalink
Merge pull request #14398 from brave/FIX_for_23919_fingerprinting_for…
Browse files Browse the repository at this point in the history
…_language

Fix for 23919 fingerprint for language
  • Loading branch information
sujitacharya2005 authored Aug 9, 2022
2 parents 95a3a84 + d9759ae commit 009d932
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class BravePrivacySettings extends PrivacySettings {
private static final String PREF_HTTPS_FIRST_MODE = "https_first_mode";
private static final String PREF_INCOGNITO_LOCK = "incognito_lock";
private static final String PREF_PHONE_AS_A_SECURITY_KEY = "phone_as_a_security_key";
private static final String PREF_FINGERPRINT_LANGUAGE = "fingerprint_language";

// brave Prefs
private static final String PREF_BRAVE_SHIELDS_GLOBALS_SECTION =
Expand Down Expand Up @@ -95,7 +96,7 @@ public class BravePrivacySettings extends PrivacySettings {
PREF_BRAVE_SHIELDS_GLOBALS_SECTION, // shields globals section
PREF_SHIELDS_SUMMARY, PREF_BLOCK_TRACKERS_ADS, PREF_DE_AMP, PREF_HTTPSE,
PREF_HTTPS_FIRST_MODE, PREF_BLOCK_SCRIPTS, PREF_BLOCK_CROSS_SITE_COOKIES,
PREF_FINGERPRINTING_PROTECTION,
PREF_FINGERPRINTING_PROTECTION, PREF_FINGERPRINT_LANGUAGE,
PREF_CLEAR_DATA_SECTION, // clear data automatically section
PREF_CLEAR_ON_EXIT, PREF_CLEAR_BROWSING_DATA,
PREF_BRAVE_SOCIAL_BLOCKING_SECTION, // social blocking section
Expand Down Expand Up @@ -145,6 +146,7 @@ public class BravePrivacySettings extends PrivacySettings {
private ChromeBasePreference mWebrtcPolicy;
private ChromeSwitchPreference mClearBrowsingDataOnExit;
private Preference mUstoppableDomains;
private ChromeSwitchPreference mFingerprntLanguagePref;

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
Expand Down Expand Up @@ -187,6 +189,10 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
(BraveDialogPreference) findPreference(PREF_FINGERPRINTING_PROTECTION);
mFingerprintingProtectionPref.setOnPreferenceChangeListener(this);

mFingerprntLanguagePref =
(ChromeSwitchPreference) findPreference(PREF_FINGERPRINT_LANGUAGE);
mFingerprntLanguagePref.setOnPreferenceChangeListener(this);

mCloseTabsOnExitPref = (ChromeSwitchPreference) findPreference(PREF_CLOSE_TABS_ON_EXIT);
mCloseTabsOnExitPref.setOnPreferenceChangeListener(this);

Expand Down Expand Up @@ -311,6 +317,9 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
R.string.block_fingerprinting_option_3));
mFingerprintingProtectionPref.setCheckedIndex(2);
}
} else if (PREF_FINGERPRINT_LANGUAGE.equals(key)) {
UserPrefs.get(Profile.getLastUsedRegularProfile())
.setBoolean(BravePref.REDUCE_LANGUAGE_ENABLED, (boolean) newValue);
} else if (PREF_BLOCK_CROSS_SITE_COOKIES.equals(key)) {
if ((int) newValue == 0) {
BravePrefServiceBridge.getInstance().setCookiesBlockType(
Expand Down Expand Up @@ -510,6 +519,8 @@ private void updateBravePreferences() {
mSearchSuggestions.setEnabled(autocompleteEnabled);
mAutocompleteTopSites.setEnabled(autocompleteEnabled);
mAutocompleteBraveSuggestedSites.setEnabled(autocompleteEnabled);
mFingerprntLanguagePref.setChecked(UserPrefs.get(Profile.getLastUsedRegularProfile())
.getBoolean(BravePref.REDUCE_LANGUAGE_ENABLED));
}

private void removePreferenceIfPresent(String key) {
Expand Down
5 changes: 5 additions & 0 deletions android/java/res/xml/brave_privacy_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
app:dialog_subtitle="@string/block_fingerprinting_text"
app:dialog_entries="@array/blockFingerprintingTexts"
app:dialog_default_index="1" />
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
android:key="fingerprint_language"
android:title="@string/fingerprint_language_switch"
android:summary="@string/fingerprint_language_switch_summary"
android:defaultValue="false" />
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
android:key="de_amp"
android:title="@string/de_amp_switch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class BravePrivacySettingsTest {
private static final String PREF_INCOGNITO_LOCK = "incognito_lock";
private static final String PREF_PHONE_AS_A_SECURITY_KEY = "phone_as_a_security_key";

private static int BRAVE_PRIVACY_SETTINGS_NUMBER_OF_ITEMS = 22;
private static int BRAVE_PRIVACY_SETTINGS_NUMBER_OF_ITEMS = 23;

private int mItemsLeft;

Expand Down
1 change: 1 addition & 0 deletions browser/android/preferences/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ source_set("preferences") {
java_cpp_strings("java_pref_names_srcjar") {
sources = [
"//brave/components/brave_rewards/common/pref_names.cc",
"//brave/components/brave_shields/common/pref_names.cc",
"//brave/components/constants/pref_names.cc",
"//brave/components/ntp_background_images/common/pref_names.cc",
"//brave/components/omnibox/browser/brave_omnibox_prefs.cc",
Expand Down
6 changes: 6 additions & 0 deletions browser/ui/android/strings/android_brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,12 @@ Are you sure you want to do this?
<message name="IDS_SHIELDS_SUMMARY" desc="Title for shields option.">
These are the default Shields settings for new sites. Changing these won't affect your existing per-site settings.
</message>
<message name="IDS_FINGERPRINT_LANGUAGE_SWITCH" desc="Title for fingerprint language switch">
Prevent fingerprinting via language settings
</message>
<message name="IDS_FINGERPRINT_LANGUAGE_SWITCH_SUMMARY" desc="Title for shields option fingerprint language">
Reduces how much websites can learn about you based on your browser's language settings.
</message>
<message name="IDS_BLOCK_FINGERPRINTING_TEXT" desc="Text for shields option.">
Prevents browser from recognizing your device
</message>
Expand Down

0 comments on commit 009d932

Please sign in to comment.