#include <string>
#include "base/gtest_prod_util.h"
-#include "chrome/browser/autocomplete/autocomplete_provider.h"
-#include "chrome/browser/history/shortcuts_backend.h"
+#include "chrome/browser/autocomplete/shortcuts_backend.h"
+#include "components/omnibox/autocomplete_provider.h"
class Profile;
-
-namespace history {
class ShortcutsProviderTest;
-}
// Provider of recently autocompleted links. Provides autocomplete suggestions
// from previously selected suggestions. The more often a user selects a
// ranking for future uses of that search term.
class ShortcutsProvider
: public AutocompleteProvider,
- public history::ShortcutsBackend::ShortcutsBackendObserver {
+ public ShortcutsBackend::ShortcutsBackendObserver {
public:
- ShortcutsProvider(AutocompleteProviderListener* listener, Profile* profile);
+ explicit ShortcutsProvider(Profile* profile);
// Performs the autocompletion synchronously. Since no asynch completion is
// performed |minimal_changes| is ignored.
private:
friend class ClassifyTest;
- friend class history::ShortcutsProviderTest;
+ friend class ShortcutsProviderTest;
+ FRIEND_TEST_ALL_PREFIXES(ShortcutsProviderTest, CalculateScore);
- typedef std::multimap<char16, string16> WordMap;
+ typedef std::multimap<base::char16, base::string16> WordMap;
virtual ~ShortcutsProvider();
// Performs the autocomplete matching and scoring.
void GetMatches(const AutocompleteInput& input);
+ // Returns an AutocompleteMatch corresponding to |shortcut|. Assigns it
+ // |relevance| score in the process, and highlights the description and
+ // contents against |input|, which should be the lower-cased version of
+ // the user's input. |input| and |fixed_up_input_text| are used to decide
+ // what can be inlined.
AutocompleteMatch ShortcutToACMatch(
+ const history::ShortcutsDatabase::Shortcut& shortcut,
int relevance,
- const string16& terms,
- const history::ShortcutsBackend::Shortcut& shortcut);
+ const AutocompleteInput& input,
+ const base::string16& fixed_up_input_text);
// Returns a map mapping characters to groups of words from |text| that start
// with those characters, ordered lexicographically descending so that longer
// words appear before their prefixes (if any) within a particular
// equal_range().
- static WordMap CreateWordMapForString(const string16& text);
+ static WordMap CreateWordMapForString(const base::string16& text);
// Given |text| and a corresponding base set of classifications
// |original_class|, adds ACMatchClassification::MATCH markers for all
// |find_text| (and thus |find_words|) are expected to be lowercase. |text|
// will be lowercased in this function.
static ACMatchClassifications ClassifyAllMatchesInString(
- const string16& find_text,
+ const base::string16& find_text,
const WordMap& find_words,
- const string16& text,
+ const base::string16& text,
const ACMatchClassifications& original_class);
// Returns iterator to first item in |shortcuts_map_| matching |keyword|.
// Returns shortcuts_map_.end() if there are no matches.
- history::ShortcutsBackend::ShortcutMap::const_iterator FindFirstMatch(
- const string16& keyword,
- history::ShortcutsBackend* backend);
+ ShortcutsBackend::ShortcutMap::const_iterator FindFirstMatch(
+ const base::string16& keyword,
+ ShortcutsBackend* backend);
+
+ int CalculateScore(const base::string16& terms,
+ const history::ShortcutsDatabase::Shortcut& shortcut,
+ int max_relevance);
- int CalculateScore(
- const string16& terms,
- const history::ShortcutsBackend::Shortcut& shortcut,
- int max_relevance);
+ // The default max relevance unless overridden by a field trial.
+ static const int kShortcutsProviderDefaultMaxRelevance;
+ Profile* profile_;
std::string languages_;
bool initialized_;
};