OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // This file contains the Search autocomplete provider. This provider is | 5 // This file contains the Search autocomplete provider. This provider is |
6 // responsible for all autocomplete entries that start with "Search <engine> | 6 // responsible for all autocomplete entries that start with "Search <engine> |
7 // for ...", including searching for the current input string, search | 7 // for ...", including searching for the current input string, search |
8 // history, and search suggestions. An instance of it gets created and | 8 // history, and search suggestions. An instance of it gets created and |
9 // managed by the autocomplete controller. | 9 // managed by the autocomplete controller. |
10 | 10 |
11 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 11 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
12 #define CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 12 #define CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 19 #include "chrome/browser/autocomplete/answers_cache.h" |
19 #include "chrome/browser/autocomplete/base_search_provider.h" | 20 #include "chrome/browser/autocomplete/base_search_provider.h" |
20 #include "components/metrics/proto/omnibox_input_type.pb.h" | 21 #include "components/metrics/proto/omnibox_input_type.pb.h" |
21 #include "components/search_engines/template_url.h" | 22 #include "components/search_engines/template_url.h" |
22 | 23 |
23 class AutocompleteResult; | 24 class AutocompleteResult; |
24 class Profile; | 25 class Profile; |
25 class SearchProviderTest; | 26 class SearchProviderTest; |
26 class TemplateURLService; | 27 class TemplateURLService; |
27 | 28 |
28 namespace history { | 29 namespace history { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // Cached across the life of a query so we behave consistently even if the | 127 // Cached across the life of a query so we behave consistently even if the |
127 // user changes their default while the query is running. | 128 // user changes their default while the query is running. |
128 base::string16 default_provider_; | 129 base::string16 default_provider_; |
129 base::string16 keyword_provider_; | 130 base::string16 keyword_provider_; |
130 | 131 |
131 DISALLOW_COPY_AND_ASSIGN(Providers); | 132 DISALLOW_COPY_AND_ASSIGN(Providers); |
132 }; | 133 }; |
133 | 134 |
134 class CompareScoredResults; | 135 class CompareScoredResults; |
135 | 136 |
136 struct AnswersQueryData { | |
137 base::string16 full_query_text; | |
138 base::string16 query_type; | |
139 }; | |
140 | |
141 typedef std::vector<history::KeywordSearchTermVisit> HistoryResults; | 137 typedef std::vector<history::KeywordSearchTermVisit> HistoryResults; |
142 | 138 |
143 // Removes non-inlineable results until either the top result can inline | 139 // Removes non-inlineable results until either the top result can inline |
144 // autocomplete the current input or verbatim outscores the top result. | 140 // autocomplete the current input or verbatim outscores the top result. |
145 static void RemoveStaleResults( | 141 static void RemoveStaleResults( |
146 const base::string16& input, | 142 const base::string16& input, |
147 int verbatim_relevance, | 143 int verbatim_relevance, |
148 SearchSuggestionParser::SuggestResults* suggest_results, | 144 SearchSuggestionParser::SuggestResults* suggest_results, |
149 SearchSuggestionParser::NavigationResults* navigation_results); | 145 SearchSuggestionParser::NavigationResults* navigation_results); |
150 | 146 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 SearchSuggestionParser::Results default_results_; | 331 SearchSuggestionParser::Results default_results_; |
336 SearchSuggestionParser::Results keyword_results_; | 332 SearchSuggestionParser::Results keyword_results_; |
337 | 333 |
338 GURL current_page_url_; | 334 GURL current_page_url_; |
339 | 335 |
340 // Session token management. | 336 // Session token management. |
341 std::string current_token_; | 337 std::string current_token_; |
342 base::TimeTicks token_expiration_time_; | 338 base::TimeTicks token_expiration_time_; |
343 | 339 |
344 // Answers prefetch management. | 340 // Answers prefetch management. |
345 AnswersQueryData prefetch_data_; // Data to use for query prefetching. | 341 AnswersCache answers_cache_; // Cache for last answers seen. |
346 AnswersQueryData last_answer_seen_; // Last answer seen. | 342 AnswersQueryData prefetch_data_; // Data to use for query prefetching. |
347 | 343 |
348 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 344 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
349 }; | 345 }; |
350 | 346 |
351 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 347 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
OLD | NEW |