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.
5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/autocomplete/history_provider.h"
13 #include "chrome/browser/autocomplete/in_memory_url_index.h"
14 #include "components/history/core/browser/history_types.h"
15 #include "components/omnibox/autocomplete_input.h"
16 #include "components/omnibox/autocomplete_match.h"
19 struct ScoredHistoryMatch
;
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
25 class HistoryQuickProvider
: public HistoryProvider
{
27 HistoryQuickProvider(Profile
* profile
, InMemoryURLIndex
* in_memory_url_index
);
29 // AutocompleteProvider. |minimal_changes| is ignored since there is no asynch
30 // completion performed.
31 void Start(const AutocompleteInput
& input
,
33 bool called_due_to_focus
) override
;
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
39 // TODO(mrossetti): Eliminate this once the HUP has been refactored.
40 static void set_disabled(bool disabled
) { disabled_
= disabled
; }
43 friend class HistoryQuickProviderTest
;
44 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest
, Spans
);
45 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest
, Relevance
);
47 ~HistoryQuickProvider() override
;
49 // Performs the autocomplete matching and scoring.
50 void DoAutocomplete();
52 // Creates an AutocompleteMatch from |history_match|, assigning it
54 AutocompleteMatch
QuickMatchToACMatch(const ScoredHistoryMatch
& history_match
,
57 AutocompleteInput autocomplete_input_
;
58 std::string languages_
;
59 InMemoryURLIndex
* in_memory_url_index_
; // Not owned by this class.
61 // This provider is disabled when true.
62 static bool disabled_
;
64 DISALLOW_COPY_AND_ASSIGN(HistoryQuickProvider
);
67 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_