Bug 1859392 - Update the cookie banner handling section in the quick setting to only show in private mode.

fenix/121.0
Arturo Mejia 8 months ago committed by mergify[bot]
parent 4c9f7f77a6
commit ef57a71852

@ -272,7 +272,7 @@ features:
type: Map<CookieBannersSection, Int>
default:
{
"feature-ui": 0,
"feature-ui": 1,
"feature-setting-value": 0,
"feature-setting-value-pbm": 0,
"feature-setting-detect-only": 0,

@ -142,8 +142,8 @@ class Core(
R.color.fx_mobile_layer_color_1,
),
httpsOnlyMode = context.settings().getHttpsOnlyMode(),
cookieBannerHandlingModePrivateBrowsing = context.settings().getCookieBannerHandlingPrivateMode(),
cookieBannerHandlingMode = context.settings().getCookieBannerHandling(),
cookieBannerHandlingModePrivateBrowsing = context.settings().getCookieBannerHandlingPrivateMode(),
cookieBannerHandlingDetectOnlyMode = context.settings().shouldEnableCookieBannerDetectOnly,
cookieBannerHandlingGlobalRules = context.settings().shouldEnableCookieBannerGlobalRules,
cookieBannerHandlingGlobalRulesSubFrames = context.settings().shouldEnableCookieBannerGlobalRulesSubFrame,

@ -60,7 +60,8 @@ class ProtectionsView(
bindTrackingProtectionInfo(state.isTrackingProtectionEnabled)
bindCookieBannerProtection(state.cookieBannerUIMode)
binding.trackingProtectionSwitch.isVisible = settings.shouldUseTrackingProtection
binding.cookieBannerItem.isVisible = shouldShowCookieBanner &&
val isPrivateSession = state.tab?.content?.private == true
binding.cookieBannerItem.isVisible = isPrivateSession && shouldShowCookieBanner &&
state.cookieBannerUIMode != CookieBannerUIMode.HIDE
binding.trackingProtectionDetails.setOnClickListener {
@ -98,11 +99,11 @@ class ProtectionsView(
)
private val shouldShowCookieBanner: Boolean
get() = settings.shouldShowCookieBannerUI && settings.shouldUseCookieBanner
get() = settings.shouldShowCookieBannerUI && settings.shouldUseCookieBannerPrivateMode
private fun bindCookieBannerProtection(cookieBannerMode: CookieBannerUIMode) {
val context = binding.cookieBannerItem.context
val label = context.getString(R.string.preferences_cookie_banner_reduction)
val label = context.getString(R.string.cookie_banner_blocker)
binding.cookieBannerItem.apply {
setContent {

@ -95,11 +95,11 @@ class CookieBannerHandlingDetailsView(
val shortUrl = data.toShortUrl(publicSuffixList)
val title = when (state) {
CookieBannerUIMode.ENABLE -> context.getString(
R.string.reduce_cookie_banner_details_panel_title_off_for_site,
R.string.reduce_cookie_banner_details_panel_title_off_for_site_1,
shortUrl,
)
CookieBannerUIMode.DISABLE -> context.getString(
R.string.reduce_cookie_banner_details_panel_title_on_for_site,
R.string.reduce_cookie_banner_details_panel_title_on_for_site_1,
shortUrl,
)
CookieBannerUIMode.SITE_NOT_SUPPORTED -> context.getString(
@ -117,11 +117,11 @@ class CookieBannerHandlingDetailsView(
val appName = context.getString(R.string.app_name)
val description = when (state) {
CookieBannerUIMode.ENABLE -> context.getString(
R.string.reduce_cookie_banner_details_panel_description_off_for_site,
R.string.reduce_cookie_banner_details_panel_description_off_for_site_1,
appName,
)
CookieBannerUIMode.DISABLE -> context.getString(
R.string.reduce_cookie_banner_details_panel_description_on_for_site_2,
R.string.reduce_cookie_banner_details_panel_description_on_for_site_3,
appName,
)
CookieBannerUIMode.SITE_NOT_SUPPORTED -> context.getString(

@ -23,7 +23,7 @@ suspend fun CookieBannersStorage.getCookieBannerUIMode(
context: Context,
tab: SessionState,
): CookieBannerUIMode {
return if (context.settings().shouldUseCookieBanner) {
return if (context.settings().shouldUseCookieBannerPrivateMode) {
val isSiteDomainReported = withContext(Dispatchers.IO) {
val host = tab.content.url.toUri().host.orEmpty()
val siteDomain = context.components.publicSuffixList.getPublicSuffixPlusOne(host).await()

@ -616,18 +616,15 @@ class Settings(private val appContext: Context) : PreferencesHolder {
default = true,
)
var shouldUseCookieBanner by lazyFeatureFlagPreference(
appContext.getPreferenceKey(R.string.pref_key_cookie_banner_v1),
featureFlag = true,
default = { cookieBannersSection[CookieBannersSection.FEATURE_SETTING_VALUE] == 1 },
)
var shouldUseCookieBannerPrivateMode by lazyFeatureFlagPreference(
appContext.getPreferenceKey(R.string.pref_key_cookie_banner_private_mode),
featureFlag = true,
default = { cookieBannersSection[CookieBannersSection.FEATURE_SETTING_VALUE_PBM] == 1 },
)
val shouldUseCookieBanner: Boolean
get() = cookieBannersSection[CookieBannersSection.FEATURE_SETTING_VALUE] == 1
val shouldShowCookieBannerUI: Boolean
get() = cookieBannersSection[CookieBannersSection.FEATURE_UI] == 1

@ -31,17 +31,29 @@
android:paddingTop="16dp"
android:textColor="?attr/textPrimary"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/navigate_back"
app:layout_constraintEnd_toStartOf="@id/cookieBannerSwitch"
app:layout_constraintTop_toTopOf="parent"
tools:text="Turn off Cookize Banner Reduction for [domain.com]? " />
tools:text="Turn off Cookie Banner Blocker for [domain.com]?" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/cookieBannerSwitch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minHeight="@dimen/tracking_protection_item_height"
android:visibility="gone"
app:layout_constraintStart_toEndOf="@id/title"
app:layout_constraintEnd_toEndOf="parent"
android:paddingHorizontal="16dp"
app:layout_constraintBottom_toTopOf="@id/details"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/details"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
android:layout_marginBottom="8dp"
android:textColor="?attr/textSecondary"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
@ -49,20 +61,6 @@
app:layout_constraintTop_toBottomOf="@id/title"
tools:text="Firefox will clear this sites cookies and refresh the page. Clearing all cookies may sign you out or empty shopping carts." />
<org.mozilla.fenix.trackingprotection.SwitchWithDescription
android:id="@+id/cookieBannerSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/tracking_protection_item_height"
android:paddingHorizontal="16dp"
android:paddingTop="23dp"
android:visibility="gone"
app:layout_constraintStart_toEndOf="@+id/navigate_back"
app:layout_constraintTop_toBottomOf="@id/details"
app:switchDescriptionOff="@string/reduce_cookie_banner_off_for_site"
app:switchDescriptionOn="@string/reduce_cookie_banner_on_for_site"
app:switchShowIcon="false"
app:switchTitle="@string/preferences_cookie_banner_reduction" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/cancel_button"

@ -161,7 +161,6 @@
<string name="pref_key_https_only_in_private_tabs" translatable="false">pref_key_https_only_in_private_tabs</string>
<!-- Cookie Banner Reduction Settings-->
<string name="pref_key_cookie_banner_v1" translatable="false">pref_key_cookie_banner_v1</string>
<string name="pref_key_cookie_banner_private_mode" translatable="false">pref_key_cookie_banner_private_mode</string>
<!-- Tracking Protection Settings -->

@ -442,6 +442,8 @@
<!-- Preference for removing cookie/consent banners from sites automatically. See reduce_cookie_banner_summary for additional context. -->
<string name="preferences_cookie_banner_reduction" moz:RemovedIn="121" tools:ignore="UnusedResources">Cookie banner reduction</string>
<!-- Label for cookie banner section in quick settings panel. -->
<string name="cookie_banner_blocker">Cookie Banner Blocker</string>
<!-- Preference for removing cookie/consent banners from sites automatically in private mode. See reduce_cookie_banner_summary for additional context. -->
<string name="preferences_cookie_banner_reduction_private_mode">Cookie Banner Blocker in private browsing</string>
<!-- Preference for rejecting or removing as many cookie/consent banners as possible on sites. See reduce_cookie_banner_summary for additional context. -->
@ -469,15 +471,23 @@
<!-- Text for indicating cookie banner handling is currently not supported for this site, this is shown as part of the protections panel with the tracking protection toggle -->
<string name="reduce_cookie_banner_unsupported_site">Site currently not supported</string>
<!-- Title text for a detail explanation indicating cookie banner handling is on this site, this is shown as part of the cookie banner panel in the toolbar. The first parameter is a shortened URL of the current site-->
<string name="reduce_cookie_banner_details_panel_title_on_for_site">Turn on Cookie banner reduction for %1$s?</string>
<string name="reduce_cookie_banner_details_panel_title_on_for_site" moz:RemovedIn="121" tools:ignore="UnusedResources">Turn on Cookie banner reduction for %1$s?</string>
<!-- Title text for a detail explanation indicating cookie banner handling is on this site, this is shown as part of the cookie banner panel in the toolbar. The first parameter is a shortened URL of the current site-->
<string name="reduce_cookie_banner_details_panel_title_on_for_site_1">Turn on Cookie Banner Blocker for %1$s?</string>
<!-- Title text for a detail explanation indicating cookie banner handling is off this site, this is shown as part of the cookie banner panel in the toolbar. The first parameter is a shortened URL of the current site-->
<string name="reduce_cookie_banner_details_panel_title_off_for_site" moz:RemovedIn="121" tools:ignore="UnusedResources">Turn off Cookie banner reduction for %1$s?</string>
<!-- Title text for a detail explanation indicating cookie banner handling is off this site, this is shown as part of the cookie banner panel in the toolbar. The first parameter is a shortened URL of the current site-->
<string name="reduce_cookie_banner_details_panel_title_off_for_site">Turn off Cookie banner reduction for %1$s?</string>
<string name="reduce_cookie_banner_details_panel_title_off_for_site_1">Turn off Cookie Banner Blocker for %1$s?</string>
<!-- Title text for a detail explanation indicating cookie banner reducer didn't work for the current site, this is shown as part of the cookie banner panel in the toolbar. The first parameter is the application name-->
<string name="reduce_cookie_banner_details_panel_title_unsupported_site_request_2">%1$s cant automatically reject cookie requests on this site. You can send a request to support this site in the future.</string>
<!-- Long text for a detail explanation indicating what will happen if cookie banner handling is off for a site, this is shown as part of the cookie banner panel in the toolbar. The first parameter is the application name -->
<string name="reduce_cookie_banner_details_panel_description_off_for_site">%1$s will clear this sites cookies and refresh the page. Clearing all cookies may sign you out or empty shopping carts.</string>
<string name="reduce_cookie_banner_details_panel_description_off_for_site" moz:RemovedIn="121" tools:ignore="UnusedResources">%1$s will clear this sites cookies and refresh the page. Clearing all cookies may sign you out or empty shopping carts.</string>
<!-- Long text for a detail explanation indicating what will happen if cookie banner handling is off for a site, this is shown as part of the cookie banner panel in the toolbar. The first parameter is the application name -->
<string name="reduce_cookie_banner_details_panel_description_off_for_site_1">Turn off and %1$s will clear cookies and reload this site. This may sign you out or empty shopping carts.</string>
<!-- Long text for a detail explanation indicating what will happen if cookie banner handling is on for a site, this is shown as part of the cookie banner panel in the toolbar. The first parameter is the application name -->
<string name="reduce_cookie_banner_details_panel_description_on_for_site_2" moz:RemovedIn="121" tools:ignore="UnusedResources">%1$s tries to automatically reject all cookie requests on supported sites.</string>
<!-- Long text for a detail explanation indicating what will happen if cookie banner handling is on for a site, this is shown as part of the cookie banner panel in the toolbar. The first parameter is the application name -->
<string name="reduce_cookie_banner_details_panel_description_on_for_site_2">%1$s tries to automatically reject all cookie requests on supported sites.</string>
<string name="reduce_cookie_banner_details_panel_description_on_for_site_3" >Turn on and %1$s will try to automatically refuse all cookie banners on this site.</string>
<!-- Title text for the cookie banner re-engagement dialog. The first parameter is the application name. -->
<string name="reduce_cookie_banner_dialog_title" moz:RemovedIn="121" tools:ignore="UnusedResources">Allow %1$s to reject cookie banners?</string>
<!-- Body text for the cookie banner re-engagement dialog use. The first parameter is the application name. -->

@ -89,7 +89,7 @@ class DefaultConnectionDetailsControllerTest {
@Test
fun `WHEN handleBackPressed is called THEN should call popBackStack and navigate`() = runTestOnMain {
every { context.settings().shouldUseCookieBanner } returns false
every { context.settings().shouldUseCookieBannerPrivateMode } returns false
controller.handleBackPressed()

@ -108,7 +108,7 @@ class ProtectionsViewTest {
)
every { settings.shouldShowCookieBannerUI } returns true
every { settings.shouldUseCookieBanner } returns false
every { settings.shouldUseCookieBannerPrivateMode } returns false
view.update(state)
@ -129,7 +129,7 @@ class ProtectionsViewTest {
)
every { settings.shouldShowCookieBannerUI } returns false
every { settings.shouldUseCookieBanner } returns false
every { settings.shouldUseCookieBannerPrivateMode } returns false
view.update(state)
@ -150,7 +150,7 @@ class ProtectionsViewTest {
)
every { settings.shouldShowCookieBannerUI } returns true
every { settings.shouldUseCookieBanner } returns true
every { settings.shouldUseCookieBannerPrivateMode } returns true
view.update(state)
@ -184,7 +184,7 @@ class ProtectionsViewTest {
)
every { settings.shouldShowCookieBannerUI } returns true
every { settings.shouldUseCookieBanner } returns true
every { settings.shouldUseCookieBannerPrivateMode } returns true
view.update(state)

@ -97,7 +97,7 @@ class CookieBannerHandlingDetailsViewTest {
val expectedText =
testContext.getString(
R.string.reduce_cookie_banner_details_panel_title_off_for_site,
R.string.reduce_cookie_banner_details_panel_title_off_for_site_1,
"mozilla.org",
)
@ -137,7 +137,7 @@ class CookieBannerHandlingDetailsViewTest {
val expectedText =
testContext.getString(
R.string.reduce_cookie_banner_details_panel_title_on_for_site,
R.string.reduce_cookie_banner_details_panel_title_on_for_site_1,
"mozilla.org",
)
@ -161,7 +161,7 @@ class CookieBannerHandlingDetailsViewTest {
val expectedText =
testContext.getString(
R.string.reduce_cookie_banner_details_panel_description_off_for_site,
R.string.reduce_cookie_banner_details_panel_description_off_for_site_1,
testContext.getString(R.string.app_name),
)
@ -189,7 +189,7 @@ class CookieBannerHandlingDetailsViewTest {
val appName = testContext.getString(R.string.app_name)
val expectedText =
testContext.getString(
R.string.reduce_cookie_banner_details_panel_description_on_for_site_2,
R.string.reduce_cookie_banner_details_panel_description_on_for_site_3,
appName,
appName,
)

@ -135,7 +135,7 @@ internal class DefaultCookieBannerDetailsControllerTest {
@Test
fun `WHEN handleBackPressed is called THEN should call popBackStack and navigate`() = runTestOnMain {
every { context.settings().shouldUseCookieBanner } returns false
every { context.settings().shouldUseCookieBannerPrivateMode } returns false
controller.handleBackPressed()

@ -135,7 +135,7 @@ class TrackingProtectionPanelInteractorTest {
@Test
fun `WHEN onBackPressed is called THEN call popBackStack and navigate`() = runTestOnMain {
every { context.settings().shouldUseCookieBanner } returns false
every { context.settings().shouldUseCookieBannerPrivateMode } returns false
interactor.onBackPressed()

Loading…
Cancel
Save