For #13221 - Update global ETP to include PBM
parent
c9f8986d2b
commit
a1a839f237
|
@ -24,7 +24,7 @@ class TrackingProtectionPolicyFactory(private val settings: Settings) {
|
|||
@Suppress("ComplexMethod")
|
||||
fun createTrackingProtectionPolicy(
|
||||
normalMode: Boolean = settings.shouldUseTrackingProtection,
|
||||
privateMode: Boolean = true
|
||||
privateMode: Boolean = settings.shouldUseTrackingProtection
|
||||
): TrackingProtectionPolicy {
|
||||
val trackingProtectionPolicy =
|
||||
when {
|
||||
|
|
|
@ -77,8 +77,7 @@ class OnboardingTrackingProtectionViewHolder(view: View) : RecyclerView.ViewHold
|
|||
private fun updateTrackingProtectionSetting(enabled: Boolean) {
|
||||
itemView.context.settings().shouldUseTrackingProtection = enabled
|
||||
with(itemView.context.components) {
|
||||
val policy = core.trackingProtectionPolicyFactory
|
||||
.createTrackingProtectionPolicy(enabled)
|
||||
val policy = core.trackingProtectionPolicyFactory.createTrackingProtectionPolicy()
|
||||
useCases.settingsUseCases.updateTrackingProtection.invoke(policy)
|
||||
useCases.sessionUseCases.reload.invoke()
|
||||
}
|
||||
|
|
|
@ -64,8 +64,7 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {
|
|||
preference.context.settings().shouldUseTrackingProtection =
|
||||
trackingProtectionOn
|
||||
with(preference.context.components) {
|
||||
val policy = core.trackingProtectionPolicyFactory
|
||||
.createTrackingProtectionPolicy(trackingProtectionOn)
|
||||
val policy = core.trackingProtectionPolicyFactory.createTrackingProtectionPolicy()
|
||||
useCases.settingsUseCases.updateTrackingProtection(policy)
|
||||
useCases.sessionUseCases.reload()
|
||||
}
|
||||
|
|
|
@ -198,6 +198,18 @@ class TrackingProtectionPolicyFactoryTest {
|
|||
// `normalMode = true, privateMode = true` can never be shown to the user
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `factory should follow global ETP settings by default`() {
|
||||
var useETPFactory = TrackingProtectionPolicyFactory(mockSettings(useTrackingProtection = true))
|
||||
var policy = useETPFactory.createTrackingProtectionPolicy()
|
||||
assertTrue(policy.useForPrivateSessions)
|
||||
assertTrue(policy.useForRegularSessions)
|
||||
|
||||
useETPFactory = TrackingProtectionPolicyFactory(mockSettings(useTrackingProtection = false))
|
||||
policy = useETPFactory.createTrackingProtectionPolicy()
|
||||
assertEquals(policy, EngineSession.TrackingProtectionPolicy.none())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `custom tabs should respect their privacy rules`() {
|
||||
val allSettings = listOf(
|
||||
|
@ -315,10 +327,12 @@ class TrackingProtectionPolicyFactoryTest {
|
|||
|
||||
private fun mockSettings(
|
||||
useStrict: Boolean = false,
|
||||
useCustom: Boolean = false
|
||||
useCustom: Boolean = false,
|
||||
useTrackingProtection: Boolean = false
|
||||
): Settings = mockk {
|
||||
every { useStrictTrackingProtection } returns useStrict
|
||||
every { useCustomTrackingProtection } returns useCustom
|
||||
every { shouldUseTrackingProtection } returns useTrackingProtection
|
||||
}
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
|
|
Loading…
Reference in New Issue