diff --git a/app/src/main/java/org/mozilla/fenix/components/Core.kt b/app/src/main/java/org/mozilla/fenix/components/Core.kt index bd2d4a124217..09e2786eaf03 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Core.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Core.kt @@ -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 */ diff --git a/app/src/main/java/org/mozilla/fenix/settings/TrackingProtectionFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/TrackingProtectionFragment.kt index 72f61f7bbc33..3662957ea7ba 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/TrackingProtectionFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/TrackingProtectionFragment.kt @@ -31,7 +31,15 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() { val preferenceTP = findPreference(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 }