| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 | |
| 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ | |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "chrome/browser/autocomplete/in_memory_url_index.h" | |
| 13 #include "components/history/core/browser/history_types.h" | |
| 14 #include "components/omnibox/autocomplete_input.h" | |
| 15 #include "components/omnibox/autocomplete_match.h" | |
| 16 #include "components/omnibox/history_provider.h" | |
| 17 | |
| 18 struct ScoredHistoryMatch; | |
| 19 | |
| 20 // This class is an autocomplete provider (a pseudo-internal component of | |
| 21 // the history system) which quickly (and synchronously) provides matching | |
| 22 // results from recently or frequently visited sites in the profile's | |
| 23 // history. | |
| 24 class HistoryQuickProvider : public HistoryProvider { | |
| 25 public: | |
| 26 HistoryQuickProvider(AutocompleteProviderClient* client, | |
| 27 InMemoryURLIndex* in_memory_url_index); | |
| 28 | |
| 29 // AutocompleteProvider. |minimal_changes| is ignored since there is no asynch | |
| 30 // completion performed. | |
| 31 void Start(const AutocompleteInput& input, | |
| 32 bool minimal_changes, | |
| 33 bool called_due_to_focus) override; | |
| 34 | |
| 35 // Disable this provider. For unit testing purposes only. This is required | |
| 36 // because this provider is closely associated with the HistoryURLProvider | |
| 37 // and in order to properly test the latter the HistoryQuickProvider must | |
| 38 // be disabled. | |
| 39 // TODO(mrossetti): Eliminate this once the HUP has been refactored. | |
| 40 static void set_disabled(bool disabled) { disabled_ = disabled; } | |
| 41 | |
| 42 private: | |
| 43 friend class HistoryQuickProviderTest; | |
| 44 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans); | |
| 45 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance); | |
| 46 | |
| 47 ~HistoryQuickProvider() override; | |
| 48 | |
| 49 // Performs the autocomplete matching and scoring. | |
| 50 void DoAutocomplete(); | |
| 51 | |
| 52 // Creates an AutocompleteMatch from |history_match|, assigning it | |
| 53 // the score |score|. | |
| 54 AutocompleteMatch QuickMatchToACMatch(const ScoredHistoryMatch& history_match, | |
| 55 int score); | |
| 56 | |
| 57 AutocompleteInput autocomplete_input_; | |
| 58 std::string languages_; | |
| 59 InMemoryURLIndex* in_memory_url_index_; // Not owned by this class. | |
| 60 | |
| 61 // This provider is disabled when true. | |
| 62 static bool disabled_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(HistoryQuickProvider); | |
| 65 }; | |
| 66 | |
| 67 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ | |
| OLD | NEW |