Permission message rules: Each rule must have >= 1 required permissions
[chromium-blink-merge.git] / components / omnibox / browser / history_quick_provider.h
blobd35ecd3da4db35b9c8a21faf4f4b66859abbe1e4
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 COMPONENTS_OMNIBOX_BROWSER_HISTORY_QUICK_PROVIDER_H_
6 #define COMPONENTS_OMNIBOX_BROWSER_HISTORY_QUICK_PROVIDER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "components/history/core/browser/history_types.h"
13 #include "components/omnibox/browser/autocomplete_input.h"
14 #include "components/omnibox/browser/autocomplete_match.h"
15 #include "components/omnibox/browser/history_provider.h"
16 #include "components/omnibox/browser/in_memory_url_index.h"
18 struct ScoredHistoryMatch;
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 explicit HistoryQuickProvider(AutocompleteProviderClient* client);
28 // AutocompleteProvider. |minimal_changes| is ignored since there is no asynch
29 // completion performed.
30 void Start(const AutocompleteInput& input, bool minimal_changes) override;
32 // Disable this provider. For unit testing purposes only. This is required
33 // because this provider is closely associated with the HistoryURLProvider
34 // and in order to properly test the latter the HistoryQuickProvider must
35 // be disabled.
36 // TODO(mrossetti): Eliminate this once the HUP has been refactored.
37 static void set_disabled(bool disabled) { disabled_ = disabled; }
39 private:
40 friend class HistoryQuickProviderTest;
41 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans);
42 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance);
44 ~HistoryQuickProvider() override;
46 // Performs the autocomplete matching and scoring.
47 void DoAutocomplete();
49 // Creates an AutocompleteMatch from |history_match|, assigning it
50 // the score |score|.
51 AutocompleteMatch QuickMatchToACMatch(const ScoredHistoryMatch& history_match,
52 int score);
54 AutocompleteInput autocomplete_input_;
55 std::string languages_;
56 InMemoryURLIndex* in_memory_url_index_; // Not owned by this class.
58 // This provider is disabled when true.
59 static bool disabled_;
61 DISALLOW_COPY_AND_ASSIGN(HistoryQuickProvider);
64 #endif // COMPONENTS_OMNIBOX_BROWSER_HISTORY_QUICK_PROVIDER_H_