Skip to content

Commit

Permalink
Uplift of #6899 (squashed) to beta
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-browser-releases committed Oct 21, 2020
1 parent 66b0593 commit 9cb9a61
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 =
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
22 changes: 21 additions & 1 deletion android/java/res/xml/brave_privacy_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<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.ChromeBaseCheckBoxPreference
android:key="close_tabs_on_exit"
android:title="@string/close_tabs_on_exit_title"
Expand Down Expand Up @@ -40,4 +39,25 @@
android:key="autocomplete_brave_suggested_sites"
android:title="@string/autocomplete_brave_suggested_sites_title"
android:persistent="false"/>
<PreferenceCategory
android:key="brave_shields_social_blocking"
android:title="@string/brave_shields_social_blocking_title">

<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
android:key="social_blocking_google"
android:title="@string/brave_shields_social_blocking_google"
android:defaultValue="true" />
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
android:key="social_blocking_facebook"
android:title="@string/brave_shields_social_blocking_facebook"
android:defaultValue="true" />
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
android:key="social_blocking_twitter"
android:title="@string/brave_shields_social_blocking_twitter"
android:defaultValue="true" />
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
android:key="social_blocking_linkedin"
android:title="@string/brave_shields_social_blocking_linkedin"
android:defaultValue="false" />
</PreferenceCategory>
</PreferenceScreen>
28 changes: 28 additions & 0 deletions browser/android/preferences/brave_pref_service_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 15 additions & 0 deletions browser/ui/android/strings/android_brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,21 @@ This file contains all "about" strings. It is set to NOT be translated, in tran
<message name="IDS_BRAVE_SHIELDS_SCRIPTS_BLOCKED" desc="Scripts Blocked.">
Scripts Blocked
</message>
<message name="IDS_BRAVE_SHIELDS_SOCIAL_BLOCKING_TITLE" desc="Title for social media blocking.">
Social Media Blocking
</message>
<message name="IDS_BRAVE_SHIELDS_SOCIAL_BLOCKING_GOOGLE" desc="Label for a switch control which allows Google social buttons to be enabled/disabled">
Allow Google login buttons on third party sites
</message>
<message name="IDS_BRAVE_SHIELDS_SOCIAL_BLOCKING_FACEBOOK" desc="Label for a switch control which allows Facebook embedded posts">
Allow Facebook logins and embedded posts
</message>
<message name="IDS_BRAVE_SHIELDS_SOCIAL_BLOCKING_TWITTER" desc="Label for a switch control which allows Twitter embedded tweets">
Allow Twitter embedded tweets
</message>
<message name="IDS_BRAVE_SHIELDS_SOCIAL_BLOCKING_LINKEDIN" desc="Label for a switch control which allows LinkedIn embedded posts">
Allow LinkedIn embedded posts
</message>
<message name="IDS_BRAVE_SHIELDS_FIRST_GROUP_TITLE" desc="Title for the first group of Brave's shields panel.">
Blocking Monitor
</message>
Expand Down

0 comments on commit 9cb9a61

Please sign in to comment.