From 4f48bf646b6946654a760ef306e6e5fa683f11f8 Mon Sep 17 00:00:00 2001 From: Arturo Mejia Date: Thu, 2 Nov 2023 21:35:07 -0400 Subject: [PATCH] Bug 1862425 - Allow to control QPS prefs using nimbus. --- app/nimbus.fml.yaml | 58 +++++++++++++++++-- .../org/mozilla/fenix/gecko/GeckoProvider.kt | 8 +++ .../java/org/mozilla/fenix/utils/Settings.kt | 21 +++++++ 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/app/nimbus.fml.yaml b/app/nimbus.fml.yaml index 460c14ea1..8c1325dde 100644 --- a/app/nimbus.fml.yaml +++ b/app/nimbus.fml.yaml @@ -232,7 +232,38 @@ features: "jump-back-in-cfr": true, } } - + query-parameter-stripping: + description: Features for query parameter stripping. + variables: + sections-enabled: + description: "This property provides a lookup table of whether or not the given section should be enabled." + type: Map + default: + { + "query-parameter-stripping": "0", + "query-parameter-stripping-pmb": "0", + "query-parameter-stripping-allow-list": "", + "query-parameter-stripping-strip-list": "", + } + defaults: + - channel: developer + value: { + "sections-enabled": { + "query-parameter-stripping": "0", + "query-parameter-stripping-pmb": "0", + "query-parameter-stripping-allow-list": "", + "query-parameter-stripping-strip-list": "", + } + } + - channel: nightly + value: { + "sections-enabled": { + "query-parameter-stripping": "0", + "query-parameter-stripping-pmb": "0", + "query-parameter-stripping-allow-list": "", + "query-parameter-stripping-strip-list": "", + } + } cookie-banners: description: Features for cookie banner handling. variables: @@ -246,7 +277,7 @@ features: "feature-setting-value-pbm": 0, "feature-setting-detect-only": 0, "feature-setting-global-rules": 0, - "feature-setting-global-rules-sub-frames": 0 + "feature-setting-global-rules-sub-frames": 0, } defaults: - channel: developer @@ -257,7 +288,7 @@ features: "feature-setting-value-pbm": 0, "feature-setting-detect-only": 0, "feature-setting-global-rules": 0, - "feature-setting-global-rules-sub-frames": 0 + "feature-setting-global-rules-sub-frames": 0, } } - channel: nightly @@ -268,7 +299,7 @@ features: "feature-setting-value-pbm": 0, "feature-setting-detect-only": 0, "feature-setting-global-rules": 0, - "feature-setting-global-rules-sub-frames": 0 + "feature-setting-global-rules-sub-frames": 0, } } unified-search: @@ -478,6 +509,25 @@ types: description: An integer either 0 or 1 indicating if cookie banner global rules sub-frames should be enabled or disabled. 0 for setting to be disabled, and 1 for enabling the setting. + QueryParameterStrippingSection: + description: The identifiers for the options for the Query Parameter Stripping feature. + variants: + query-parameter-stripping: + description: An integer either 0 or 1 indicating if query parameter stripping + should be enabled or disabled in normal mode. 0 for setting to be disabled, + and 1 for enabling the setting. + query-parameter-stripping-pmb: + description: An integer either 0 or 1 indicating if query parameter stripping + should be enabled or disabled in private mode. 0 for setting to be disabled, + and 1 for enabling the setting. + query-parameter-stripping-allow-list: + description: An string separated by commas indicating the sites where should + from query stripping should be exempted. + query-parameter-stripping-strip-list: + description: An string separated by commas indicating the list of query params + to be stripped from URIs. This list will be merged with records + coming from RemoteSettings. + OnboardingPanel: description: The types of onboarding panels in the onboarding page variants: diff --git a/app/src/main/java/org/mozilla/fenix/gecko/GeckoProvider.kt b/app/src/main/java/org/mozilla/fenix/gecko/GeckoProvider.kt index cfe33a9b8..b09019f19 100644 --- a/app/src/main/java/org/mozilla/fenix/gecko/GeckoProvider.kt +++ b/app/src/main/java/org/mozilla/fenix/gecko/GeckoProvider.kt @@ -121,6 +121,14 @@ object GeckoProvider { context.settings().shouldEnableCookieBannerGlobalRules, cookieBannerGlobalRulesSubFramesEnabled = context.settings().shouldEnableCookieBannerGlobalRulesSubFrame, + queryParameterStripping = + context.settings().shouldEnableQueryParameterStripping, + queryParameterStrippingPrivateBrowsing = + context.settings().shouldEnableQueryParameterStrippingPrivateBrowsing, + queryParameterStrippingAllowList = + context.settings().queryParameterStrippingAllowList, + queryParameterStrippingStripList = + context.settings().queryParameterStrippingStripList, ), ) .consoleOutput(context.components.settings.enableGeckoLogs) 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 bbe912179..dd61e4d75 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -46,6 +46,11 @@ import org.mozilla.fenix.nimbus.CookieBannersSection import org.mozilla.fenix.nimbus.FxNimbus import org.mozilla.fenix.nimbus.HomeScreenSection import org.mozilla.fenix.nimbus.Mr2022Section +import org.mozilla.fenix.nimbus.QueryParameterStrippingSection +import org.mozilla.fenix.nimbus.QueryParameterStrippingSection.QUERY_PARAMETER_STRIPPING +import org.mozilla.fenix.nimbus.QueryParameterStrippingSection.QUERY_PARAMETER_STRIPPING_ALLOW_LIST +import org.mozilla.fenix.nimbus.QueryParameterStrippingSection.QUERY_PARAMETER_STRIPPING_PMB +import org.mozilla.fenix.nimbus.QueryParameterStrippingSection.QUERY_PARAMETER_STRIPPING_STRIP_LIST import org.mozilla.fenix.settings.PhoneFeature import org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataOnQuitType import org.mozilla.fenix.settings.logins.SavedLoginsSortingStrategyMenu @@ -635,6 +640,18 @@ class Settings(private val appContext: Context) : PreferencesHolder { val shouldEnableCookieBannerGlobalRulesSubFrame: Boolean get() = cookieBannersSection[CookieBannersSection.FEATURE_SETTING_GLOBAL_RULES_SUB_FRAMES] == 1 + val shouldEnableQueryParameterStripping: Boolean + get() = queryParameterStrippingSection[QUERY_PARAMETER_STRIPPING] == "1" + + val shouldEnableQueryParameterStrippingPrivateBrowsing: Boolean + get() = queryParameterStrippingSection[QUERY_PARAMETER_STRIPPING_PMB] == "1" + + val queryParameterStrippingAllowList: String + get() = queryParameterStrippingSection[QUERY_PARAMETER_STRIPPING_ALLOW_LIST].orEmpty() + + val queryParameterStrippingStripList: String + get() = queryParameterStrippingSection[QUERY_PARAMETER_STRIPPING_STRIP_LIST].orEmpty() + /** * Declared as a function for performance purposes. This could be declared as a variable using * booleanPreference like other members of this class. However, doing so will make it so it will @@ -1473,6 +1490,10 @@ class Settings(private val appContext: Context) : PreferencesHolder { get() = FxNimbus.features.cookieBanners.value().sectionsEnabled + private val queryParameterStrippingSection: Map + get() = + FxNimbus.features.queryParameterStripping.value().sectionsEnabled + private val homescreenSections: Map get() = FxNimbus.features.homescreen.value().sectionsEnabled