Closes #26858: Remove unused nimbus engine-settings total-cookie-protection-enabled feature.

This commit is contained in:
Arturo Mejia 2022-09-07 10:25:25 -04:00
parent de38ada14e
commit 49bef5d309
5 changed files with 4 additions and 77 deletions

View File

@ -7,9 +7,6 @@ engine-settings:
tabs-prioritization-enabled:
type: boolean
description: "If true, enables tabs prioritization feature."
total-cookie-protection-enabled:
type: boolean
description: "If true, enables the total cookie protection in all browsing modes."
homescreen:
description: The homescreen that the user goes to when they press home or new tab.
hasExposure: true

View File

@ -5,10 +5,8 @@
package org.mozilla.fenix.components
import android.content.res.Resources
import androidx.annotation.VisibleForTesting
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy.CookiePolicy
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicyForSessionTypes
import org.mozilla.fenix.R
import org.mozilla.fenix.utils.Settings
@ -42,22 +40,16 @@ class TrackingProtectionPolicyFactory(
}
return when {
normalMode && privateMode -> trackingProtectionPolicy.applyTCPIfNeeded(settings)
normalMode && !privateMode -> trackingProtectionPolicy.applyTCPIfNeeded(settings).forRegularSessionsOnly()
!normalMode && privateMode -> trackingProtectionPolicy.applyTCPIfNeeded(settings).forPrivateSessionsOnly()
normalMode && privateMode -> trackingProtectionPolicy
normalMode && !privateMode -> trackingProtectionPolicy.forRegularSessionsOnly()
!normalMode && privateMode -> trackingProtectionPolicy.forPrivateSessionsOnly()
else -> TrackingProtectionPolicy.none()
}
}
private fun createCustomTrackingProtectionPolicy(): TrackingProtectionPolicy {
val cookiePolicy = if (settings.enabledTotalCookieProtection) {
CookiePolicy.ACCEPT_FIRST_PARTY_AND_ISOLATE_OTHERS
} else {
getCustomCookiePolicy()
}
return TrackingProtectionPolicy.select(
cookiePolicy = cookiePolicy,
cookiePolicy = getCustomCookiePolicy(),
trackingCategories = getCustomTrackingCategories(),
cookiePurging = getCustomCookiePurgingPolicy()
).let {
@ -111,20 +103,3 @@ class TrackingProtectionPolicyFactory(
return settings.blockRedirectTrackersInCustomTrackingProtection
}
}
@VisibleForTesting
internal fun TrackingProtectionPolicyForSessionTypes.applyTCPIfNeeded(settings: Settings):
TrackingProtectionPolicyForSessionTypes {
val updatedCookiePolicy = if (settings.enabledTotalCookieProtection) {
CookiePolicy.ACCEPT_FIRST_PARTY_AND_ISOLATE_OTHERS
} else {
cookiePolicy
}
return TrackingProtectionPolicy.select(
trackingCategories = trackingCategories,
cookiePolicy = updatedCookiePolicy,
strictSocialTrackingProtection = strictSocialTrackingProtection,
cookiePurging = cookiePurging
)
}

View File

@ -584,9 +584,6 @@ class Settings(private val appContext: Context) : PreferencesHolder {
true
)
val enabledTotalCookieProtection: Boolean
get() = mr2022Sections[Mr2022Section.TCP_FEATURE] == true
val enabledTotalCookieProtectionSetting: Boolean
get() = mr2022Sections[Mr2022Section.TCP_FEATURE] == true

View File

@ -137,44 +137,6 @@ class TrackingProtectionPolicyFactoryTest {
expected.assertPolicyEquals(always, checkPrivacy = false)
}
@Test
fun `GIVEN TCP is enabled by nimbus WHEN applyTCPIfNeeded THEN cookie policy should be TCP`() {
val settings: Settings = mockk(relaxed = true)
every { settings.enabledTotalCookieProtection } returns true
val policies = arrayOf(
TrackingProtectionPolicy.strict(), TrackingProtectionPolicy.recommended(),
TrackingProtectionPolicy.select()
)
for (policy in policies) {
val adaptedPolicy = policy.applyTCPIfNeeded(settings)
assertEquals(
CookiePolicy.ACCEPT_FIRST_PARTY_AND_ISOLATE_OTHERS,
adaptedPolicy.cookiePolicy
)
}
}
fun `GIVEN TCP is NOT enabled by nimbus WHEN applyTCPIfNeeded THEN reuse cookie policy`() {
val settings: Settings = mockk(relaxed = true)
every { settings.enabledTotalCookieProtection } returns false
val policies = arrayOf(
TrackingProtectionPolicy.strict(), TrackingProtectionPolicy.recommended(),
TrackingProtectionPolicy.select()
)
for (policy in policies) {
val adaptedPolicy = policy.applyTCPIfNeeded(settings)
assertEquals(
policy.cookiePolicy,
adaptedPolicy.cookiePolicy
)
}
}
@Test
fun `GIVEN custom policy WHEN cookie policy social THEN tracking policy should have cookie policy allow non-trackers`() {
val expected = TrackingProtectionPolicy.select(

View File

@ -226,10 +226,6 @@ features:
description: If true, enables tabs prioritization feature.
type: Boolean
default: true
total-cookie-protection-enabled:
description: If true, enables the total cookie protection in all browsing modes.
type: Boolean
default: false
types:
objects:
MessageData: