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 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
23 | 24 |
24 class AutocompleteProviderListener; | 25 class AutocompleteProviderListener; |
25 class AutocompleteResult; | 26 class AutocompleteResult; |
26 class Profile; | 27 class Profile; |
27 class SearchProviderTest; | 28 class SearchProviderTest; |
28 class TemplateURLService; | 29 class TemplateURLService; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // Cached across the life of a query so we behave consistently even if the | 130 // Cached across the life of a query so we behave consistently even if the |
130 // user changes their default while the query is running. | 131 // user changes their default while the query is running. |
131 base::string16 default_provider_; | 132 base::string16 default_provider_; |
132 base::string16 keyword_provider_; | 133 base::string16 keyword_provider_; |
133 | 134 |
134 DISALLOW_COPY_AND_ASSIGN(Providers); | 135 DISALLOW_COPY_AND_ASSIGN(Providers); |
135 }; | 136 }; |
136 | 137 |
137 class CompareScoredResults; | 138 class CompareScoredResults; |
138 | 139 |
139 struct AnswersQueryData { | |
140 base::string16 full_query_text; | |
141 base::string16 query_type; | |
142 }; | |
143 | |
144 typedef std::vector<history::KeywordSearchTermVisit> HistoryResults; | 140 typedef std::vector<history::KeywordSearchTermVisit> HistoryResults; |
145 | 141 |
146 // Removes non-inlineable results until either the top result can inline | 142 // Removes non-inlineable results until either the top result can inline |
147 // autocomplete the current input or verbatim outscores the top result. | 143 // autocomplete the current input or verbatim outscores the top result. |
148 static void RemoveStaleResults( | 144 static void RemoveStaleResults( |
149 const base::string16& input, | 145 const base::string16& input, |
150 int verbatim_relevance, | 146 int verbatim_relevance, |
151 SearchSuggestionParser::SuggestResults* suggest_results, | 147 SearchSuggestionParser::SuggestResults* suggest_results, |
152 SearchSuggestionParser::NavigationResults* navigation_results); | 148 SearchSuggestionParser::NavigationResults* navigation_results); |
153 | 149 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 SearchSuggestionParser::Results default_results_; | 351 SearchSuggestionParser::Results default_results_; |
356 SearchSuggestionParser::Results keyword_results_; | 352 SearchSuggestionParser::Results keyword_results_; |
357 | 353 |
358 GURL current_page_url_; | 354 GURL current_page_url_; |
359 | 355 |
360 // Session token management. | 356 // Session token management. |
361 std::string current_token_; | 357 std::string current_token_; |
362 base::TimeTicks token_expiration_time_; | 358 base::TimeTicks token_expiration_time_; |
363 | 359 |
364 // Answers prefetch management. | 360 // Answers prefetch management. |
365 AnswersQueryData prefetch_data_; // Data to use for query prefetching. | 361 AnswersCache answers_cache_; // Cache for last answers seen. |
366 AnswersQueryData last_answer_seen_; // Last answer seen. | 362 AnswersQueryData prefetch_data_; // Data to use for query prefetching. |
367 | 363 |
368 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 364 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
369 }; | 365 }; |
370 | 366 |
371 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 367 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
OLD | NEW |