From 6db2c727ec521ac62e6d99525b973cc29cc559e6 Mon Sep 17 00:00:00 2001 From: Arturo Mejia Date: Wed, 7 Sep 2022 10:25:25 -0400 Subject: [PATCH] [fenix] Closes https://github.com/mozilla-mobile/fenix/issues/26858: Remove unused nimbus engine-settings total-cookie-protection-enabled feature. --- .experimenter.yaml | 3 -- .../TrackingProtectionPolicyFactory.kt | 33 ++-------------- .../java/org/mozilla/fenix/utils/Settings.kt | 3 -- .../TrackingProtectionPolicyFactoryTest.kt | 38 ------------------- nimbus.fml.yaml | 4 -- 5 files changed, 4 insertions(+), 77 deletions(-) diff --git a/.experimenter.yaml b/.experimenter.yaml index 0d1d7dff29..48a8cf70a6 100644 --- a/.experimenter.yaml +++ b/.experimenter.yaml @@ -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 diff --git a/app/src/main/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactory.kt b/app/src/main/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactory.kt index 7ceca624ce..1001c95f12 100644 --- a/app/src/main/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactory.kt +++ b/app/src/main/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactory.kt @@ -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 - ) -} diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index c9a2a96718..dacde494e3 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -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 diff --git a/app/src/test/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactoryTest.kt b/app/src/test/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactoryTest.kt index 98918ed3c9..63c6c318fa 100644 --- a/app/src/test/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactoryTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactoryTest.kt @@ -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( diff --git a/nimbus.fml.yaml b/nimbus.fml.yaml index 1e7e6d27a9..5caf65dd23 100644 --- a/nimbus.fml.yaml +++ b/nimbus.fml.yaml @@ -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: