tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 6a107d181b6e8e01393fc5685a7c2134e6a4caae
parent 17d6947e95f4de6de8848f118a4691a4924f9091
Author: Roger Yang <royang@mozilla.com>
Date:   Mon, 27 Oct 2025 18:21:19 +0000

Bug 1994747 - Remove trending search and recent searches Nimbus flags. r=android-reviewers,gl

Differential Revision: https://phabricator.services.mozilla.com/D268911

Diffstat:
Mmobile/android/android-components/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/RecentSearchSuggestionsProvider.kt | 4++--
Mmobile/android/android-components/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/TrendingSearchProvider.kt | 4++--
Mmobile/android/android-components/components/feature/awesomebar/src/test/java/mozilla/components/feature/awesomebar/provider/RecentSearchSuggestionsProviderTest.kt | 28+++++++++++++++++++++++-----
Mmobile/android/fenix/app/nimbus.fml.yaml | 26--------------------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt | 2+-
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/awesomebar/SearchSuggestionsProvidersBuilder.kt | 3---
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt | 12------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineFragment.kt | 8+-------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt | 27+--------------------------
Mmobile/android/fenix/app/src/main/res/values/preference_keys.xml | 2--
Mmobile/android/fenix/app/src/main/res/values/static_strings.xml | 4----
Mmobile/android/fenix/app/src/main/res/xml/secret_settings_preferences.xml | 8--------
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/FenixSearchMiddlewareTest.kt | 1-
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt | 19+------------------
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt | 17-----------------
15 files changed, 31 insertions(+), 134 deletions(-)

diff --git a/mobile/android/android-components/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/RecentSearchSuggestionsProvider.kt b/mobile/android/android-components/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/RecentSearchSuggestionsProvider.kt @@ -20,9 +20,9 @@ import mozilla.components.feature.search.ext.buildSearchUrl import java.util.UUID /** - * Return 2 recent search suggestions by default. Same as on desktop. + * Number of recent search suggestions to return by default. */ -const val DEFAULT_RECENT_SEARCH_SUGGESTION_LIMIT = 2 +const val DEFAULT_RECENT_SEARCH_SUGGESTION_LIMIT = 5 /** * Error message if clients are requesting for a too big number of suggestions. diff --git a/mobile/android/android-components/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/TrendingSearchProvider.kt b/mobile/android/android-components/components/feature/awesomebar/src/main/java/mozilla/components/feature/awesomebar/provider/TrendingSearchProvider.kt @@ -23,8 +23,8 @@ import java.io.IOException import java.util.UUID import java.util.concurrent.TimeUnit -// Return 4 trending searches by default. -const val DEFAULT_TRENDING_SEARCHES_LIMIT = 4 +// Number of trending searches to display by default. +const val DEFAULT_TRENDING_SEARCHES_LIMIT = 5 const val TRENDING_SEARCHES_MAXIMUM_ALLOWED_SUGGESTIONS_LIMIT: Int = 1000 /** diff --git a/mobile/android/android-components/components/feature/awesomebar/src/test/java/mozilla/components/feature/awesomebar/provider/RecentSearchSuggestionsProviderTest.kt b/mobile/android/android-components/components/feature/awesomebar/src/test/java/mozilla/components/feature/awesomebar/provider/RecentSearchSuggestionsProviderTest.kt @@ -216,7 +216,7 @@ class RecentSearchSuggestionsProviderTest { } @Test - fun `GIVEN a valid input WHEN querying suggestions THEN return by default 2 suggestions`() = runTest { + fun `GIVEN a valid input WHEN querying suggestions THEN return by default 5 suggestions`() = runTest { val historyEntries = listOf( historyEntry.copy( key = historyEntry.key.copy(searchTerm = "fir"), @@ -227,20 +227,38 @@ class RecentSearchSuggestionsProviderTest { createdAt = 2, ), historyEntry.copy( - key = historyEntry.key.copy(searchTerm = "firefox"), + key = historyEntry.key.copy(searchTerm = "firef"), createdAt = 3, ), + historyEntry.copy( + key = historyEntry.key.copy(searchTerm = "firefo"), + createdAt = 4, + ), + historyEntry.copy( + key = historyEntry.key.copy(searchTerm = "firefox"), + createdAt = 5, + ), + historyEntry.copy( + key = historyEntry.key.copy(searchTerm = "firefox!"), + createdAt = 6, + ), ) doReturn(historyEntries).`when`(storage).getHistoryMetadataSince(Long.MIN_VALUE) val provider = RecentSearchSuggestionsProvider(storage, mock(), searchEngine) val suggestions = provider.onInputChanged("") - assertEquals(2, suggestions.size) - assertEquals(historyEntries[2].key.searchTerm, suggestions[0].title) + assertEquals(5, suggestions.size) + assertEquals(historyEntries[5].key.searchTerm, suggestions[0].title) assertEquals(Int.MAX_VALUE - 2, suggestions[0].score) - assertEquals(historyEntries[1].key.searchTerm, suggestions[1].title) + assertEquals(historyEntries[4].key.searchTerm, suggestions[1].title) assertEquals(Int.MAX_VALUE - 3, suggestions[1].score) + assertEquals(historyEntries[3].key.searchTerm, suggestions[2].title) + assertEquals(Int.MAX_VALUE - 4, suggestions[2].score) + assertEquals(historyEntries[2].key.searchTerm, suggestions[3].title) + assertEquals(Int.MAX_VALUE - 5, suggestions[3].score) + assertEquals(historyEntries[1].key.searchTerm, suggestions[4].title) + assertEquals(Int.MAX_VALUE - 6, suggestions[4].score) } @Test diff --git a/mobile/android/fenix/app/nimbus.fml.yaml b/mobile/android/fenix/app/nimbus.fml.yaml @@ -693,32 +693,6 @@ features: value: enabled: true - trending-searches: - description: Enables trending searches. - variables: - enabled: - description: > - Whether or not to enable trending searches. - type: Boolean - default: true - max-suggestions: - description: The number of maximum suggestions. - type: Int - default: 5 - - recent-searches: - description: Enables recent searches. - variables: - enabled: - description: > - Whether or not to enable recent searches. - type: Boolean - default: true - max-suggestions: - description: The number of maximum suggestions. - type: Int - default: 5 - search-suggestions-on-homepage: description: Enables search suggestions on homepage. variables: diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/SearchFragmentStore.kt @@ -674,5 +674,5 @@ internal fun shouldShowTrendingSearchSuggestions( settings: Settings, isTrendingSuggestionSupported: Boolean, ) = - settings.trendingSearchSuggestionsEnabled && settings.isTrendingSearchesVisible && + settings.trendingSearchSuggestionsEnabled && isTrendingSuggestionSupported && shouldShowSearchSuggestions(browsingMode, settings) diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/awesomebar/SearchSuggestionsProvidersBuilder.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/search/awesomebar/SearchSuggestionsProvidersBuilder.kt @@ -36,7 +36,6 @@ import org.mozilla.fenix.components.Components import org.mozilla.fenix.components.Core.Companion.METADATA_HISTORY_SUGGESTION_LIMIT import org.mozilla.fenix.components.Core.Companion.METADATA_SHORTCUT_SUGGESTION_LIMIT import org.mozilla.fenix.ext.containsQueryParameters -import org.mozilla.fenix.nimbus.FxNimbus import org.mozilla.fenix.search.SearchEngineSource /** @@ -117,7 +116,6 @@ class SearchSuggestionsProvidersBuilder( fetchClient = components.core.client, privateMode = browsingModeManager.mode.isPrivate, searchUseCase = searchUseCase, - limit = FxNimbus.features.trendingSearches.value().maxSuggestions, icon = searchBitmap, ) @@ -179,7 +177,6 @@ class SearchSuggestionsProvidersBuilder( if (state.showRecentSearches) { getRecentSearchSuggestionsProvider( searchEngineSource = state.searchEngineSource, - maxNumberOfSuggestions = FxNimbus.features.recentSearches.value().maxSuggestions, )?.let { providersToAdd.add(it) } } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SecretSettingsFragment.kt @@ -193,12 +193,6 @@ class SecretSettingsFragment : PreferenceFragmentCompat() { onPreferenceChangeListener = SharedPreferenceUpdater() } - requirePreference<SwitchPreference>(R.string.pref_key_enable_trending_searches).apply { - isVisible = true - isChecked = context.settings().isTrendingSearchesVisible - onPreferenceChangeListener = SharedPreferenceUpdater() - } - requirePreference<SwitchPreference>(R.string.pref_key_enable_lna_blocking_enabled).apply { isVisible = Config.channel.isNightlyOrDebug isChecked = context.settings().isLnaBlockingEnabled @@ -211,12 +205,6 @@ class SecretSettingsFragment : PreferenceFragmentCompat() { } } - requirePreference<SwitchPreference>(R.string.pref_key_enable_recent_searches).apply { - isVisible = true - isChecked = context.settings().isRecentSearchesVisible - onPreferenceChangeListener = SharedPreferenceUpdater() - } - requirePreference<SwitchPreference>(R.string.pref_key_allow_settings_search).apply { isVisible = Config.channel.isNightlyOrDebug isChecked = context.settings().isSettingsSearchEnabled diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/search/SearchEngineFragment.kt @@ -47,12 +47,6 @@ class SearchEngineFragment : PreferenceFragmentCompat() { requirePreference<Preference>(R.string.pref_key_learn_about_fx_suggest).apply { isVisible = context.settings().enableFxSuggest } - requirePreference<CheckBoxPreference>(R.string.pref_key_show_trending_search_suggestions).apply { - isVisible = context.settings().isTrendingSearchesVisible - } - requirePreference<SwitchPreference>(R.string.pref_key_show_recent_search_suggestions).apply { - isVisible = context.settings().isRecentSearchesVisible - } view?.hideKeyboard() } @@ -78,7 +72,7 @@ class SearchEngineFragment : PreferenceFragmentCompat() { val trendingSearchSuggestionsPreference = requirePreference<CheckBoxPreference>(R.string.pref_key_show_trending_search_suggestions).apply { - isVisible = context.settings().isTrendingSearchesVisible + isChecked = context.settings().trendingSearchSuggestionsEnabled isEnabled = getSelectedSearchEngine(requireContext())?.trendingUrl != null && context.settings().shouldShowSearchSuggestions } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -1499,18 +1499,11 @@ class Settings(private val appContext: Context) : PreferencesHolder { /** * Indicates if the user have enabled recent search in the search suggestions setting preference. */ - @VisibleForTesting - internal var recentSearchSuggestionsEnabled by booleanPreference( + internal var shouldShowRecentSearchSuggestions by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_show_recent_search_suggestions), default = true, ) - /** - * Returns true if recent searches should be shown to the user. - */ - val shouldShowRecentSearchSuggestions: Boolean - get() = recentSearchSuggestionsEnabled && isRecentSearchesVisible - var showSearchSuggestionsInPrivateOnboardingFinished by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions_in_private_onboarding), default = false, @@ -2331,24 +2324,6 @@ class Settings(private val appContext: Context) : PreferencesHolder { ) /** - * Indicates if Trending Search Suggestions are enabled. - */ - var isTrendingSearchesVisible by lazyFeatureFlagPreference( - key = appContext.getPreferenceKey(R.string.pref_key_enable_trending_searches), - default = { FxNimbus.features.trendingSearches.value().enabled }, - featureFlag = true, - ) - - /** - * Indicates if Recent Search Suggestions are enabled. - */ - var isRecentSearchesVisible by lazyFeatureFlagPreference( - key = appContext.getPreferenceKey(R.string.pref_key_enable_recent_searches), - default = { FxNimbus.features.recentSearches.value().enabled }, - featureFlag = true, - ) - - /** * Adjust Activated User sent */ var growthUserActivatedSent by booleanPreference( diff --git a/mobile/android/fenix/app/src/main/res/values/preference_keys.xml b/mobile/android/fenix/app/src/main/res/values/preference_keys.xml @@ -433,8 +433,6 @@ <string name="pref_key_enable_discover_more_stories" translatable="false">pref_key_enable_discover_more_stories</string> <string name="pref_key_enable_private_browsing_mode_redesign" translatable="false">pref_key_enable_private_browsing_mode_redesign</string> <string name="pref_key_enable_unified_trust_panel" translatable="false">pref_key_enable_unified_trust_panel</string> - <string name="pref_key_enable_trending_searches" translatable="false">pref_key_enable_trending_searches</string> - <string name="pref_key_enable_recent_searches" translatable="false">pref_key_enable_recent_searches</string> <string name="pref_key_enable_composable_toolbar" translatable="false">pref_key_enable_composable_toolbar</string>" <string name="pref_key_enable_toolbar_redesign" translatable="false">pref_key_enable_toolbar_redesign</string>" <string name="pref_key_enable_address_sync" translatable="false">pref_key_enable_address_sync</string>" diff --git a/mobile/android/fenix/app/src/main/res/values/static_strings.xml b/mobile/android/fenix/app/src/main/res/values/static_strings.xml @@ -109,12 +109,8 @@ <string name="preferences_debug_settings_microsurvey_feature" translatable="false">Enable Microsurvey Feature</string> <!-- Label for enabling Unified Trust Panel --> <string name="preferences_debug_settings_unified_trust_panel" translatable="false">Enable Unified Trust Panel</string> - <!-- Label for enabling Trending Searches --> - <string name="preferences_debug_settings_trending_searches" translatable="false">Enable Trending Searches</string> <!-- Label for enabling remote search configuration --> <string name="preferences_debug_settings_remote_search_configuration" translatable="false">Enable Remote Search Configuration (requires restart)</string> - <!-- Label for enabling Recent Searches --> - <string name="preferences_debug_settings_recent_searches" translatable="false">Enable Recent Searches</string> <!-- Label for enabling Address Sync --> <string name="preferences_debug_settings_address_sync" translatable="false">Enable Address Sync for supported regions</string> <!-- Label for enabling Settings Search--> diff --git a/mobile/android/fenix/app/src/main/res/xml/secret_settings_preferences.xml b/mobile/android/fenix/app/src/main/res/xml/secret_settings_preferences.xml @@ -83,18 +83,10 @@ android:title="@string/preferences_debug_settings_unified_trust_panel" app:iconSpaceReserved="false" /> <SwitchPreference - android:key="@string/pref_key_enable_trending_searches" - android:title="@string/preferences_debug_settings_trending_searches" - app:iconSpaceReserved="false" /> - <SwitchPreference android:key="@string/pref_key_use_remote_search_configuration" android:title="@string/preferences_debug_settings_remote_search_configuration" app:iconSpaceReserved="false" /> <SwitchPreference - android:key="@string/pref_key_enable_recent_searches" - android:title="@string/preferences_debug_settings_recent_searches" - app:iconSpaceReserved="false" /> - <SwitchPreference android:defaultValue="false" android:key="@string/pref_key_enable_debug_drawer" android:title="@string/preferences_debug_settings_debug_drawer" diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/FenixSearchMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/FenixSearchMiddlewareTest.kt @@ -257,7 +257,6 @@ class FenixSearchMiddlewareTest { fun `GIVEN trending searches are enabled WHEN search starts starts for the current webpage THEN show new search suggestions`() { val (_, store) = buildMiddlewareAndAddToSearchStore() every { settings.trendingSearchSuggestionsEnabled } returns true - every { settings.isTrendingSearchesVisible } returns true every { settings.shouldShowSearchSuggestions } returns true val defaultSearchEngine = fakeSearchEnginesState().selectedOrDefaultSearchEngine diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt @@ -766,7 +766,6 @@ class SearchFragmentStoreTest { every { settings.showSponsoredSuggestions } returns true every { settings.showNonSponsoredSuggestions } returns true every { settings.trendingSearchSuggestionsEnabled } returns true - every { settings.isTrendingSearchesVisible } returns true every { settings.shouldShowRecentSearchSuggestions } returns true store.dispatch( @@ -1245,10 +1244,9 @@ class SearchFragmentStoreTest { } @Test - fun `GIVEN trending searches is enabled, visible and search engine supports it THEN should show trending searches`() { + fun `GIVEN trending searches is enabled and search engine supports it THEN should show trending searches`() { var settings: Settings = mockk { every { trendingSearchSuggestionsEnabled } returns true - every { isTrendingSearchesVisible } returns true every { shouldShowSearchSuggestions } returns true every { shouldShowSearchSuggestionsInPrivate } returns true } @@ -1258,7 +1256,6 @@ class SearchFragmentStoreTest { settings = mockk { every { trendingSearchSuggestionsEnabled } returns false - every { isTrendingSearchesVisible } returns true every { shouldShowSearchSuggestions } returns true every { shouldShowSearchSuggestionsInPrivate } returns true } @@ -1268,17 +1265,6 @@ class SearchFragmentStoreTest { settings = mockk { every { trendingSearchSuggestionsEnabled } returns true - every { isTrendingSearchesVisible } returns false - every { shouldShowSearchSuggestions } returns true - every { shouldShowSearchSuggestionsInPrivate } returns true - } - - assertFalse(shouldShowTrendingSearchSuggestions(BrowsingMode.Private, settings, true)) - assertFalse(shouldShowTrendingSearchSuggestions(BrowsingMode.Normal, settings, true)) - - settings = mockk { - every { trendingSearchSuggestionsEnabled } returns true - every { isTrendingSearchesVisible } returns true every { shouldShowSearchSuggestions } returns false every { shouldShowSearchSuggestionsInPrivate } returns true } @@ -1291,7 +1277,6 @@ class SearchFragmentStoreTest { fun `GIVEN search engine does not supports trending search THEN should not show trending searches`() { val settings: Settings = mockk { every { trendingSearchSuggestionsEnabled } returns true - every { isTrendingSearchesVisible } returns true every { shouldShowSearchSuggestions } returns true every { shouldShowSearchSuggestionsInPrivate } returns true } @@ -1304,7 +1289,6 @@ class SearchFragmentStoreTest { fun `GIVEN is private tab THEN should show trending searches only if allowed`() { var settings: Settings = mockk { every { trendingSearchSuggestionsEnabled } returns true - every { isTrendingSearchesVisible } returns true every { shouldShowSearchSuggestions } returns true every { shouldShowSearchSuggestionsInPrivate } returns false } @@ -1314,7 +1298,6 @@ class SearchFragmentStoreTest { settings = mockk { every { trendingSearchSuggestionsEnabled } returns true - every { isTrendingSearchesVisible } returns true every { shouldShowSearchSuggestions } returns true every { shouldShowSearchSuggestionsInPrivate } returns true } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt @@ -1115,23 +1115,6 @@ class SettingsTest { } @Test - fun `GIVEN recent search is enable THEN should show recent searches only if recent search is visible`() { - val settings = spyk(settings) - every { settings.recentSearchSuggestionsEnabled } returns true - every { settings.isRecentSearchesVisible } returns true - - assertTrue(settings.shouldShowRecentSearchSuggestions) - - every { settings.isRecentSearchesVisible } returns false - every { settings.recentSearchSuggestionsEnabled } returns true - assertFalse(settings.shouldShowRecentSearchSuggestions) - - every { settings.isRecentSearchesVisible } returns true - every { settings.recentSearchSuggestionsEnabled } returns false - assertFalse(settings.shouldShowRecentSearchSuggestions) - } - - @Test fun `GIVEN the conditions to show a prompt are not met WHEN checking prompt eligibility THEN shouldShowSetAsDefaultPrompt is false`() { settings.numberOfSetAsDefaultPromptShownTimes = 0 settings.lastSetAsDefaultPromptShownTimeInMillis = System.currentTimeMillis()