diff --git a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java index c9e190e6572d..dbb2a62986d4 100644 --- a/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java +++ b/android/java/org/chromium/chrome/browser/preferences/BravePrefServiceBridge.java @@ -34,6 +34,34 @@ public void setHTTPSEEnabled(boolean enabled) { BravePrefServiceBridgeJni.get().setHTTPSEEnabled(enabled); } + /** + * @param whether google login is enabled on third party sites. + */ + public void setThirdPartyGoogleLoginEnabled(boolean enabled) { + BravePrefServiceBridgeJni.get().setThirdPartyGoogleLoginEnabled(enabled); + } + + /** + * @param whether facebook embeds are allowed on third party sites. + */ + public void setThirdPartyFacebookEmbedEnabled(boolean enabled) { + BravePrefServiceBridgeJni.get().setThirdPartyFacebookEmbedEnabled(enabled); + } + + /** + * @param whether twitter embeds are allowed on third party sites. + */ + public void setThirdPartyTwitterEmbedEnabled(boolean enabled) { + BravePrefServiceBridgeJni.get().setThirdPartyTwitterEmbedEnabled(enabled); + } + + /** + * @param whether linkedin embeds are allowed on third party sites. + */ + public void setThirdPartyLinkedinEmbedEnabled(boolean enabled) { + BravePrefServiceBridgeJni.get().setThirdPartyLinkedinEmbedEnabled(enabled); + } + /** * @param whether AdBlock should be enabled. */ @@ -149,6 +177,11 @@ interface Natives { void setAdBlockEnabled(boolean enabled); void setFingerprintingProtectionEnabled(boolean enabled); + void setThirdPartyGoogleLoginEnabled(boolean enabled); + void setThirdPartyFacebookEmbedEnabled(boolean enabled); + void setThirdPartyTwitterEmbedEnabled(boolean enabled); + void setThirdPartyLinkedinEmbedEnabled(boolean enabled); + void setPlayYTVideoInBrowserEnabled(boolean enabled); boolean getPlayYTVideoInBrowserEnabled(); diff --git a/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java b/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java index 064d7200e671..7d7b16f434c1 100644 --- a/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java +++ b/android/java/org/chromium/chrome/browser/privacy/settings/BravePrivacySettings.java @@ -9,6 +9,7 @@ import android.os.Bundle; import androidx.preference.Preference; +import androidx.preference.PreferenceCategory; import org.chromium.base.ContextUtils; import org.chromium.chrome.R; @@ -34,6 +35,11 @@ public class BravePrivacySettings extends PrivacySettings { private static final String PREF_AUTOCOMPLETE_TOP_SITES = "autocomplete_top_sites"; private static final String PREF_AUTOCOMPLETE_BRAVE_SUGGESTED_SITES = "autocomplete_brave_suggested_sites"; private static final String PREF_CLEAR_BROWSING_DATA = "clear_browsing_data"; + private static final String PREF_SOCIAL_BLOCKING = "brave_shields_social_blocking"; + private static final String PREF_SOCIAL_BLOCKING_GOOGLE = "social_blocking_google"; + private static final String PREF_SOCIAL_BLOCKING_FACEBOOK = "social_blocking_facebook"; + private static final String PREF_SOCIAL_BLOCKING_TWITTER = "social_blocking_twitter"; + private static final String PREF_SOCIAL_BLOCKING_LINKEDIN = "social_blocking_linkedin"; private final PrefService mPrefServiceBridge = UserPrefs.get(Profile.getLastUsedRegularProfile()); private final ChromeManagedPreferenceDelegate mManagedPreferenceDelegate = @@ -45,6 +51,11 @@ public class BravePrivacySettings extends PrivacySettings { private ChromeBaseCheckBoxPreference mAdBlockPref; private ChromeBaseCheckBoxPreference mFingerprintingProtectionPref; private ChromeBaseCheckBoxPreference mCloseTabsOnExitPref; + private PreferenceCategory mSocialBlockingCategory; + private ChromeSwitchPreference mSocialBlockingGoogle; + private ChromeSwitchPreference mSocialBlockingFacebook; + private ChromeSwitchPreference mSocialBlockingTwitter; + private ChromeSwitchPreference mSocialBlockingLinkedin; @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { @@ -76,6 +87,21 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { mAutocompleteBraveSuggestedSites = (ChromeSwitchPreference) findPreference(PREF_AUTOCOMPLETE_BRAVE_SUGGESTED_SITES); mAutocompleteBraveSuggestedSites.setOnPreferenceChangeListener(this); + mSocialBlockingCategory = (PreferenceCategory) findPreference(PREF_SOCIAL_BLOCKING); + mSocialBlockingCategory.setOnPreferenceChangeListener(this); + + mSocialBlockingGoogle = (ChromeSwitchPreference) findPreference(PREF_SOCIAL_BLOCKING_GOOGLE); + mSocialBlockingGoogle.setOnPreferenceChangeListener(this); + + mSocialBlockingFacebook = (ChromeSwitchPreference) findPreference(PREF_SOCIAL_BLOCKING_FACEBOOK); + mSocialBlockingFacebook.setOnPreferenceChangeListener(this); + + mSocialBlockingTwitter = (ChromeSwitchPreference) findPreference(PREF_SOCIAL_BLOCKING_TWITTER); + mSocialBlockingTwitter.setOnPreferenceChangeListener(this); + + mSocialBlockingLinkedin = (ChromeSwitchPreference) findPreference(PREF_SOCIAL_BLOCKING_LINKEDIN); + mSocialBlockingLinkedin.setOnPreferenceChangeListener(this); + updatePreferences(); } @@ -103,6 +129,18 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } else if (PREF_AUTOCOMPLETE_BRAVE_SUGGESTED_SITES.equals(key)) { UserPrefs.get(Profile.getLastUsedRegularProfile()).setBoolean(BravePref.BRAVE_SUGGESTED_SITE_SUGGESTIONS_ENABLED, (boolean) newValue); + } else if (PREF_SOCIAL_BLOCKING_GOOGLE.equals(key)) { + BravePrefServiceBridge.getInstance().setThirdPartyGoogleLoginEnabled( + (boolean) newValue); + } else if (PREF_SOCIAL_BLOCKING_FACEBOOK.equals(key)) { + BravePrefServiceBridge.getInstance().setThirdPartyFacebookEmbedEnabled( + (boolean) newValue); + } else if (PREF_SOCIAL_BLOCKING_TWITTER.equals(key)) { + BravePrefServiceBridge.getInstance().setThirdPartyTwitterEmbedEnabled( + (boolean) newValue); + } else if (PREF_SOCIAL_BLOCKING_LINKEDIN.equals(key)) { + BravePrefServiceBridge.getInstance().setThirdPartyLinkedinEmbedEnabled( + (boolean) newValue); } return true; @@ -129,6 +167,7 @@ private void updatePreferences() { mAutocompleteBraveSuggestedSites.setChecked( UserPrefs.get(Profile.getLastUsedRegularProfile()).getBoolean(BravePref.BRAVE_SUGGESTED_SITE_SUGGESTIONS_ENABLED)); mAutocompleteBraveSuggestedSites.setOrder(++order); + mSocialBlockingCategory.setOrder(++order); } private void removePreferenceIfPresent(String key) { diff --git a/android/java/res/xml/brave_privacy_preferences.xml b/android/java/res/xml/brave_privacy_preferences.xml index f8c7872466bc..43b011da601f 100644 --- a/android/java/res/xml/brave_privacy_preferences.xml +++ b/android/java/res/xml/brave_privacy_preferences.xml @@ -6,7 +6,6 @@ - + + + + + + + diff --git a/browser/android/preferences/brave_pref_service_bridge.cc b/browser/android/preferences/brave_pref_service_bridge.cc index d540aa7e9637..2c8a3a217474 100644 --- a/browser/android/preferences/brave_pref_service_bridge.cc +++ b/browser/android/preferences/brave_pref_service_bridge.cc @@ -52,6 +52,34 @@ void JNI_BravePrefServiceBridge_SetHTTPSEEnabled( g_browser_process->local_state()); } +void JNI_BravePrefServiceBridge_SetThirdPartyGoogleLoginEnabled( + JNIEnv* env, + jboolean enabled) { + GetOriginalProfile()->GetPrefs()->SetBoolean( + kGoogleLoginControlType, enabled); +} + +void JNI_BravePrefServiceBridge_SetThirdPartyFacebookEmbedEnabled( + JNIEnv* env, + jboolean enabled) { + GetOriginalProfile()->GetPrefs()->SetBoolean( + kFBEmbedControlType, enabled); +} + +void JNI_BravePrefServiceBridge_SetThirdPartyTwitterEmbedEnabled( + JNIEnv* env, + jboolean enabled) { + GetOriginalProfile()->GetPrefs()->SetBoolean( + kTwitterEmbedControlType, enabled); +} + +void JNI_BravePrefServiceBridge_SetThirdPartyLinkedinEmbedEnabled( + JNIEnv* env, + jboolean enabled) { + GetOriginalProfile()->GetPrefs()->SetBoolean( + kLinkedInEmbedControlType, enabled); +} + void JNI_BravePrefServiceBridge_SetAdBlockEnabled( JNIEnv* env, jboolean enabled) { diff --git a/browser/ui/android/strings/android_brave_strings.grd b/browser/ui/android/strings/android_brave_strings.grd index a44fb69be46d..b5b17bd6bde6 100644 --- a/browser/ui/android/strings/android_brave_strings.grd +++ b/browser/ui/android/strings/android_brave_strings.grd @@ -175,6 +175,21 @@ This file contains all "about" strings. It is set to NOT be translated, in tran Scripts Blocked + + Social Media Blocking + + + Allow Google login buttons on third party sites + + + Allow Facebook logins and embedded posts + + + Allow Twitter embedded tweets + + + Allow LinkedIn embedded posts + Blocking Monitor