omnibox_features.cc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/omnibox/common/omnibox_features.h"
  5. #include "build/build_config.h"
  6. namespace omnibox {
  7. constexpr auto enabled_by_default_desktop_only =
  8. #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
  9. base::FEATURE_DISABLED_BY_DEFAULT;
  10. #else
  11. base::FEATURE_ENABLED_BY_DEFAULT;
  12. #endif
  13. constexpr auto enabled_by_default_android_only =
  14. #if BUILDFLAG(IS_ANDROID)
  15. base::FEATURE_ENABLED_BY_DEFAULT;
  16. #else
  17. base::FEATURE_DISABLED_BY_DEFAULT;
  18. #endif
  19. constexpr auto enabled_by_default_desktop_android =
  20. #if BUILDFLAG(IS_IOS)
  21. base::FEATURE_DISABLED_BY_DEFAULT;
  22. #else
  23. base::FEATURE_ENABLED_BY_DEFAULT;
  24. #endif
  25. // Comment out this macro since it is currently not being used in this file.
  26. // const auto enabled_by_default_android_ios =
  27. // #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
  28. // base::FEATURE_ENABLED_BY_DEFAULT;
  29. // #else
  30. // base::FEATURE_DISABLED_BY_DEFAULT;
  31. // #endif
  32. // Feature used to enable various experiments on keyword mode, UI and
  33. // suggestions.
  34. const base::Feature kExperimentalKeywordMode{"OmniboxExperimentalKeywordMode",
  35. base::FEATURE_DISABLED_BY_DEFAULT};
  36. // Feature to enable showing thumbnail in front of the Omnibox clipboard image
  37. // search suggestion.
  38. const base::Feature kImageSearchSuggestionThumbnail{
  39. "ImageSearchSuggestionThumbnail", enabled_by_default_android_only};
  40. // Feature used to allow users to remove suggestions from clipboard.
  41. const base::Feature kOmniboxRemoveSuggestionsFromClipboard{
  42. "OmniboxRemoveSuggestionsFromClipboard", enabled_by_default_android_only};
  43. // Auxiliary search for Android. See http://crbug/1310100 for more details.
  44. const base::Feature kAndroidAuxiliarySearch{"AndroidAuxiliarySearch",
  45. base::FEATURE_DISABLED_BY_DEFAULT};
  46. // Enables various tweaks to `AutocompleteController` autocompletion twiddling
  47. // that may improve autocompletion stability. Feature params control which
  48. // tweaks specifically are enabled. Enabling this feature without params is a
  49. // no-op.
  50. const base::Feature kAutocompleteStability{"OmniboxAutocompleteStability",
  51. base::FEATURE_DISABLED_BY_DEFAULT};
  52. // Demotes the relevance scores when comparing suggestions based on the
  53. // suggestion's |AutocompleteMatchType| and the user's |PageClassification|.
  54. // This feature's main job is to contain the DemoteByType parameter.
  55. const base::Feature kOmniboxDemoteByType{"OmniboxDemoteByType",
  56. base::FEATURE_DISABLED_BY_DEFAULT};
  57. // Feature used to cap max zero suggestions shown according to the param
  58. // OmniboxMaxZeroSuggestMatches. If omitted,
  59. // OmniboxUIExperimentMaxAutocompleteMatches will be used instead. If present,
  60. // OmniboxMaxZeroSuggestMatches will override
  61. // OmniboxUIExperimentMaxAutocompleteMatches when |from_omnibox_focus| is true.
  62. const base::Feature kMaxZeroSuggestMatches{"OmniboxMaxZeroSuggestMatches",
  63. base::FEATURE_DISABLED_BY_DEFAULT};
  64. // Feature used to cap max suggestions shown according to the params
  65. // UIMaxAutocompleteMatches and UIMaxAutocompleteMatchesByProvider.
  66. const base::Feature kUIExperimentMaxAutocompleteMatches{
  67. "OmniboxUIExperimentMaxAutocompleteMatches",
  68. base::FEATURE_DISABLED_BY_DEFAULT};
  69. // Feature used to cap the number of URL-type matches shown within the
  70. // Omnibox. If enabled, the number of URL-type matches is limited (unless
  71. // there are no more non-URL matches available.) If enabled, there is a
  72. // companion parameter - OmniboxMaxURLMatches - which specifies the maximum
  73. // desired number of URL-type matches.
  74. const base::Feature kOmniboxMaxURLMatches{"OmniboxMaxURLMatches",
  75. enabled_by_default_desktop_android};
  76. // Feature used to cap max suggestions to a dynamic limit based on how many URLs
  77. // would be shown. E.g., show up to 10 suggestions if doing so would display no
  78. // URLs; else show up to 8 suggestions if doing so would include 1 or more URLs.
  79. const base::Feature kDynamicMaxAutocomplete{"OmniboxDynamicMaxAutocomplete",
  80. enabled_by_default_desktop_android};
  81. // Used to adjust the relevance for the local history zero-prefix suggestions.
  82. // If enabled, the relevance is determined by this feature's companion
  83. // parameter, OmniboxFieldTrial::kLocalHistoryZeroSuggestRelevanceScore.
  84. const base::Feature kAdjustLocalHistoryZeroSuggestRelevanceScore{
  85. "AdjustLocalHistoryZeroSuggestRelevanceScore",
  86. base::FEATURE_DISABLED_BY_DEFAULT};
  87. // Enables on-clobber (i.e., when the user clears the whole omnibox text)
  88. // zero-prefix suggestions on the Open Web, that are contextual to the current
  89. // URL. Will only work if user is signed-in and syncing, or is otherwise
  90. // eligible to send the current page URL to the suggest server.
  91. const base::Feature kClobberTriggersContextualWebZeroSuggest{
  92. "OmniboxClobberTriggersContextualWebZeroSuggest",
  93. enabled_by_default_desktop_only};
  94. // Enables on-clobber (i.e., when the user clears the whole omnibox text)
  95. // zero-prefix suggestions on the SRP.
  96. const base::Feature kClobberTriggersSRPZeroSuggest{
  97. "OmniboxClobberTriggersSRPZeroSuggest", enabled_by_default_desktop_only};
  98. // Enables on-focus zero-prefix suggestions on the Open Web, that are contextual
  99. // to the current URL. Will only work if user is signed-in and syncing, or is
  100. // otherwise eligible to send the current page URL to the suggest server.
  101. const base::Feature kFocusTriggersContextualWebZeroSuggest{
  102. "OmniboxFocusTriggersContextualWebZeroSuggest",
  103. enabled_by_default_android_only};
  104. // Enables on-focus zero-prefix suggestions on the SRP.
  105. const base::Feature kFocusTriggersSRPZeroSuggest{
  106. "OmniboxFocusTriggersSRPZeroSuggest", enabled_by_default_android_only};
  107. // Revamps how local search history is extracted and processed for generating
  108. // zero-prefix and prefix suggestions.
  109. extern const base::Feature kLocalHistorySuggestRevamp{
  110. "LocalHistorySuggestRevamp", base::FEATURE_DISABLED_BY_DEFAULT};
  111. // Enables local history zero-prefix suggestions in every context in which the
  112. // remote zero-prefix suggestions are enabled.
  113. const base::Feature kLocalHistoryZeroSuggestBeyondNTP{
  114. "LocalHistoryZeroSuggestBeyondNTP", base::FEATURE_DISABLED_BY_DEFAULT};
  115. // Used to adjust the age threshold since the last visit in order to consider a
  116. // normalized keyword search term as a zero-prefix suggestion. If disabled, the
  117. // default value of 60 days for Desktop and 7 days for Android and iOS is used.
  118. // If enabled, the age threshold is determined by this feature's companion
  119. // parameter, OmniboxFieldTrial::kOmniboxLocalZeroSuggestAgeThresholdParam.
  120. const base::Feature kOmniboxLocalZeroSuggestAgeThreshold{
  121. "OmniboxLocalZeroSuggestAgeThreshold", base::FEATURE_DISABLED_BY_DEFAULT};
  122. // Enables on-focus zero-prefix suggestions on the NTP for signed-out users.
  123. const base::Feature kZeroSuggestOnNTPForSignedOutUsers{
  124. "OmniboxTrendingZeroPrefixSuggestionsOnNTP",
  125. enabled_by_default_desktop_android};
  126. // Enables prefetching of the zero prefix suggestions for eligible users on NTP.
  127. const base::Feature kZeroSuggestPrefetching{"ZeroSuggestPrefetching",
  128. enabled_by_default_desktop_only};
  129. // Enables prefetching of the zero prefix suggestions for eligible users on SRP.
  130. const base::Feature kZeroSuggestPrefetchingOnSRP{
  131. "ZeroSuggestPrefetchingOnSRP", base::FEATURE_DISABLED_BY_DEFAULT};
  132. // Enables prefetching of the zero prefix suggestions for eligible users on the
  133. // Web (i.e. non-NTP and non-SRP URLs).
  134. const base::Feature kZeroSuggestPrefetchingOnWeb{
  135. "ZeroSuggestPrefetchingOnWeb", base::FEATURE_DISABLED_BY_DEFAULT};
  136. // Features to provide non personalized head search suggestion from a compact
  137. // on device model. More specifically, feature name with suffix Incognito /
  138. // NonIncognito will only controls behaviors under incognito / non-incognito
  139. // mode respectively.
  140. const base::Feature kOnDeviceHeadProviderIncognito{
  141. "OmniboxOnDeviceHeadProviderIncognito", base::FEATURE_ENABLED_BY_DEFAULT};
  142. const base::Feature kOnDeviceHeadProviderNonIncognito{
  143. "OmniboxOnDeviceHeadProviderNonIncognito",
  144. base::FEATURE_ENABLED_BY_DEFAULT};
  145. // If enabled, changes the way Google-provided search suggestions are scored by
  146. // the backend. Note that this Feature is only used for triggering a server-
  147. // side experiment config that will send experiment IDs to the backend. It is
  148. // not referred to in any of the Chromium code.
  149. const base::Feature kOmniboxExperimentalSuggestScoring{
  150. "OmniboxExperimentalSuggestScoring", base::FEATURE_DISABLED_BY_DEFAULT};
  151. // If enabled, the HistoryQuickProvider's InMemoryURLIndex service never
  152. // persists its index to a cache file on shutdown, and instead always rebuilds
  153. // it from the HistoryService on startup. Persisting the index to disk causes
  154. // over 10% of all shutdown hangs.
  155. const base::Feature kHistoryQuickProviderAblateInMemoryURLIndexCacheFile{
  156. "OmniboxHistoryQuickProviderAblateInMemoryURLIndexCacheFile",
  157. base::FEATURE_ENABLED_BY_DEFAULT};
  158. // If enabled, suggestions from a cgi param name match are scored to 0.
  159. const base::Feature kDisableCGIParamMatching{"OmniboxDisableCGIParamMatching",
  160. base::FEATURE_DISABLED_BY_DEFAULT};
  161. // Features used to enable matching short inputs to bookmarks for suggestions.
  162. // By default, if both of the following are disabled, input words shorter than 3
  163. // characters won't prefix match bookmarks. E.g., the inputs 'abc x' or 'x'
  164. // won't match bookmark text 'abc xyz'.
  165. // If |kShortBookmarkSuggestions()| is enabled, this limitation is lifted and
  166. // both inputs 'abc x' and 'x' can match bookmark text 'abc xyz'.
  167. // If |kShortBookmarkSuggestionsByTotalInputLength()| is enabled, matching is
  168. // limited by input length rather than input word length. Input 'abc x' can
  169. // but input 'x' can't match bookmark text 'abc xyz'.
  170. const base::Feature kShortBookmarkSuggestions{
  171. "OmniboxShortBookmarkSuggestions", base::FEATURE_DISABLED_BY_DEFAULT};
  172. const base::Feature kShortBookmarkSuggestionsByTotalInputLength{
  173. "OmniboxShortBookmarkSuggestionsByTotalInputLength",
  174. base::FEATURE_DISABLED_BY_DEFAULT};
  175. // If enabled, inputs may match bookmark paths. These path matches won't
  176. // contribute to scoring. E.g. 'planets jupiter' can suggest a bookmark titled
  177. // 'Jupiter' with URL 'en.wikipedia.org/wiki/Jupiter' located in a path
  178. // containing 'planet.'
  179. const base::Feature kBookmarkPaths{"OmniboxBookmarkPaths",
  180. base::FEATURE_DISABLED_BY_DEFAULT};
  181. // If disabled, shortcuts to the same stripped destination URL are scored
  182. // independently, and only the highest scored shortcut is kept. If enabled,
  183. // duplicate shortcuts are given an aggregate score, as if they had been a
  184. // single shortcut.
  185. const base::Feature kAggregateShortcuts{"OmniboxAggregateShortcuts",
  186. base::FEATURE_ENABLED_BY_DEFAULT};
  187. // If enabled, when updating or creating a shortcut, the last word of the input
  188. // is expanded, if possible, to a complete word in the suggestion description.
  189. const base::Feature kShortcutExpanding{"OmniboxShortcutExpanding",
  190. base::FEATURE_DISABLED_BY_DEFAULT};
  191. // If enabled, the relevant AutocompleteProviders will store "title" data in
  192. // AutocompleteMatch::contents and "URL" data in AutocompleteMatch::description
  193. // for URL-based omnibox suggestions (see crbug.com/1202964 for more details).
  194. const base::Feature kStoreTitleInContentsAndUrlInDescription{
  195. "OmniboxStoreTitleInContentsAndUrlInDescription",
  196. base::FEATURE_DISABLED_BY_DEFAULT};
  197. // Feature used to fetch document suggestions.
  198. const base::Feature kDocumentProvider{"OmniboxDocumentProvider",
  199. enabled_by_default_desktop_only};
  200. // Feature to determine a value in the drive request indicating whether the
  201. // request should be served by the ASO backend.
  202. const base::Feature kDocumentProviderAso{"OmniboxDocumentProviderAso",
  203. base::FEATURE_DISABLED_BY_DEFAULT};
  204. // Allows Omnibox to dynamically adjust number of offered suggestions to fill in
  205. // the space between Omnibox and the soft keyboard. The number of suggestions
  206. // shown will be no less than minimum for the platform (eg. 5 for Android).
  207. const base::Feature kAdaptiveSuggestionsCount{"OmniboxAdaptiveSuggestionsCount",
  208. enabled_by_default_android_only};
  209. // If enabled, clipboard suggestion will not show the clipboard content until
  210. // the user clicks the reveal button.
  211. const base::Feature kClipboardSuggestionContentHidden = {
  212. "ClipboardSuggestionContentHidden", enabled_by_default_android_only};
  213. // Feature to enable memoizing and filtering non-doc hosts for
  214. // `DocumentProvider::GetURLForDeduping()`.
  215. const base::Feature kDocumentProviderDedupingOptimization{
  216. "OmniboxDocumentProviderDedupingOptimization",
  217. base::FEATURE_DISABLED_BY_DEFAULT};
  218. // If enabled, finance ticker answer from omnibox will reverse the color for
  219. // stock ticker. only colors being swapped are those that represent "growth" and
  220. // "loss" to represent colors red and green in a way that is appropriate for a
  221. // given country/culture
  222. const base::Feature kSuggestionAnswersColorReverse = {
  223. "SuggestionAnswersColorReverse", base::FEATURE_ENABLED_BY_DEFAULT};
  224. // If enabled, frequently visited sites are presented in form of a single row
  225. // with a carousel of tiles, instead of one URL per row.
  226. extern const base::Feature kMostVisitedTiles{"OmniboxMostVisitedTiles",
  227. enabled_by_default_android_only};
  228. // If enabled, computes spacing between MV tiles so that about 4.5 tiles are
  229. // shown on screen on narrow devices.
  230. extern const base::Feature kMostVisitedTilesDynamicSpacing{
  231. "OmniboxMostVisitedTilesDynamicSpacing", base::FEATURE_DISABLED_BY_DEFAULT};
  232. // If enabled, permits the title on the MostVisitedTiles to wrap around to
  233. // second line.
  234. extern const base::Feature kMostVisitedTilesTitleWrapAround{
  235. "OmniboxMostVisitedTilesTitleWrapAround",
  236. base::FEATURE_DISABLED_BY_DEFAULT};
  237. // If enabled, expands autocompletion to possibly (depending on params) include
  238. // suggestion titles and non-prefixes as opposed to be restricted to URL
  239. // prefixes. Will also adjust the location bar UI and omnibox text selection to
  240. // accommodate the autocompletions.
  241. const base::Feature kRichAutocompletion{"OmniboxRichAutocompletion",
  242. base::FEATURE_DISABLED_BY_DEFAULT};
  243. // Feature used to enable Pedals in the NTP Realbox.
  244. const base::Feature kNtpRealboxPedals{"NtpRealboxPedals",
  245. base::FEATURE_DISABLED_BY_DEFAULT};
  246. // Feature used to enable Suggestion Answers in the NTP Realbox.
  247. const base::Feature kNtpRealboxSuggestionAnswers{
  248. "NtpRealboxSuggestionAnswers", base::FEATURE_ENABLED_BY_DEFAULT};
  249. // Feature used to enable Tail Suggest Formatting in the NTP Realbox.
  250. const base::Feature kNtpRealboxTailSuggest{"NtpRealboxTailSuggest",
  251. base::FEATURE_ENABLED_BY_DEFAULT};
  252. // Feature used to enable URL suggestions for inputs that may contain typos.
  253. const base::Feature kOmniboxFuzzyUrlSuggestions{
  254. "OmniboxFuzzyUrlSuggestions", base::FEATURE_DISABLED_BY_DEFAULT};
  255. // Feature used to update the left and bottom padding of the omnibox suggestion
  256. // header.
  257. const base::Feature kOmniboxHeaderPaddingUpdate{
  258. "OmniboxHeaderPaddingUpdate", base::FEATURE_DISABLED_BY_DEFAULT};
  259. // Feature used to remove the capitalization of the suggestion header text.
  260. const base::Feature kOmniboxRemoveSuggestionHeaderCapitalization{
  261. "OmniboxRemoveSuggestionHeaderCapitalization",
  262. base::FEATURE_DISABLED_BY_DEFAULT};
  263. // Feature used to remove the chevron on the right side of suggestion list
  264. // header under omnibox.
  265. const base::Feature kOmniboxRemoveSuggestionHeaderChevron{
  266. "OmniboxRemoveSuggestionHeaderChevron", base::FEATURE_DISABLED_BY_DEFAULT};
  267. // Feature used to add fading effect to most visited tiles on tablet.
  268. const base::Feature kOmniboxMostVisitedTilesFadingOnTablet{
  269. "OmniboxMostVisitedTilesFadingOnTablet", base::FEATURE_DISABLED_BY_DEFAULT};
  270. // Feature used to add most visited tiles to the suggestions when the user is on
  271. // a search result page that does not do search term replacement.
  272. const base::Feature kOmniboxMostVisitedTilesOnSrp{
  273. "OmniboxMostVisitedTilesOnSrp", base::FEATURE_DISABLED_BY_DEFAULT};
  274. // Feature to enable memoizing URLs when replacing search terms in
  275. // `AutocompleteMatch::GURLToStrippedGURL()`.
  276. const base::Feature kStrippedGurlOptimization{
  277. "OmniboxStrippedGurlOptimization", base::FEATURE_DISABLED_BY_DEFAULT};
  278. // When enabled, use Assistant for omnibox voice query recognition instead of
  279. // Android's built-in voice recognition service. Only works on Android.
  280. const base::Feature kOmniboxAssistantVoiceSearch{
  281. "OmniboxAssistantVoiceSearch", base::FEATURE_DISABLED_BY_DEFAULT};
  282. const base::Feature kClosePopupWithEscape{"OmniboxClosePopupWithEscape",
  283. base::FEATURE_DISABLED_BY_DEFAULT};
  284. const base::Feature kBlurWithEscape{"OmniboxBlurWithEscape",
  285. base::FEATURE_ENABLED_BY_DEFAULT};
  286. // When enabled, adds a "starter pack" of @history, @bookmarks, and @settings
  287. // scopes to Site Search/Keyword Mode.
  288. const base::Feature kSiteSearchStarterPack{"OmniboxSiteSearchStarterPack",
  289. base::FEATURE_DISABLED_BY_DEFAULT};
  290. // Experiment to introduce new security indicators for HTTPS.
  291. const base::Feature kUpdatedConnectionSecurityIndicators{
  292. "OmniboxUpdatedConnectionSecurityIndicators",
  293. base::FEATURE_DISABLED_BY_DEFAULT};
  294. // Feature used to default typed navigations to use HTTPS instead of HTTP.
  295. // This only applies to navigations that don't have a scheme such as
  296. // "example.com". Presently, typing "example.com" in a clean browsing profile
  297. // loads http://example.com. When this feature is enabled, it should load
  298. // https://example.com instead, with fallback to http://example.com if
  299. // necessary.
  300. const base::Feature kDefaultTypedNavigationsToHttps{
  301. "OmniboxDefaultTypedNavigationsToHttps",
  302. enabled_by_default_desktop_android};
  303. // Parameter name used to look up the delay before falling back to the HTTP URL
  304. // while trying an HTTPS URL. The parameter is treated as a TimeDelta, so the
  305. // unit must be included in the value as well (e.g. 3s for 3 seconds).
  306. // - If the HTTPS load finishes successfully during this time, the timer is
  307. // cleared and no more work is done.
  308. // - Otherwise, a new navigation to the the fallback HTTP URL is started.
  309. const char kDefaultTypedNavigationsToHttpsTimeoutParam[] = "timeout";
  310. // If enabled, Omnibox reports the Assisted Query Stats in the aqs= param in the
  311. // Search Results Page URL.
  312. const base::Feature kReportAssistedQueryStats{"OmniboxReportAssistedQueryStats",
  313. base::FEATURE_ENABLED_BY_DEFAULT};
  314. // If enabled, Omnibox reports the Searchbox Stats in the gs_lcrp= param in the
  315. // Search Results Page URL.
  316. extern const base::Feature kReportSearchboxStats{
  317. "OmniboxReportSearchboxStats", base::FEATURE_DISABLED_BY_DEFAULT};
  318. // If enabled, retains all suggestions with headers to be presented entirely.
  319. // Disabling the feature trims the suggestions list to the predefined limit.
  320. extern const base::Feature kRetainSuggestionsWithHeaders{
  321. "OmniboxRetainSuggestionsWithHeaders", base::FEATURE_DISABLED_BY_DEFAULT};
  322. } // namespace omnibox