[email protected] | 29a89dd | 2012-01-30 21:04:39 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 7c6821d | 2010-08-04 16:07:34 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
blundell | 2102f7c | 2015-07-09 10:00:53 | [diff] [blame] | 5 | #ifndef COMPONENTS_OMNIBOX_BROWSER_HISTORY_QUICK_PROVIDER_H_ |
6 | #define COMPONENTS_OMNIBOX_BROWSER_HISTORY_QUICK_PROVIDER_H_ | ||||
[email protected] | 7c6821d | 2010-08-04 16:07:34 | [diff] [blame] | 7 | |
[email protected] | 497606b | 2010-10-12 17:31:23 | [diff] [blame] | 8 | #include <string> |
9 | |||||
[email protected] | 9f8bc2f | 2012-07-03 16:26:53 | [diff] [blame] | 10 | #include "base/compiler_specific.h" |
thestig | a0e18cd | 2015-09-25 04:58:36 | [diff] [blame] | 11 | #include "base/gtest_prod_util.h" |
avi | f57136c1 | 2015-12-25 23:27:45 | [diff] [blame] | 12 | #include "base/macros.h" |
sdefresne | bc766ef | 2014-09-25 09:28:13 | [diff] [blame] | 13 | #include "components/history/core/browser/history_types.h" |
blundell | 2102f7c | 2015-07-09 10:00:53 | [diff] [blame] | 14 | #include "components/omnibox/browser/autocomplete_input.h" |
15 | #include "components/omnibox/browser/autocomplete_match.h" | ||||
16 | #include "components/omnibox/browser/history_provider.h" | ||||
17 | #include "components/omnibox/browser/in_memory_url_index.h" | ||||
[email protected] | 497606b | 2010-10-12 17:31:23 | [diff] [blame] | 18 | |
sdefresne | 5677607 | 2015-02-16 16:08:04 | [diff] [blame] | 19 | struct ScoredHistoryMatch; |
[email protected] | 4eeb651 | 2012-06-07 13:59:48 | [diff] [blame] | 20 | |
[email protected] | 7c6821d | 2010-08-04 16:07:34 | [diff] [blame] | 21 | // This class is an autocomplete provider (a pseudo-internal component of |
22 | // the history system) which quickly (and synchronously) provides matching | ||||
23 | // results from recently or frequently visited sites in the profile's | ||||
24 | // history. | ||||
[email protected] | 497606b | 2010-10-12 17:31:23 | [diff] [blame] | 25 | class HistoryQuickProvider : public HistoryProvider { |
[email protected] | 7c6821d | 2010-08-04 16:07:34 | [diff] [blame] | 26 | public: |
blundell | b11c2787e | 2015-06-22 10:05:10 | [diff] [blame] | 27 | explicit HistoryQuickProvider(AutocompleteProviderClient* client); |
[email protected] | 7c6821d | 2010-08-04 16:07:34 | [diff] [blame] | 28 | |
[email protected] | bc77dcbe | 2013-01-09 02:01:27 | [diff] [blame] | 29 | // AutocompleteProvider. |minimal_changes| is ignored since there is no asynch |
30 | // completion performed. | ||||
jif | cf322cd | 2015-06-17 11:01:18 | [diff] [blame] | 31 | void Start(const AutocompleteInput& input, bool minimal_changes) override; |
[email protected] | 0b9d27b | 2010-12-22 00:51:39 | [diff] [blame] | 32 | |
[email protected] | dcc592a9 | 2011-08-19 20:42:55 | [diff] [blame] | 33 | // Disable this provider. For unit testing purposes only. This is required |
34 | // because this provider is closely associated with the HistoryURLProvider | ||||
35 | // and in order to properly test the latter the HistoryQuickProvider must | ||||
36 | // be disabled. | ||||
37 | // TODO(mrossetti): Eliminate this once the HUP has been refactored. | ||||
38 | static void set_disabled(bool disabled) { disabled_ = disabled; } | ||||
39 | |||||
[email protected] | 7c6821d | 2010-08-04 16:07:34 | [diff] [blame] | 40 | private: |
[email protected] | 497606b | 2010-10-12 17:31:23 | [diff] [blame] | 41 | friend class HistoryQuickProviderTest; |
[email protected] | 91c0cf56 | 2011-03-10 17:23:14 | [diff] [blame] | 42 | FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans); |
[email protected] | 2b5a2651 | 2011-05-06 01:41:00 | [diff] [blame] | 43 | FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance); |
[email protected] | 497606b | 2010-10-12 17:31:23 | [diff] [blame] | 44 | |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 45 | ~HistoryQuickProvider() override; |
[email protected] | 649d1c0 | 2012-04-27 02:56:21 | [diff] [blame] | 46 | |
[email protected] | 18a4df8c | 2011-10-19 22:49:48 | [diff] [blame] | 47 | // Performs the autocomplete matching and scoring. |
48 | void DoAutocomplete(); | ||||
49 | |||||
[email protected] | 31973e8 | 2012-02-19 00:14:39 | [diff] [blame] | 50 | // Creates an AutocompleteMatch from |history_match|, assigning it |
51 | // the score |score|. | ||||
sdefresne | b21674ab | 2015-03-09 16:59:07 | [diff] [blame] | 52 | AutocompleteMatch QuickMatchToACMatch(const ScoredHistoryMatch& history_match, |
53 | int score); | ||||
[email protected] | 497606b | 2010-10-12 17:31:23 | [diff] [blame] | 54 | |
[email protected] | 497606b | 2010-10-12 17:31:23 | [diff] [blame] | 55 | AutocompleteInput autocomplete_input_; |
sdefresne | a5ad6c7 | 2015-03-12 10:06:57 | [diff] [blame] | 56 | InMemoryURLIndex* in_memory_url_index_; // Not owned by this class. |
[email protected] | dcc592a9 | 2011-08-19 20:42:55 | [diff] [blame] | 57 | |
58 | // This provider is disabled when true. | ||||
59 | static bool disabled_; | ||||
[email protected] | 9f8bc2f | 2012-07-03 16:26:53 | [diff] [blame] | 60 | |
61 | DISALLOW_COPY_AND_ASSIGN(HistoryQuickProvider); | ||||
[email protected] | 7c6821d | 2010-08-04 16:07:34 | [diff] [blame] | 62 | }; |
63 | |||||
blundell | 2102f7c | 2015-07-09 10:00:53 | [diff] [blame] | 64 | #endif // COMPONENTS_OMNIBOX_BROWSER_HISTORY_QUICK_PROVIDER_H_ |