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