OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CONTENTS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/autocomplete/autocomplete.h" | 9 #include "chrome/browser/autocomplete/history_provider.h" |
10 #include "chrome/browser/history/history.h" | 10 #include "chrome/browser/history/history.h" |
11 | 11 |
12 namespace bookmark_utils { | 12 namespace bookmark_utils { |
13 struct TitleMatch; | 13 struct TitleMatch; |
14 } | 14 } |
15 | 15 |
16 // HistoryContentsProvider is an AutocompleteProvider that provides results from | 16 // HistoryContentsProvider is an AutocompleteProvider that provides results from |
17 // the contents (body and/or title) of previously visited pages. | 17 // the contents (body and/or title) of previously visited pages. |
18 // HistoryContentsProvider gets results from two sources: | 18 // HistoryContentsProvider gets results from two sources: |
19 // . HistoryService: this provides results for matches in the body/title of | 19 // . HistoryService: this provides results for matches in the body/title of |
20 // previously viewed pages. This is asynchronous. | 20 // previously viewed pages. This is asynchronous. |
21 // . BookmarkModel: provides results for matches in the titles of bookmarks. | 21 // . BookmarkModel: provides results for matches in the titles of bookmarks. |
22 // This is synchronous. | 22 // This is synchronous. |
23 class HistoryContentsProvider : public AutocompleteProvider { | 23 class HistoryContentsProvider : public HistoryProvider { |
24 public: | 24 public: |
25 HistoryContentsProvider(ACProviderListener* listener, Profile* profile); | 25 HistoryContentsProvider(ACProviderListener* listener, Profile* profile); |
26 | 26 |
27 // As necessary asks the history service for the relevant results. When | 27 // As necessary asks the history service for the relevant results. When |
28 // done SetResults is invoked. | 28 // done SetResults is invoked. |
29 virtual void Start(const AutocompleteInput& input, | 29 virtual void Start(const AutocompleteInput& input, |
30 bool minimal_changes); | 30 bool minimal_changes) OVERRIDE; |
31 | 31 virtual void Stop() OVERRIDE; |
32 virtual void Stop(); | |
33 | 32 |
34 // Returns the total number of matches available in the database, up to | 33 // Returns the total number of matches available in the database, up to |
35 // kMaxMatchCount, whichever is smaller. | 34 // kMaxMatchCount, whichever is smaller. |
36 // Return value is incomplete if done() returns false. | 35 // Return value is incomplete if done() returns false. |
37 size_t db_match_count() const { return results_.size(); } | 36 size_t db_match_count() const { return results_.size(); } |
38 | 37 |
39 // The maximum match count we'll report. If the db_match_count is greater | 38 // The maximum match count we'll report. If the db_match_count is greater |
40 // than this, it will be clamped to this result. | 39 // than this, it will be clamped to this result. |
41 static const size_t kMaxMatchCount = 50; | 40 static const size_t kMaxMatchCount = 50; |
42 | 41 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // Whether results_ is valid (so we can tell invalid apart from empty). | 92 // Whether results_ is valid (so we can tell invalid apart from empty). |
94 bool have_results_; | 93 bool have_results_; |
95 | 94 |
96 // Current query string. | 95 // Current query string. |
97 std::wstring query_; | 96 std::wstring query_; |
98 | 97 |
99 DISALLOW_COPY_AND_ASSIGN(HistoryContentsProvider); | 98 DISALLOW_COPY_AND_ASSIGN(HistoryContentsProvider); |
100 }; | 99 }; |
101 | 100 |
102 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ | 101 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ |
OLD | NEW |