// Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_H_ #define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_H_ #include <stddef.h> #include <map> #include <string> #include <utility> #include <vector> #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "components/omnibox/browser/autocomplete_match.h" #include "components/omnibox/browser/in_memory_url_index_types.h" #include "components/omnibox/browser/suggestion_group_util.h" #include "third_party/metrics_proto/omnibox_event.pb.h" class AutocompleteInput; class AutocompleteProviderListener; ProvidersInfo; // The AutocompleteProviders each return different kinds of matches, // such as history or search matches. These matches are given // "relevance" scores. Higher scores are better matches than lower // scores. The relevance scores and classes providing the respective // matches are as listed below. // // IMPORTANT CAVEAT: The tables below are NOT COMPLETE. Developers // often forget to keep these tables in sync with the code when they // change scoring algorithms or add new providers. For example, // neither the HistoryQuickProvider (which is a provider that appears // often) nor the ShortcutsProvider are listed here. For the best // idea of how scoring works and what providers are affecting which // queries, play with chrome://omnibox/ for a while. While the tables // below may have some utility, nothing compares with first-hand // investigation and experience. // // ZERO SUGGEST (empty input type) on NTP: // --------------------------------------------------------------------|----- // Query Tiles (Android only) | 1599 // Clipboard (Mobile only) | 1501 // Remote Zero Suggest (relevance expected to be overridden by server) | 100 // Local History Zero Suggest (signed-out users) | 1450-- // Local History Zero Suggest (signed-in users) | 500-- // // ZERO SUGGEST (empty input type) on SERP: // --------------------------------------------------------------------|----- // Verbatim Match (Mobile only) | 1600 // Clipboard (Mobile only) | 1501 // // ZERO SUGGEST (empty input type) on OTHER (e.g., contextual web): // --------------------------------------------------------------------|----- // Verbatim Match (Mobile only) | 1600 // Clipboard (Mobile only) | 1501 // Most Visited Carousel (Android only) | 1500 // Most Visited Sites (Mobile only) | 600-- // Remote Zero Suggest (relevance expected to be overridden by server) | 100 // // UNKNOWN input type: // --------------------------------------------------------------------|----- // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 // HistoryURL (good exact or inline autocomplete matches, some inexact)| 1410++ // HistoryURL (intranet url never visited match, some inexact matches) | 1400++ // Search Primary Provider (past query in history within 2 days) | 1399** // Search Primary Provider (what you typed) | 1300 // HistoryURL (what you typed, some inexact matches) | 1200++ // Keyword (substituting, exact match) | 1100 // Search Primary Provider (past query in history older than 2 days) | 1050* // HistoryURL (some inexact matches) | 900++ // BookmarkProvider (prefix match in bookmark title or URL) | 900+- // Built-in | 860++ // Search Primary Provider (navigational suggestion) | 800++ // Search Primary Provider (suggestion) | 600++ // Keyword (inexact match) | 450 // Search Secondary Provider (what you typed) | 250 // Search Secondary Provider (past query in history) | 200* // Search Secondary Provider (navigational suggestion) | 150++ // Search Secondary Provider (suggestion) | 100++ // Non Personalized On Device Head Suggest Provider | * // (default value 99--, can be changed by Finch) // Document Suggestions (*experimental): value controlled by Finch | * // // URL input type: // --------------------------------------------------------------------|----- // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 // HistoryURL (good exact or inline autocomplete matches, some inexact)| 1410++ // HistoryURL (intranet url never visited match, some inexact matches) | 1400++ // HistoryURL (what you typed, some inexact matches) | 1200++ // Keyword (substituting, exact match) | 1100 // HistoryURL (some inexact matches) | 900++ // Built-in | 860++ // Search Primary Provider (what you typed) | 850 // Search Primary Provider (navigational suggestion) | 800++ // Search Primary Provider (past query in history) | 750* // Keyword (inexact match) | 700 // Search Primary Provider (suggestion) | 300++ // Search Secondary Provider (what you typed) | 250 // Search Secondary Provider (past query in history) | 200* // Search Secondary Provider (navigational suggestion) | 150++ // Search Secondary Provider (suggestion) | 100++ // Non Personalized On Device Head Suggest Provider | 99-- // // QUERY input type: // --------------------------------------------------------------------|----- // Search Primary or Secondary (past query in history within 2 days) | 1599** // Keyword (non-substituting or in keyword UI mode, exact match) | 1500 // Keyword (substituting, exact match) | 1450 // Search Primary Provider (past query in history within 2 days) | 1399** // Search Primary Provider (what you typed) | 1300 // Search Primary Provider (past query in history older than 2 days) | 1050* // HistoryURL (inexact match) | 900++ // BookmarkProvider (prefix match in bookmark title or URL) | 900+- // Search Primary Provider (navigational suggestion) | 800++ // Search Primary Provider (suggestion) | 600++ // Keyword (inexact match) | 450 // Search Secondary Provider (what you typed) | 250 // Search Secondary Provider (past query in history) | 200* // Search Secondary Provider (navigational suggestion) | 150++ // Search Secondary Provider (suggestion) | 100++ // Non Personalized On Device Head Suggest Provider | * // (default value 99--, can be changed by Finch) // // (A search keyword is a keyword with a replacement string; a bookmark keyword // is a keyword with no replacement string, that is, a shortcut for a URL.) // // There are two possible providers for search suggestions. If the user has // typed a keyword, then the primary provider is the keyword provider and the // secondary provider is the default provider. If the user has not typed a // keyword, then the primary provider corresponds to the default provider. // // Search providers may supply relevance values along with their results to be // used in place of client-side calculated values. // // The value column gives the ranking returned from the various providers. // ++: a series of matches with relevance from n up to (n + max_matches). // --: a series of matches with relevance from n down to (n - max_matches). // *: relevance score falls off over time (discounted 50 points @ 15 minutes, // 450 points @ two weeks) // **: relevance score falls off over two days (discounted 99 points after two // days). // +-: A base score that the provider will adjust upward or downward based on // provider-specific metrics. // // A single result provider for the autocomplete system. Given user input, the // provider decides what (if any) matches to return, their relevance, and their // classifications. class AutocompleteProvider : public base::RefCountedThreadSafe<AutocompleteProvider> { … }; #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_H_