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