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