Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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__ |
|
jcampan
2008/09/10 23:01:24
Since you were changing the double __ to a single
| |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H__ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H__ |
| 7 | 7 |
| 8 #include "chrome/browser/autocomplete/autocomplete.h" | 8 #include "chrome/browser/autocomplete/autocomplete.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_bar_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #include "chrome/browser/history/history.h" | 10 #include "chrome/browser/history/history.h" |
| 11 | 11 |
| 12 // HistoryContentsProvider is an AutocompleteProvider that provides results from | 12 // HistoryContentsProvider is an AutocompleteProvider that provides results from |
| 13 // the contents (body and/or title) of previously visited pages. | 13 // the contents (body and/or title) of previously visited pages. |
| 14 // HistoryContentsProvider gets results from two sources: | 14 // HistoryContentsProvider gets results from two sources: |
| 15 // . HistoryService: this provides results for matches in the body/title of | 15 // . HistoryService: this provides results for matches in the body/title of |
| 16 // previously viewed pages. This is asynchronous. | 16 // previously viewed pages. This is asynchronous. |
| 17 // . BookmarkBarModel: provides results for matches in the titles of bookmarks. | 17 // . BookmarkModel: provides results for matches in the titles of bookmarks. |
| 18 // This is synchronous. | 18 // This is synchronous. |
| 19 class HistoryContentsProvider : public AutocompleteProvider { | 19 class HistoryContentsProvider : public AutocompleteProvider { |
| 20 public: | 20 public: |
| 21 HistoryContentsProvider(ACProviderListener* listener, Profile* profile) | 21 HistoryContentsProvider(ACProviderListener* listener, Profile* profile) |
| 22 : AutocompleteProvider(listener, profile, "HistoryContents"), | 22 : AutocompleteProvider(listener, profile, "HistoryContents"), |
| 23 have_results_(false) { | 23 have_results_(false) { |
| 24 DCHECK(profile); | 24 DCHECK(profile); |
| 25 } | 25 } |
| 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 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 AutocompleteMatch* match) const; | 59 AutocompleteMatch* match) const; |
| 60 | 60 |
| 61 // Calculates and returns the relevance of a particular result. See the | 61 // Calculates and returns the relevance of a particular result. See the |
| 62 // chart in autocomplete.h for the list of values this returns. | 62 // chart in autocomplete.h for the list of values this returns. |
| 63 int CalculateRelevance(const history::URLResult& result); | 63 int CalculateRelevance(const history::URLResult& result); |
| 64 | 64 |
| 65 // Queries the bookmarks for any bookmarks whose title matches input. All | 65 // Queries the bookmarks for any bookmarks whose title matches input. All |
| 66 // matches are added directly to results_. | 66 // matches are added directly to results_. |
| 67 void QueryBookmarks(const AutocompleteInput& input); | 67 void QueryBookmarks(const AutocompleteInput& input); |
| 68 | 68 |
| 69 // Converts a BookmarkBarModel::TitleMatch to a QueryResult and adds it | 69 // Converts a BookmarkModel::TitleMatch to a QueryResult and adds it to |
| 70 // to results_. | 70 // results_. |
| 71 void AddBookmarkTitleMatchToResults( | 71 void AddBookmarkTitleMatchToResults(const BookmarkModel::TitleMatch& match); |
| 72 const BookmarkBarModel::TitleMatch& match); | |
| 73 | 72 |
| 74 CancelableRequestConsumerT<int, 0> request_consumer_; | 73 CancelableRequestConsumerT<int, 0> request_consumer_; |
| 75 | 74 |
| 76 // The number of times we're returned each different type of result. These are | 75 // The number of times we're returned each different type of result. These are |
| 77 // used by CalculateRelevance. Initialized in Start. | 76 // used by CalculateRelevance. Initialized in Start. |
| 78 int star_title_count_; | 77 int star_title_count_; |
| 79 int star_contents_count_; | 78 int star_contents_count_; |
| 80 int title_count_; | 79 int title_count_; |
| 81 int contents_count_; | 80 int contents_count_; |
| 82 | 81 |
| 83 // Current autocomplete input type. | 82 // Current autocomplete input type. |
| 84 AutocompleteInput::Type input_type_; | 83 AutocompleteInput::Type input_type_; |
| 85 | 84 |
| 86 // Results from most recent query. These are cached so we don't have to | 85 // Results from most recent query. These are cached so we don't have to |
| 87 // re-issue queries for "minor changes" (which don't affect this provider). | 86 // re-issue queries for "minor changes" (which don't affect this provider). |
| 88 history::QueryResults results_; | 87 history::QueryResults results_; |
| 89 | 88 |
| 90 // Whether results_ is valid (so we can tell invalid apart from empty). | 89 // Whether results_ is valid (so we can tell invalid apart from empty). |
| 91 bool have_results_; | 90 bool have_results_; |
| 92 | 91 |
| 93 // Current query string. | 92 // Current query string. |
| 94 std::wstring query_; | 93 std::wstring query_; |
| 95 | 94 |
| 96 DISALLOW_EVIL_CONSTRUCTORS(HistoryContentsProvider); | 95 DISALLOW_EVIL_CONSTRUCTORS(HistoryContentsProvider); |
| 97 }; | 96 }; |
| 98 | 97 |
| 99 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H__ | 98 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H__ |
| OLD | NEW |