blob: 9d34cbfa17c5503cc5676b815757481cfab5c644 [file] [log] [blame]
[email protected]29a89dd2012-01-30 21:04:391// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]7c6821d2010-08-04 16:07:342// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
blundell2102f7c2015-07-09 10:00:535#ifndef COMPONENTS_OMNIBOX_BROWSER_HISTORY_QUICK_PROVIDER_H_
6#define COMPONENTS_OMNIBOX_BROWSER_HISTORY_QUICK_PROVIDER_H_
[email protected]7c6821d2010-08-04 16:07:347
[email protected]497606b2010-10-12 17:31:238#include <string>
9
[email protected]9f8bc2f2012-07-03 16:26:5310#include "base/compiler_specific.h"
thestiga0e18cd2015-09-25 04:58:3611#include "base/gtest_prod_util.h"
avif57136c12015-12-25 23:27:4512#include "base/macros.h"
sdefresnebc766ef2014-09-25 09:28:1313#include "components/history/core/browser/history_types.h"
blundell2102f7c2015-07-09 10:00:5314#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]497606b2010-10-12 17:31:2318
sdefresne56776072015-02-16 16:08:0419struct ScoredHistoryMatch;
[email protected]4eeb6512012-06-07 13:59:4820
[email protected]7c6821d2010-08-04 16:07:3421// 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]497606b2010-10-12 17:31:2325class HistoryQuickProvider : public HistoryProvider {
[email protected]7c6821d2010-08-04 16:07:3426 public:
blundellb11c2787e2015-06-22 10:05:1027 explicit HistoryQuickProvider(AutocompleteProviderClient* client);
[email protected]7c6821d2010-08-04 16:07:3428
[email protected]bc77dcbe2013-01-09 02:01:2729 // AutocompleteProvider. |minimal_changes| is ignored since there is no asynch
30 // completion performed.
jifcf322cd2015-06-17 11:01:1831 void Start(const AutocompleteInput& input, bool minimal_changes) override;
[email protected]0b9d27b2010-12-22 00:51:3932
[email protected]dcc592a92011-08-19 20:42:5533 // 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]7c6821d2010-08-04 16:07:3440 private:
[email protected]497606b2010-10-12 17:31:2341 friend class HistoryQuickProviderTest;
[email protected]91c0cf562011-03-10 17:23:1442 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans);
[email protected]2b5a26512011-05-06 01:41:0043 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance);
[email protected]497606b2010-10-12 17:31:2344
Daniel Chenga542fca2014-10-21 09:51:2945 ~HistoryQuickProvider() override;
[email protected]649d1c02012-04-27 02:56:2146
[email protected]18a4df8c2011-10-19 22:49:4847 // Performs the autocomplete matching and scoring.
48 void DoAutocomplete();
49
[email protected]31973e82012-02-19 00:14:3950 // Creates an AutocompleteMatch from |history_match|, assigning it
51 // the score |score|.
sdefresneb21674ab2015-03-09 16:59:0752 AutocompleteMatch QuickMatchToACMatch(const ScoredHistoryMatch& history_match,
53 int score);
[email protected]497606b2010-10-12 17:31:2354
[email protected]497606b2010-10-12 17:31:2355 AutocompleteInput autocomplete_input_;
sdefresnea5ad6c72015-03-12 10:06:5756 InMemoryURLIndex* in_memory_url_index_; // Not owned by this class.
[email protected]dcc592a92011-08-19 20:42:5557
58 // This provider is disabled when true.
59 static bool disabled_;
[email protected]9f8bc2f2012-07-03 16:26:5360
61 DISALLOW_COPY_AND_ASSIGN(HistoryQuickProvider);
[email protected]7c6821d2010-08-04 16:07:3462};
63
blundell2102f7c2015-07-09 10:00:5364#endif // COMPONENTS_OMNIBOX_BROWSER_HISTORY_QUICK_PROVIDER_H_