Closes #26858: Remove unused nimbus engine-settings tabs-prioritization-enabled feature.

home_button_fix
Arturo Mejia 3 months ago
parent 49bef5d309
commit 5358e9b878
  1. 8
      .experimenter.yaml
  2. 93
      app/src/main/java/org/mozilla/fenix/components/Core.kt
  3. 8
      app/src/main/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactory.kt
  4. 299
      app/src/main/java/org/mozilla/fenix/utils/Settings.kt
  5. 144
      app/src/test/java/org/mozilla/fenix/components/TrackingProtectionPolicyFactoryTest.kt
  6. 7
      nimbus.fml.yaml

@ -1,12 +1,4 @@
---
engine-settings:
description: Contains a set of settings for controlling the web engine configurations.
hasExposure: true
exposureDescription: ""
variables:
tabs-prioritization-enabled:
type: boolean
description: "If true, enables tabs prioritization feature."
homescreen:
description: The homescreen that the user goes to when they press home or new tab.
hasExposure: true

@ -88,7 +88,6 @@ import org.mozilla.fenix.historymetadata.DefaultHistoryMetadataService
import org.mozilla.fenix.historymetadata.HistoryMetadataMiddleware
import org.mozilla.fenix.historymetadata.HistoryMetadataService
import org.mozilla.fenix.media.MediaSessionService
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.perf.StrictModeManager
import org.mozilla.fenix.perf.lazyMonitored
import org.mozilla.fenix.settings.SupportUtils
@ -106,7 +105,7 @@ import java.util.concurrent.TimeUnit
class Core(
private val context: Context,
private val crashReporter: CrashReporting,
strictMode: StrictModeManager
strictMode: StrictModeManager,
) {
/**
* The browser engine component initialized based on the build
@ -129,15 +128,15 @@ class Core(
enterpriseRootsEnabled = context.settings().allowThirdPartyRootCerts,
clearColor = ContextCompat.getColor(
context,
R.color.fx_mobile_layer_color_1
R.color.fx_mobile_layer_color_1,
),
httpsOnlyMode = context.settings().getHttpsOnlyMode()
httpsOnlyMode = context.settings().getHttpsOnlyMode(),
)
GeckoEngine(
context,
defaultSettings,
geckoRuntime
geckoRuntime,
).also {
WebCompatFeature.install(it)
@ -168,7 +167,7 @@ class Core(
val client: Client by lazyMonitored {
GeckoViewFetchClient(
context,
geckoRuntime
geckoRuntime,
)
}
@ -177,7 +176,7 @@ class Core(
context,
lazyAutofillStorage,
lazyPasswordsStorage,
trackingProtectionPolicyFactory.createTrackingProtectionPolicy()
trackingProtectionPolicyFactory.createTrackingProtectionPolicy(),
)
}
@ -224,8 +223,6 @@ class Core(
* The [BrowserStore] holds the global [BrowserState].
*/
val store by lazyMonitored {
val tabsPrioritizationEnable =
FxNimbus.features.engineSettings.value().tabsPrioritizationEnabled
val middlewareList =
mutableListOf(
LastAccessMiddleware(),
@ -239,18 +236,15 @@ class Core(
SearchMiddleware(
context,
additionalBundledSearchEngineIds = listOf("reddit", "youtube"),
migration = SearchMigration(context)
migration = SearchMigration(context),
),
RecordingDevicesMiddleware(context),
PromptMiddleware(),
AdsTelemetryMiddleware(adsTelemetry),
LastMediaAccessMiddleware(),
HistoryMetadataMiddleware(historyMetadataService),
) + if (tabsPrioritizationEnable) {
listOf(SessionPrioritizationMiddleware())
} else {
emptyList()
}
SessionPrioritizationMiddleware(),
)
BrowserStore(
initialState = BrowserState(
@ -260,7 +254,7 @@ class Core(
} else {
emptyList()
},
)
),
),
middleware = middlewareList + EngineMiddleware.create(
engine,
@ -271,8 +265,8 @@ class Core(
// https://github.com/mozilla-mobile/fenix/issues/12731
// https://github.com/mozilla-mobile/android-components/issues/11300
// https://github.com/mozilla-mobile/android-components/issues/11653
trimMemoryAutomatically = false
)
trimMemoryAutomatically = false,
),
).apply {
// Install the "icons" WebExtension to automatically load icons for every visited website.
icons.install(engine, this)
@ -284,8 +278,12 @@ class Core(
searchTelemetry.install(engine, this)
WebNotificationFeature(
context, engine, icons, R.drawable.ic_status_logo,
permissionStorage.permissionsStorage, IntentReceiverActivity::class.java
context,
engine,
icons,
R.drawable.ic_status_logo,
permissionStorage.permissionsStorage,
IntentReceiverActivity::class.java,
)
MediaSessionFeature(context, MediaSessionService::class.java, this).start()
@ -337,7 +335,7 @@ class Core(
WebAppShortcutManager(
context,
client,
webAppManifestStorage
webAppManifestStorage,
)
}
@ -349,14 +347,16 @@ class Core(
val lazyHistoryStorage = lazyMonitored { PlacesHistoryStorage(context, crashReporter) }
val lazyBookmarksStorage = lazyMonitored { PlacesBookmarksStorage(context) }
val lazyPasswordsStorage = lazyMonitored { SyncableLoginsStorage(context, lazySecurePrefs) }
val lazyAutofillStorage = lazyMonitored { AutofillCreditCardsAddressesStorage(context, lazySecurePrefs) }
val lazyAutofillStorage =
lazyMonitored { AutofillCreditCardsAddressesStorage(context, lazySecurePrefs) }
/**
* The storage component to sync and persist tabs in a Firefox Sync account.
*/
val lazyRemoteTabsStorage = lazyMonitored { RemoteTabsStorage(context) }
val recentlyClosedTabsStorage = lazyMonitored { RecentlyClosedTabsStorage(context, engine, crashReporter) }
val recentlyClosedTabsStorage =
lazyMonitored { RecentlyClosedTabsStorage(context, engine, crashReporter) }
// For most other application code (non-startup), these wrappers are perfectly fine and more ergonomic.
val historyStorage: PlacesHistoryStorage get() = lazyHistoryStorage.value
@ -367,7 +367,7 @@ class Core(
val tabCollectionStorage by lazyMonitored {
TabCollectionStorage(
context,
strictMode
strictMode,
)
}
@ -385,8 +385,8 @@ class Core(
Frequency(4, TimeUnit.HOURS),
Profile(
profileId = UUID.fromString(context.settings().pocketSponsoredStoriesProfileId),
appId = BuildConfig.POCKET_CONSUMER_KEY
)
appId = BuildConfig.POCKET_CONSUMER_KEY,
),
)
}
val pocketStoriesService by lazyMonitored { PocketStoriesService(context, pocketStoriesConfig) }
@ -395,7 +395,7 @@ class Core(
ContileTopSitesProvider(
context = context,
client = client,
maxCacheAgeInMinutes = CONTILE_MAX_CACHE_AGE
maxCacheAgeInMinutes = CONTILE_MAX_CACHE_AGE,
)
}
@ -404,7 +404,7 @@ class Core(
ContileTopSitesUpdater(
context = context,
provider = contileTopSitesProvider,
frequency = Frequency(3, TimeUnit.HOURS)
frequency = Frequency(3, TimeUnit.HOURS),
)
}
@ -417,59 +417,59 @@ class Core(
defaultTopSites.add(
Pair(
context.getString(R.string.default_top_site_baidu),
SupportUtils.BAIDU_URL
)
SupportUtils.BAIDU_URL,
),
)
defaultTopSites.add(
Pair(
context.getString(R.string.default_top_site_jd),
SupportUtils.JD_URL
)
SupportUtils.JD_URL,
),
)
defaultTopSites.add(
Pair(
context.getString(R.string.default_top_site_pdd),
SupportUtils.PDD_URL
)
SupportUtils.PDD_URL,
),
)
defaultTopSites.add(
Pair(
context.getString(R.string.default_top_site_tc),
SupportUtils.TC_URL
)
SupportUtils.TC_URL,
),
)
defaultTopSites.add(
Pair(
context.getString(R.string.default_top_site_meituan),
SupportUtils.MEITUAN_URL
)
SupportUtils.MEITUAN_URL,
),
)
} else {
defaultTopSites.add(
Pair(
context.getString(R.string.default_top_site_google),
SupportUtils.GOOGLE_URL
)
SupportUtils.GOOGLE_URL,
),
)
if (LocaleManager.getSelectedLocale(context).language == "en") {
defaultTopSites.add(
Pair(
context.getString(R.string.pocket_pinned_top_articles),
SupportUtils.POCKET_TRENDING_URL
)
SupportUtils.POCKET_TRENDING_URL,
),
)
}
defaultTopSites.add(
Pair(
context.getString(R.string.default_top_site_wikipedia),
SupportUtils.WIKIPEDIA_URL
)
SupportUtils.WIKIPEDIA_URL,
),
)
}
@ -481,7 +481,7 @@ class Core(
pinnedSitesStorage = pinnedSiteStorage,
historyStorage = historyStorage,
topSitesProvider = contileTopSitesProvider,
defaultTopSites = defaultTopSites
defaultTopSites = defaultTopSites,
)
}
@ -501,7 +501,7 @@ class Core(
SecureAbove22Preferences(
context = context,
name = KEY_STORAGE_NAME,
forceInsecure = !Config.channel.isNightlyOrDebug
forceInsecure = !Config.channel.isNightlyOrDebug,
)
// Temporary. See https://github.com/mozilla-mobile/fenix/issues/19155
@ -535,6 +535,7 @@ class Core(
// Maximum number of suggestions returned from the history search engine source.
const val METADATA_HISTORY_SUGGESTION_LIMIT = 100
// Maximum number of suggestions returned from shortcut search engine.
const val METADATA_SHORTCUT_SUGGESTION_LIMIT = 20
}

@ -15,7 +15,7 @@ import org.mozilla.fenix.utils.Settings
*/
class TrackingProtectionPolicyFactory(
private val settings: Settings,
private val resources: Resources
private val resources: Resources,
) {
/**
@ -30,7 +30,7 @@ class TrackingProtectionPolicyFactory(
@Suppress("ComplexMethod")
fun createTrackingProtectionPolicy(
normalMode: Boolean = settings.shouldUseTrackingProtection,
privateMode: Boolean = settings.shouldUseTrackingProtection
privateMode: Boolean = settings.shouldUseTrackingProtection,
): TrackingProtectionPolicy {
val trackingProtectionPolicy =
when {
@ -51,7 +51,7 @@ class TrackingProtectionPolicyFactory(
return TrackingProtectionPolicy.select(
cookiePolicy = getCustomCookiePolicy(),
trackingCategories = getCustomTrackingCategories(),
cookiePurging = getCustomCookiePurgingPolicy()
cookiePurging = getCustomCookiePurgingPolicy(),
).let {
if (settings.blockTrackingContentSelectionInCustomTrackingProtection == "private") {
it.forPrivateSessionsOnly()
@ -81,7 +81,7 @@ class TrackingProtectionPolicyFactory(
TrackingProtectionPolicy.TrackingCategory.AD,
TrackingProtectionPolicy.TrackingCategory.ANALYTICS,
TrackingProtectionPolicy.TrackingCategory.SOCIAL,
TrackingProtectionPolicy.TrackingCategory.MOZILLA_SOCIAL
TrackingProtectionPolicy.TrackingCategory.MOZILLA_SOCIAL,
)
if (settings.blockTrackingContentInCustomTrackingProtection) {

@ -88,6 +88,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
// The maximum number of top sites to display.
const val TOP_SITES_MAX_COUNT = 16
/**
* Only fetch top sites from the [ContileTopSitesProvider] when the number of default and
* pinned sites are below this maximum threshold.
@ -139,17 +140,17 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var numberOfAppLaunches by intPreference(
appContext.getPreferenceKey(R.string.pref_key_times_app_opened),
default = 0
default = 0,
)
var lastReviewPromptTimeInMillis by longPreference(
appContext.getPreferenceKey(R.string.pref_key_last_review_prompt_shown_time),
default = 0L
default = 0L,
)
var lastCfrShownTimeInMillis by longPreference(
appContext.getPreferenceKey(R.string.pref_key_last_cfr_shown_time),
default = 0L
default = 0L,
)
val canShowCfr: Boolean
@ -157,37 +158,37 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var forceEnableZoom by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_accessibility_force_enable_zoom),
default = false
default = false,
)
var adjustCampaignId by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_adjust_campaign),
default = ""
default = "",
)
var adjustNetwork by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_adjust_network),
default = ""
default = "",
)
var adjustAdGroup by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_adjust_adgroup),
default = ""
default = "",
)
var adjustCreative by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_adjust_creative),
default = ""
default = "",
)
var contileContextId by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_contile_context_id),
default = ""
default = "",
)
var currentWallpaperName by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_current_wallpaper),
default = Wallpaper.Default.name
default = Wallpaper.Default.name,
)
/**
@ -195,7 +196,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var currentWallpaperTextColor by longPreference(
appContext.getPreferenceKey(R.string.pref_key_current_wallpaper_text_color),
default = 0
default = 0,
)
/**
@ -203,7 +204,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var currentWallpaperCardColor by longPreference(
appContext.getPreferenceKey(R.string.pref_key_current_wallpaper_card_color),
default = 0
default = 0,
)
/**
@ -217,64 +218,64 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var openLinksInAPrivateTab by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_open_links_in_a_private_tab),
default = false
default = false,
)
var allowScreenshotsInPrivateMode by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_allow_screenshots_in_private_mode),
default = false
default = false,
)
var shouldReturnToBrowser by booleanPreference(
appContext.getString(R.string.pref_key_return_to_browser),
false
false,
)
var defaultSearchEngineName by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_search_engine),
default = ""
default = "",
)
var openInAppOpened by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_open_in_app_opened),
default = false
default = false,
)
var installPwaOpened by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_install_pwa_opened),
default = false
default = false,
)
var showCollectionsPlaceholderOnHome by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_show_collections_placeholder_home),
default = true
default = true,
)
val isCrashReportingEnabled: Boolean
get() = isCrashReportEnabledInBuild &&
preferences.getBoolean(
appContext.getPreferenceKey(R.string.pref_key_crash_reporter),
true
true,
)
val isRemoteDebuggingEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_remote_debugging),
default = false
default = false,
)
val isTelemetryEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_telemetry),
default = true
default = true,
)
var isMarketingTelemetryEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_marketing_telemetry),
default = !Config.channel.isMozillaOnline
default = !Config.channel.isMozillaOnline,
)
var isExperimentationEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_experimentation),
default = true
default = true,
)
var isOverrideTPPopupsForPerformanceTest = false
@ -289,87 +290,87 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var shouldShowPrivacyPopWindow by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_privacy_pop_window),
default = true
default = true,
)
var shouldUseLightTheme by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_light_theme),
default = false
default = false,
)
var shouldUseAutoSize by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_accessibility_auto_size),
default = true
default = true,
)
var fontSizeFactor by floatPreference(
appContext.getPreferenceKey(R.string.pref_key_accessibility_font_scale),
default = 1f
default = 1f,
)
val shouldShowHistorySuggestions by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_search_browsing_history),
default = true
default = true,
)
val shouldShowBookmarkSuggestions by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_search_bookmarks),
default = true
default = true,
)
val shouldShowSyncedTabsSuggestions by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_search_synced_tabs),
default = true
default = true,
)
val shouldShowClipboardSuggestions by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_show_clipboard_suggestions),
default = true
default = true,
)
val shouldShowSearchShortcuts by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_show_search_engine_shortcuts),
default = false
default = false,
)
var gridTabView by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tab_view_grid),
default = true
default = true,
)
var manuallyCloseTabs by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_close_tabs_manually),
default = true
default = true,
)
var closeTabsAfterOneDay by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_close_tabs_after_one_day),
default = false
default = false,
)
var closeTabsAfterOneWeek by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_close_tabs_after_one_week),
default = false
default = false,
)
var closeTabsAfterOneMonth by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_close_tabs_after_one_month),
default = false
default = false,
)
var allowThirdPartyRootCerts by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_allow_third_party_root_certs),
default = false
default = false,
)
var nimbusUsePreview by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_nimbus_use_preview),
default = false
default = false,
)
var isFirstNimbusRun: Boolean by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_is_first_run),
default = true
default = true,
)
/**
@ -379,7 +380,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var lastBrowseActivity by longPreference(
appContext.getPreferenceKey(R.string.pref_key_last_browse_activity_time),
default = timeNowInMillis()
default = timeNowInMillis(),
)
/**
@ -388,7 +389,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var openHomepageAfterFourHoursOfInactivity by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_start_on_home_after_four_hours),
default = true
default = true,
)
/**
@ -396,7 +397,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var alwaysOpenTheHomepageWhenOpeningTheApp by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_start_on_home_always),
default = false
default = false,
)
/**
@ -405,7 +406,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var alwaysOpenTheLastTabWhenOpeningTheApp by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_start_on_home_never),
default = false
default = false,
)
/**
@ -426,7 +427,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var inactiveTabsAreEnabled by featureFlagPreference(
appContext.getPreferenceKey(R.string.pref_key_inactive_tabs),
default = FeatureFlags.inactiveTabs,
featureFlag = FeatureFlags.inactiveTabs
featureFlag = FeatureFlags.inactiveTabs,
)
@VisibleForTesting
@ -481,32 +482,32 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var shouldUseDarkTheme by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_dark_theme),
default = false
default = false,
)
var shouldFollowDeviceTheme by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_follow_device_theme),
default = false
default = false,
)
var shouldUseHttpsOnly by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_https_only),
default = false
default = false,
)
var shouldUseHttpsOnlyInAllTabs by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_https_only_in_all_tabs),
default = true
default = true,
)
var shouldUseHttpsOnlyInPrivateTabsOnly by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_https_only_in_private_tabs),
default = false
default = false,
)
var shouldUseTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection),
default = true
default = true,
)
/**
@ -518,7 +519,8 @@ class Settings(private val appContext: Context) : PreferencesHolder {
fun checkIfFenixIsDefaultBrowserOnAppResume(): Boolean {
val prefKey = appContext.getPreferenceKey(R.string.pref_key_default_browser)
val isDefaultBrowserNow = isDefaultBrowserBlocking()
val wasDefaultBrowserOnLastResume = this.preferences.getBoolean(prefKey, isDefaultBrowserNow)
val wasDefaultBrowserOnLastResume =
this.preferences.getBoolean(prefKey, isDefaultBrowserNow)
this.preferences.edit().putBoolean(prefKey, isDefaultBrowserNow).apply()
return isDefaultBrowserNow && !wasDefaultBrowserOnLastResume
}
@ -534,7 +536,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var defaultBrowserNotificationDisplayed by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_should_show_default_browser_notification),
default = false
default = false,
)
fun shouldShowDefaultBrowserNotification(): Boolean {
@ -543,33 +545,33 @@ class Settings(private val appContext: Context) : PreferencesHolder {
val shouldUseAutoBatteryTheme by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_auto_battery_theme),
default = false
default = false,
)
val useStandardTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_standard_option),
true
true,
)
val useStrictTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_strict_default),
false
false,
)
val useCustomTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_custom_option),
false
false,
)
@VisibleForTesting(otherwise = PRIVATE)
fun setStrictETP() {
preferences.edit().putBoolean(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_strict_default),
true
true,
).apply()
preferences.edit().putBoolean(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_standard_option),
false
false,
).apply()
appContext.components.let {
val policy = it.core.trackingProtectionPolicyFactory
@ -581,7 +583,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
val blockCookiesInCustomTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_custom_cookies),
true
true,
)
val enabledTotalCookieProtectionSetting: Boolean
@ -601,32 +603,32 @@ class Settings(private val appContext: Context) : PreferencesHolder {
appContext.getString(R.string.total_protection)
} else {
appContext.getString(R.string.social)
}
},
)
val blockTrackingContentInCustomTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_custom_tracking_content),
true
true,
)
val blockTrackingContentSelectionInCustomTrackingProtection by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_custom_tracking_content_select),
appContext.getString(R.string.all)
appContext.getString(R.string.all),
)
val blockCryptominersInCustomTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_custom_cryptominers),
true
true,
)
val blockFingerprintersInCustomTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_custom_fingerprinters),
true
true,
)
val blockRedirectTrackersInCustomTrackingProtection by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_redirect_trackers),
true
true,
)
/**
@ -645,7 +647,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
get() {
val lastKnownModeWasPrivate = preferences.getBoolean(
appContext.getPreferenceKey(R.string.pref_key_last_known_mode_private),
false
false,
)
return if (lastKnownModeWasPrivate) {
@ -660,7 +662,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
preferences.edit()
.putBoolean(
appContext.getPreferenceKey(R.string.pref_key_last_known_mode_private),
lastKnownModeWasPrivate
lastKnownModeWasPrivate,
)
.apply()
@ -669,43 +671,43 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var shouldDeleteBrowsingDataOnQuit by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_delete_browsing_data_on_quit),
default = false
default = false,
)
var deleteOpenTabs by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_delete_open_tabs_now),
default = true
default = true,
)
var deleteBrowsingHistory by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_delete_browsing_history_now),
default = true
default = true,
)
var deleteCookies by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_delete_cookies_now),
default = true
default = true,
)
var deleteCache by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_delete_caches_now),
default = true
default = true,
)
var deleteSitePermissions by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_delete_permissions_now),
default = true
default = true,
)
var deleteDownloads by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_delete_downloads_now),
default = true
default = true,
)
var shouldUseBottomToolbar by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_toolbar_bottom),
// Default accessibility users to top toolbar
default = !touchExplorationIsEnabled && !switchServiceIsEnabled
default = !touchExplorationIsEnabled && !switchServiceIsEnabled,
)
val toolbarPosition: ToolbarPosition
@ -755,24 +757,24 @@ class Settings(private val appContext: Context) : PreferencesHolder {
val passwordsEncryptionKeyGenerated by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_encryption_key_generated),
false
false,
)
fun recordPasswordsEncryptionKeyGenerated() = preferences.edit().putBoolean(
appContext.getPreferenceKey(R.string.pref_key_encryption_key_generated),
true
true,
).apply()
@VisibleForTesting(otherwise = PRIVATE)
internal val loginsSecureWarningSyncCount = counterPreference(
appContext.getPreferenceKey(R.string.pref_key_logins_secure_warning_sync),
maxCount = 1
maxCount = 1,
)
@VisibleForTesting(otherwise = PRIVATE)
internal val secureWarningCount = counterPreference(
appContext.getPreferenceKey(R.string.pref_key_secure_warning),
maxCount = 1
maxCount = 1,
)
fun incrementSecureWarningCount() = secureWarningCount.increment()
@ -781,27 +783,27 @@ class Settings(private val appContext: Context) : PreferencesHolder {
val shouldShowSearchSuggestions by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions),
default = true
default = true,
)
val shouldAutocompleteInAwesomebar by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_enable_autocomplete_urls),
default = true
default = true,
)
var defaultTopSitesAdded by booleanPreference(
appContext.getPreferenceKey(R.string.default_top_sites_added),
default = false
default = false,
)
var shouldShowSearchSuggestionsInPrivate by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions_in_private),
default = false
default = false,
)
var showSearchSuggestionsInPrivateOnboardingFinished by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions_in_private_onboarding),
default = false
default = false,
)
fun incrementVisitedInstallableCount() = pwaInstallableVisitCount.increment()
@ -809,7 +811,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
@VisibleForTesting(otherwise = PRIVATE)
internal val pwaInstallableVisitCount = counterPreference(
appContext.getPreferenceKey(R.string.pref_key_install_pwa_visits),
maxCount = 3
maxCount = 3,
)
private val userNeedsToVisitInstallableSites: Boolean
@ -835,12 +837,12 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var userKnowsAboutPwas by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_user_knows_about_pwa),
default = false
default = false,
)
var shouldShowOpenInAppBanner by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_should_show_open_in_app_banner),
default = true
default = true,
)
val shouldShowOpenInAppCfr: Boolean
@ -848,12 +850,12 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var shouldShowAutoCloseTabsBanner by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_should_show_auto_close_tabs_banner),
default = true
default = true,
)
var shouldShowInactiveTabsOnboardingPopup by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_should_show_inactive_tabs_popup),
default = true
default = true,
)
/**
@ -861,7 +863,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var hasInactiveTabsAutoCloseDialogBeenDismissed by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_has_inactive_tabs_auto_close_dialog_dismissed),
default = false
default = false,
)
/**
@ -887,7 +889,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
fun getSitePermissionsPhoneFeatureAction(
feature: PhoneFeature,
default: Action = Action.ASK_TO_ALLOW
default: Action = Action.ASK_TO_ALLOW,
) =
preferences.getInt(feature.getPreferenceKey(appContext), default.toInt()).toAction()
@ -901,7 +903,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
* the user selected setting as well.
*/
fun setAutoplayUserSetting(
autoplaySetting: Int
autoplaySetting: Int,
) {
preferences.edit().putInt(AUTOPLAY_USER_SETTING, autoplaySetting).apply()
}
@ -919,12 +921,12 @@ class Settings(private val appContext: Context) : PreferencesHolder {
private fun getSitePermissionsPhoneFeatureAutoplayAction(
feature: PhoneFeature,
default: AutoplayAction = AutoplayAction.BLOCKED
default: AutoplayAction = AutoplayAction.BLOCKED,
) = preferences.getInt(feature.getPreferenceKey(appContext), default.toInt()).toAutoplayAction()
fun setSitePermissionsPhoneFeatureAction(
feature: PhoneFeature,
value: Action
value: Action,
) {
preferences.edit().putInt(feature.getPreferenceKey(appContext), value.toInt()).apply()
}
@ -937,15 +939,15 @@ class Settings(private val appContext: Context) : PreferencesHolder {
camera = getSitePermissionsPhoneFeatureAction(PhoneFeature.CAMERA),
autoplayAudible = getSitePermissionsPhoneFeatureAutoplayAction(
feature = PhoneFeature.AUTOPLAY_AUDIBLE,
default = AutoplayAction.BLOCKED
default = AutoplayAction.BLOCKED,
),
autoplayInaudible = getSitePermissionsPhoneFeatureAutoplayAction(
feature = PhoneFeature.AUTOPLAY_INAUDIBLE,
default = AutoplayAction.ALLOWED
default = AutoplayAction.ALLOWED,
),
persistentStorage = getSitePermissionsPhoneFeatureAction(PhoneFeature.PERSISTENT_STORAGE),
crossOriginStorageAccess = getSitePermissionsPhoneFeatureAction(PhoneFeature.CROSS_ORIGIN_STORAGE_ACCESS),
mediaKeySystemAccess = getSitePermissionsPhoneFeatureAction(PhoneFeature.MEDIA_KEY_SYSTEM_ACCESS)
mediaKeySystemAccess = getSitePermissionsPhoneFeatureAction(PhoneFeature.MEDIA_KEY_SYSTEM_ACCESS),
)
}
@ -959,7 +961,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
PhoneFeature.AUTOPLAY_INAUDIBLE,
PhoneFeature.PERSISTENT_STORAGE,
PhoneFeature.CROSS_ORIGIN_STORAGE_ACCESS,
PhoneFeature.MEDIA_KEY_SYSTEM_ACCESS
PhoneFeature.MEDIA_KEY_SYSTEM_ACCESS,
).map { it.getPreferenceKey(appContext) }
preferences.registerOnSharedPreferenceChangeListener(lifecycleOwner) { _, key ->
@ -969,7 +971,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var shouldShowVoiceSearch by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_show_voice_search),
default = true
default = true,
)
/**
@ -978,7 +980,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var shouldShowCameraPermissionPrompt by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_camera_permissions_needed),
default = true
default = true,
)
/**
@ -987,22 +989,22 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var setCameraPermissionNeededState by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_camera_permissions_needed),
default = true
default = true,
)
var shouldPromptToSaveLogins by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_save_logins),
default = true
default = true,
)
var shouldAutofillLogins by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_autofill_logins),
default = true
default = true,
)
var lastPlacesStorageMaintenance by longPreference(
appContext.getPreferenceKey(R.string.pref_key_last_maintenance),
default = 0
default = 0,
)
fun addSearchWidgetInstalled(count: Int) {
@ -1016,18 +1018,18 @@ class Settings(private val appContext: Context) : PreferencesHolder {
val searchWidgetInstalled: Boolean
get() = 0 < preferences.getInt(
appContext.getPreferenceKey(R.string.pref_key_search_widget_installed),
0
0,
)
fun incrementNumTimesPrivateModeOpened() = numTimesPrivateModeOpened.increment()
var showedPrivateModeContextualFeatureRecommender by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_showed_private_mode_cfr),
default = false
default = false,
)
private val numTimesPrivateModeOpened = counterPreference(
appContext.getPreferenceKey(R.string.pref_key_private_mode_opened)
appContext.getPreferenceKey(R.string.pref_key_private_mode_opened),
)
val shouldShowPrivateModeCfr: Boolean
@ -1052,37 +1054,37 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var openLinksInExternalApp by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_open_links_in_external_app),
default = false
default = false,
)
var allowDomesticChinaFxaServer by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_allow_domestic_china_fxa_server),
default = true
default = true,
)
var overrideFxAServer by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_override_fxa_server),
default = ""
default = "",
)
var overrideSyncTokenServer by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_override_sync_tokenserver),
default = ""
default = "",
)
var overridePushServer by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_override_push_server),
default = ""
default = "",
)
var overrideAmoUser by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_override_amo_user),
default = ""
default = "",
)
var overrideAmoCollection by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_override_amo_collection),
default = ""
default = "",
)
fun amoCollectionOverrideConfigured(): Boolean {
@ -1091,27 +1093,27 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var topSitesSize by intPreference(
appContext.getPreferenceKey(R.string.pref_key_top_sites_size),
default = 0
default = 0,
)
val topSitesMaxLimit by intPreference(
appContext.getPreferenceKey(R.string.pref_key_top_sites_max_limit),
default = TOP_SITES_MAX_COUNT
default = TOP_SITES_MAX_COUNT,
)
var openTabsCount by intPreference(
appContext.getPreferenceKey(R.string.pref_key_open_tabs_count),
0
0,
)
var mobileBookmarksSize by intPreference(
appContext.getPreferenceKey(R.string.pref_key_mobile_bookmarks_size),
0
0,
)
var desktopBookmarksSize by intPreference(
appContext.getPreferenceKey(R.string.pref_key_desktop_bookmarks_size),
0
0,
)
/**
@ -1119,7 +1121,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var installedAddonsCount by intPreference(
appContext.getPreferenceKey(R.string.pref_key_installed_addons_count),
0
0,
)
/**
@ -1127,8 +1129,9 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var installedAddonsList by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_installed_addons_list),
default = ""
default = "",
)
/**
* URLs from the user's history that contain this search param will be hidden.
* The value is a string with one of the following forms:
@ -1139,7 +1142,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
val frecencyFilterQuery by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_frecency_filter_query),
default = "mfadid=adm" // Parameter provided by adM
default = "mfadid=adm", // Parameter provided by adM
)
/**
@ -1147,7 +1150,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var enabledAddonsCount by intPreference(
appContext.getPreferenceKey(R.string.pref_key_enabled_addons_count),
0
0,
)
/**
@ -1155,12 +1158,12 @@ class Settings(private val appContext: Context) : PreferencesHolder {
*/
var enabledAddonsList by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_enabled_addons_list),
default = ""
default = "",
)
private var savedLoginsSortingStrategyString by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_saved_logins_sorting_strategy),
default = SavedLoginsSortingStrategyMenu.Item.AlphabeticallySort.strategyString
default = SavedLoginsSortingStrategyMenu.Item.AlphabeticallySort.strategyString,
)
val savedLoginsMenuHighlightedItem: SavedLoginsSortingStrategyMenu.Item
@ -1184,23 +1187,23 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var isPullToRefreshEnabledInBrowser by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_website_pull_to_refresh),
default = true
default = true,
)
var isDynamicToolbarEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_dynamic_toolbar),
default = true
default = true,
)
var isSwipeToolbarToSwitchTabsEnabled by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_swipe_toolbar_switch_tabs),
default = true
default = true,
)
var addressFeature by featureFlagPreference(
appContext.getPreferenceKey(R.string.pref_key_show_address_feature),
default = true,
featureFlag = isAddressFeatureEnabled(appContext)
featureFlag = isAddressFeatureEnabled(appContext),
)
/**
@ -1212,25 +1215,27 @@ class Settings(private val appContext: Context) : PreferencesHolder {
return listOf(
"en-US",
"en-CA",