mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1634545 - Update GVE's tracking protection settings to fix some bugs and add more control. r=geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D73348
This commit is contained in:
parent
f558d21f4d
commit
a604ef3384
@ -382,6 +382,7 @@ public class GeckoViewActivity
|
||||
private GeckoView mGeckoView;
|
||||
private boolean mFullAccessibilityTree;
|
||||
private boolean mUseTrackingProtection;
|
||||
private String mEnhancedTackingProtection;
|
||||
private boolean mAllowAutoplay;
|
||||
private boolean mUsePrivateBrowsing;
|
||||
private boolean mEnableRemoteDebugging;
|
||||
@ -437,7 +438,9 @@ public class GeckoViewActivity
|
||||
boolean remoteDebugging = preferences.getBoolean(
|
||||
getString(R.string.key_remote_debugging), false);
|
||||
boolean trackingProtection = preferences.getBoolean(
|
||||
getString(R.string.key_tracking_protection), true);
|
||||
getString(R.string.key_tracking_protection), false);
|
||||
String enhancedTrackingProtection = preferences.getString(
|
||||
getString(R.string.key_enhanced_tracking_protection), "standard");
|
||||
boolean autoplay = preferences.getBoolean(
|
||||
getString(R.string.key_autoplay), false);
|
||||
int colorScheme = Integer.parseInt(preferences.getString(
|
||||
@ -459,16 +462,36 @@ public class GeckoViewActivity
|
||||
final GeckoSession currentSession = mTabSessionManager.getCurrentSession();
|
||||
|
||||
if (mUseTrackingProtection != trackingProtection) {
|
||||
mTabSessionManager.setUseTrackingProtection(trackingProtection);
|
||||
if (sGeckoRuntime != null) {
|
||||
sGeckoRuntime.getSettings().getContentBlocking()
|
||||
.setStrictSocialTrackingProtection(mUseTrackingProtection);
|
||||
}
|
||||
if (currentSession != null) {
|
||||
currentSession.reload();
|
||||
sGeckoRuntime.getSettings().getContentBlocking().setStrictSocialTrackingProtection(trackingProtection);
|
||||
}
|
||||
mUseTrackingProtection = trackingProtection;
|
||||
}
|
||||
|
||||
if (mEnhancedTackingProtection != enhancedTrackingProtection) {
|
||||
int etpLevel;
|
||||
switch (enhancedTrackingProtection) {
|
||||
case "disabled":
|
||||
etpLevel = ContentBlocking.EtpLevel.NONE;
|
||||
break;
|
||||
case "standard":
|
||||
etpLevel = ContentBlocking.EtpLevel.DEFAULT;
|
||||
break;
|
||||
case "strict":
|
||||
etpLevel = ContentBlocking.EtpLevel.STRICT;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Invalid ETP level: " + enhancedTrackingProtection);
|
||||
}
|
||||
|
||||
if (sGeckoRuntime != null) {
|
||||
sGeckoRuntime.getSettings().getContentBlocking().setEnhancedTrackingProtectionLevel(etpLevel);
|
||||
}
|
||||
|
||||
mEnhancedTackingProtection = enhancedTrackingProtection;
|
||||
}
|
||||
|
||||
if (mAllowAutoplay != autoplay) {
|
||||
if (currentSession != null) {
|
||||
currentSession.reload();
|
||||
@ -787,6 +810,7 @@ public class GeckoViewActivity
|
||||
.userAgentMode(mDesktopMode
|
||||
? GeckoSessionSettings.USER_AGENT_MODE_DESKTOP
|
||||
: GeckoSessionSettings.USER_AGENT_MODE_MOBILE)
|
||||
.useTrackingProtection(mUseTrackingProtection)
|
||||
.build());
|
||||
connectSession(session);
|
||||
|
||||
|
@ -12,6 +12,7 @@ public class TabSessionManager {
|
||||
private static ArrayList<TabSession> mTabSessions = new ArrayList<>();
|
||||
private int mCurrentSessionIndex = 0;
|
||||
private TabObserver mTabObserver;
|
||||
private boolean mTrackingProtection;
|
||||
|
||||
public interface TabObserver {
|
||||
void onCurrentSession(TabSession session);
|
||||
@ -37,6 +38,17 @@ public class TabSessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void setUseTrackingProtection(boolean trackingProtection) {
|
||||
if (trackingProtection == mTrackingProtection) {
|
||||
return;
|
||||
}
|
||||
mTrackingProtection = trackingProtection;
|
||||
|
||||
for (final TabSession session : mTabSessions) {
|
||||
session.getSettings().setUseTrackingProtection(trackingProtection);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTabObserver(TabObserver observer) {
|
||||
mTabObserver = observer;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@
|
||||
|
||||
# Preference Keys
|
||||
<string name="key_tracking_protection">tracking_protection</string>
|
||||
<string name="key_enhanced_tracking_protection">enhanced_tracking_protection</string>
|
||||
<string name="key_autoplay">autoplay</string>
|
||||
<string name="key_remote_debugging">remote_debugging</string>
|
||||
<string name="key_allow_extensions_in_private_browsing">allow_extensions_in_private_browsing</string>
|
||||
@ -79,4 +80,15 @@
|
||||
<item>Mozilla/5.0 (iPhone; CPU OS 10_15_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Mobile/14E304 Safari/605.1.15</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="enhanced_tracking_protection_display_names">
|
||||
<item>Disabled</item>
|
||||
<item>Enabled (standard)</item>
|
||||
<item>Enabled (strict)</item>
|
||||
</string-array>
|
||||
<string-array name="enhanced_tracking_protection_values">
|
||||
<item>disabled</item>
|
||||
<item>standard</item>
|
||||
<item>strict</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
@ -4,6 +4,14 @@
|
||||
<SwitchPreferenceCompat
|
||||
app:key="@string/key_tracking_protection"
|
||||
app:title="Enable Tracking Protection"/>
|
||||
<ListPreference
|
||||
app:key="@string/key_enhanced_tracking_protection"
|
||||
app:title="Enhanced Tracking Protection"
|
||||
app:summary="%s"
|
||||
app:entries="@array/enhanced_tracking_protection_display_names"
|
||||
app:entryValues="@array/enhanced_tracking_protection_values"
|
||||
app:defaultValue="standard">
|
||||
</ListPreference>
|
||||
<SwitchPreferenceCompat
|
||||
app:key="@string/key_autoplay"
|
||||
app:title="Allow Autoplay"/>
|
||||
|
Loading…
Reference in New Issue
Block a user