For #1084 - Update TP Policy for the current engineSession

nightly-build-test
Emily Kager 5 years ago committed by Emily Kager
parent 658f6dcf23
commit 43e0588d68

@ -135,7 +135,7 @@ class Core(private val context: Context) {
* in private browsing mode, default to the current preference value.
* @return the constructed tracking protection policy based on preferences.
*/
private fun createTrackingProtectionPolicy(
fun createTrackingProtectionPolicy(
normalMode: Boolean = Settings.getInstance(context).shouldUseTrackingProtection,
privateMode: Boolean = true
): TrackingProtectionPolicy {
@ -153,11 +153,6 @@ class Core(private val context: Context) {
}
}
fun updateTrackingProtection(newValue: Boolean) {
engine.settings.trackingProtectionPolicy =
createTrackingProtectionPolicy(normalMode = newValue)
}
/**
* Sets Preferred Color scheme based on Dark/Light Theme Settings or Current Configuration
*/

@ -31,7 +31,15 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {
val preferenceTP = findPreference<Preference>(trackingProtectionKey)
preferenceTP?.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _, newValue ->
requireComponents.core.updateTrackingProtection(newValue as Boolean)
with(requireComponents.core) {
val policy =
createTrackingProtectionPolicy(newValue as Boolean)
engine.settings.trackingProtectionPolicy = policy
with(sessionManager) {
sessions.forEach { getEngineSession(it)?.enableTrackingProtection(policy) }
}
}
true
}

Loading…
Cancel
Save