mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
Bug 1816186 - Use detect-only just when we can show the re-engagement dialog
This commit is contained in:
parent
b275c973a8
commit
4d87860b2e
@ -132,6 +132,7 @@ import org.mozilla.fenix.settings.TrackingProtectionFragmentDirections
|
|||||||
import org.mozilla.fenix.settings.about.AboutFragmentDirections
|
import org.mozilla.fenix.settings.about.AboutFragmentDirections
|
||||||
import org.mozilla.fenix.settings.logins.fragment.LoginDetailFragmentDirections
|
import org.mozilla.fenix.settings.logins.fragment.LoginDetailFragmentDirections
|
||||||
import org.mozilla.fenix.settings.logins.fragment.SavedLoginsAuthFragmentDirections
|
import org.mozilla.fenix.settings.logins.fragment.SavedLoginsAuthFragmentDirections
|
||||||
|
import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.dialog.CookieBannerReEngagementDialogUtils
|
||||||
import org.mozilla.fenix.settings.search.AddSearchEngineFragmentDirections
|
import org.mozilla.fenix.settings.search.AddSearchEngineFragmentDirections
|
||||||
import org.mozilla.fenix.settings.search.EditCustomSearchEngineFragmentDirections
|
import org.mozilla.fenix.settings.search.EditCustomSearchEngineFragmentDirections
|
||||||
import org.mozilla.fenix.settings.studies.StudiesFragmentDirections
|
import org.mozilla.fenix.settings.studies.StudiesFragmentDirections
|
||||||
@ -445,6 +446,10 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
|||||||
// and the user changes the system language
|
// and the user changes the system language
|
||||||
// More details here: https://github.com/mozilla-mobile/fenix/pull/27793#discussion_r1029892536
|
// More details here: https://github.com/mozilla-mobile/fenix/pull/27793#discussion_r1029892536
|
||||||
components.core.store.dispatch(SearchAction.RefreshSearchEnginesAction)
|
components.core.store.dispatch(SearchAction.RefreshSearchEnginesAction)
|
||||||
|
CookieBannerReEngagementDialogUtils.tryToEnableDetectOnlyModeIfNeeded(
|
||||||
|
components.settings,
|
||||||
|
components.core.engine.settings,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
@ -140,7 +140,7 @@ class Core(
|
|||||||
cookieBannerHandlingModePrivateBrowsing = context.settings().getCookieBannerHandling(),
|
cookieBannerHandlingModePrivateBrowsing = context.settings().getCookieBannerHandling(),
|
||||||
cookieBannerHandlingMode = context.settings().getCookieBannerHandling(),
|
cookieBannerHandlingMode = context.settings().getCookieBannerHandling(),
|
||||||
cookieBannerHandlingDetectOnlyMode = context.settings()
|
cookieBannerHandlingDetectOnlyMode = context.settings()
|
||||||
.shouldEnabledCookieBannerDetectOnlyMode(),
|
.shouldShowCookieBannerReEngagementDialog(),
|
||||||
)
|
)
|
||||||
|
|
||||||
GeckoEngine(
|
GeckoEngine(
|
||||||
|
@ -53,7 +53,7 @@ class CookieBannersFragment : PreferenceFragmentCompat() {
|
|||||||
getEngineSettings().cookieBannerHandlingModePrivateBrowsing = mode
|
getEngineSettings().cookieBannerHandlingModePrivateBrowsing = mode
|
||||||
getEngineSettings().cookieBannerHandlingMode = mode
|
getEngineSettings().cookieBannerHandlingMode = mode
|
||||||
getEngineSettings().cookieBannerHandlingDetectOnlyMode =
|
getEngineSettings().cookieBannerHandlingDetectOnlyMode =
|
||||||
requireContext().settings().shouldEnabledCookieBannerDetectOnlyMode()
|
requireContext().settings().shouldShowCookieBannerReEngagementDialog()
|
||||||
CookieBanners.settingChanged.record(CookieBanners.SettingChangedExtra(metricTag))
|
CookieBanners.settingChanged.record(CookieBanners.SettingChangedExtra(metricTag))
|
||||||
requireContext().components.useCases.sessionUseCases.reload()
|
requireContext().components.useCases.sessionUseCases.reload()
|
||||||
return super.onPreferenceChange(preference, newValue)
|
return super.onPreferenceChange(preference, newValue)
|
||||||
|
@ -62,13 +62,12 @@ class CookieBannerReEngagementDialog : DialogFragment() {
|
|||||||
dismiss()
|
dismiss()
|
||||||
},
|
},
|
||||||
onNotNowButtonClicked = {
|
onNotNowButtonClicked = {
|
||||||
|
disabledCookieBannerHandlingDetectOnlyMode()
|
||||||
CookieBanners.notNowReEngagementDialog.record(NoExtras())
|
CookieBanners.notNowReEngagementDialog.record(NoExtras())
|
||||||
dismiss()
|
dismiss()
|
||||||
},
|
},
|
||||||
onCloseButtonClicked = {
|
onCloseButtonClicked = {
|
||||||
getEngineSettings().cookieBannerHandlingDetectOnlyMode = false
|
disabledCookieBannerHandlingDetectOnlyMode()
|
||||||
getEngineSettings().cookieBannerHandlingModePrivateBrowsing = DISABLED
|
|
||||||
getEngineSettings().cookieBannerHandlingMode = DISABLED
|
|
||||||
requireContext().settings().userOptOutOfReEngageCookieBannerDialog = true
|
requireContext().settings().userOptOutOfReEngageCookieBannerDialog = true
|
||||||
CookieBanners.optOutReEngagementDialog.record(NoExtras())
|
CookieBanners.optOutReEngagementDialog.record(NoExtras())
|
||||||
dismiss()
|
dismiss()
|
||||||
@ -78,6 +77,12 @@ class CookieBannerReEngagementDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun disabledCookieBannerHandlingDetectOnlyMode() {
|
||||||
|
getEngineSettings().cookieBannerHandlingDetectOnlyMode = false
|
||||||
|
getEngineSettings().cookieBannerHandlingModePrivateBrowsing = DISABLED
|
||||||
|
getEngineSettings().cookieBannerHandlingMode = DISABLED
|
||||||
|
}
|
||||||
|
|
||||||
private fun getEngineSettings(): Settings {
|
private fun getEngineSettings(): Settings {
|
||||||
return requireContext().components.core.engine.settings
|
return requireContext().components.core.engine.settings
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ package org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.dialo
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
|
import mozilla.components.concept.engine.EngineSession.CookieBannerHandlingMode.REJECT_ALL
|
||||||
import mozilla.components.concept.engine.EngineSession.CookieBannerHandlingStatus
|
import mozilla.components.concept.engine.EngineSession.CookieBannerHandlingStatus
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.browser.BrowserFragmentDirections
|
import org.mozilla.fenix.browser.BrowserFragmentDirections
|
||||||
@ -13,6 +14,7 @@ import org.mozilla.fenix.ext.nav
|
|||||||
import org.mozilla.fenix.nimbus.CookieBannersSection
|
import org.mozilla.fenix.nimbus.CookieBannersSection
|
||||||
import org.mozilla.fenix.nimbus.FxNimbus
|
import org.mozilla.fenix.nimbus.FxNimbus
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
|
import mozilla.components.concept.engine.Settings as EngineSettings
|
||||||
|
|
||||||
private const val CONTROL_VARIANT = 0
|
private const val CONTROL_VARIANT = 0
|
||||||
private const val VARIANT_ONE = 1
|
private const val VARIANT_ONE = 1
|
||||||
@ -87,8 +89,13 @@ object CookieBannerReEngagementDialogUtils {
|
|||||||
status: CookieBannerHandlingStatus,
|
status: CookieBannerHandlingStatus,
|
||||||
navController: NavController,
|
navController: NavController,
|
||||||
) {
|
) {
|
||||||
if (status == CookieBannerHandlingStatus.DETECTED &&
|
val tcpCFRAlreadyShown = if (settings.enabledTotalCookieProtectionCFR) {
|
||||||
settings.shouldCookieBannerReEngagementDialog()
|
!settings.shouldShowTotalCookieProtectionCFR
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
if (tcpCFRAlreadyShown && status == CookieBannerHandlingStatus.DETECTED &&
|
||||||
|
settings.shouldShowCookieBannerReEngagementDialog()
|
||||||
) {
|
) {
|
||||||
settings.lastInteractionWithReEngageCookieBannerDialogInMs = System.currentTimeMillis()
|
settings.lastInteractionWithReEngageCookieBannerDialogInMs = System.currentTimeMillis()
|
||||||
settings.cookieBannerDetectedPreviously = true
|
settings.cookieBannerDetectedPreviously = true
|
||||||
@ -98,6 +105,21 @@ object CookieBannerReEngagementDialogUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to enable the detect only mode after the time limit for the cookie banner has been
|
||||||
|
* expired.
|
||||||
|
*/
|
||||||
|
fun tryToEnableDetectOnlyModeIfNeeded(
|
||||||
|
settings: Settings,
|
||||||
|
engineSettings: EngineSettings,
|
||||||
|
) {
|
||||||
|
if (settings.shouldShowCookieBannerReEngagementDialog()) {
|
||||||
|
engineSettings.cookieBannerHandlingDetectOnlyMode = true
|
||||||
|
engineSettings.cookieBannerHandlingModePrivateBrowsing = REJECT_ALL
|
||||||
|
engineSettings.cookieBannerHandlingMode = REJECT_ALL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data class for cookie banner dialog variant
|
* Data class for cookie banner dialog variant
|
||||||
* @property title of the dialog
|
* @property title of the dialog
|
||||||
|
@ -586,10 +586,10 @@ class Settings(private val appContext: Context) : PreferencesHolder {
|
|||||||
* Indicates if we should should show the cookie banner dialog that invites the user to turn-on
|
* Indicates if we should should show the cookie banner dialog that invites the user to turn-on
|
||||||
* the setting.
|
* the setting.
|
||||||
*/
|
*/
|
||||||
fun shouldCookieBannerReEngagementDialog(): Boolean {
|
fun shouldShowCookieBannerReEngagementDialog(): Boolean {
|
||||||
val shouldShowDialog =
|
val shouldShowDialog =
|
||||||
shouldShowCookieBannerUI && !userOptOutOfReEngageCookieBannerDialog && !shouldUseCookieBanner
|
shouldShowCookieBannerUI && !userOptOutOfReEngageCookieBannerDialog && !shouldUseCookieBanner
|
||||||
return if (!shouldShowTotalCookieProtectionCFR && shouldShowDialog) {
|
return if (shouldShowDialog) {
|
||||||
!cookieBannerDetectedPreviously ||
|
!cookieBannerDetectedPreviously ||
|
||||||
timeNowInMillis() - lastInteractionWithReEngageCookieBannerDialogInMs >= timerForCookieBannerDialog
|
timeNowInMillis() - lastInteractionWithReEngageCookieBannerDialogInMs >= timerForCookieBannerDialog
|
||||||
} else {
|
} else {
|
||||||
@ -704,7 +704,10 @@ class Settings(private val appContext: Context) : PreferencesHolder {
|
|||||||
val enabledTotalCookieProtection: Boolean
|
val enabledTotalCookieProtection: Boolean
|
||||||
get() = Config.channel.isNightlyOrDebug || mr2022Sections[Mr2022Section.TCP_FEATURE] == true
|
get() = Config.channel.isNightlyOrDebug || mr2022Sections[Mr2022Section.TCP_FEATURE] == true
|
||||||
|
|
||||||
private val enabledTotalCookieProtectionCFR: Boolean
|
/**
|
||||||
|
* Indicates if the total cookie protection CRF feature is enabled.
|
||||||
|
*/
|
||||||
|
val enabledTotalCookieProtectionCFR: Boolean
|
||||||
get() = Config.channel.isNightlyOrDebug || mr2022Sections[Mr2022Section.TCP_CFR] == true
|
get() = Config.channel.isNightlyOrDebug || mr2022Sections[Mr2022Section.TCP_CFR] == true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1557,7 +1560,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
|
|||||||
fun getCookieBannerHandling(): CookieBannerHandlingMode {
|
fun getCookieBannerHandling(): CookieBannerHandlingMode {
|
||||||
return when (shouldUseCookieBanner) {
|
return when (shouldUseCookieBanner) {
|
||||||
true -> CookieBannerHandlingMode.REJECT_ALL
|
true -> CookieBannerHandlingMode.REJECT_ALL
|
||||||
false -> if (shouldEnabledCookieBannerDetectOnlyMode()) {
|
false -> if (shouldShowCookieBannerReEngagementDialog()) {
|
||||||
CookieBannerHandlingMode.REJECT_ALL
|
CookieBannerHandlingMode.REJECT_ALL
|
||||||
} else {
|
} else {
|
||||||
CookieBannerHandlingMode.DISABLED
|
CookieBannerHandlingMode.DISABLED
|
||||||
@ -1565,18 +1568,6 @@ class Settings(private val appContext: Context) : PreferencesHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if the cookie banner detect only mode should be enabled.
|
|
||||||
*/
|
|
||||||
fun shouldEnabledCookieBannerDetectOnlyMode(): Boolean {
|
|
||||||
val tcpCFRAlreadyShown = if (enabledTotalCookieProtectionCFR) {
|
|
||||||
!userOptOutOfReEngageCookieBannerDialog
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
return shouldShowCookieBannerUI && tcpCFRAlreadyShown && !shouldUseCookieBanner
|
|
||||||
}
|
|
||||||
|
|
||||||
var setAsDefaultGrowthSent by booleanPreference(
|
var setAsDefaultGrowthSent by booleanPreference(
|
||||||
key = appContext.getPreferenceKey(R.string.pref_key_growth_set_as_default),
|
key = appContext.getPreferenceKey(R.string.pref_key_growth_set_as_default),
|
||||||
default = false,
|
default = false,
|
||||||
|
Loading…
Reference in New Issue
Block a user