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 COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ | 11 #ifndef COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ |
12 #define COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ | 12 #define COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ |
13 | 13 |
| 14 #include <string> |
| 15 #include <vector> |
| 16 |
14 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
15 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
16 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
17 #include "base/time/time.h" | 20 #include "base/time/time.h" |
18 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
19 #include "components/metrics/proto/omnibox_input_type.pb.h" | 22 #include "components/metrics/proto/omnibox_input_type.pb.h" |
20 #include "components/omnibox/answers_cache.h" | 23 #include "components/omnibox/answers_cache.h" |
21 #include "components/omnibox/base_search_provider.h" | 24 #include "components/omnibox/base_search_provider.h" |
22 #include "components/search_engines/template_url.h" | 25 #include "components/search_engines/template_url.h" |
23 #include "net/url_request/url_fetcher_delegate.h" | 26 #include "net/url_request/url_fetcher_delegate.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 227 |
225 // Starts a new URLFetcher requesting suggest results from |template_url|; | 228 // Starts a new URLFetcher requesting suggest results from |template_url|; |
226 // callers own the returned URLFetcher, which is NULL for invalid providers. | 229 // callers own the returned URLFetcher, which is NULL for invalid providers. |
227 net::URLFetcher* CreateSuggestFetcher(int id, | 230 net::URLFetcher* CreateSuggestFetcher(int id, |
228 const TemplateURL* template_url, | 231 const TemplateURL* template_url, |
229 const AutocompleteInput& input); | 232 const AutocompleteInput& input); |
230 | 233 |
231 // Converts the parsed results to a set of AutocompleteMatches, |matches_|. | 234 // Converts the parsed results to a set of AutocompleteMatches, |matches_|. |
232 void ConvertResultsToAutocompleteMatches(); | 235 void ConvertResultsToAutocompleteMatches(); |
233 | 236 |
| 237 // Remove answer contents from each match in |matches| other than the first |
| 238 // that appears. |
| 239 static void RemoveExtraAnswers(ACMatches* matches); |
| 240 |
234 // Returns an iterator to the first match in |matches_| which might | 241 // Returns an iterator to the first match in |matches_| which might |
235 // be chosen as default. | 242 // be chosen as default. |
236 ACMatches::const_iterator FindTopMatch() const; | 243 ACMatches::const_iterator FindTopMatch() const; |
237 | 244 |
238 // Checks if suggested relevances violate an expected constraint. | 245 // Checks if suggested relevances violate an expected constraint. |
239 // See UpdateMatches() for the use and explanation of this constraint | 246 // See UpdateMatches() for the use and explanation of this constraint |
240 // and other constraints enforced without the use of helper functions. | 247 // and other constraints enforced without the use of helper functions. |
241 bool IsTopMatchSearchWithURLInput() const; | 248 bool IsTopMatchSearchWithURLInput() const; |
242 | 249 |
243 // Converts an appropriate number of navigation results in | 250 // Converts an appropriate number of navigation results in |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 base::TimeTicks token_expiration_time_; | 374 base::TimeTicks token_expiration_time_; |
368 | 375 |
369 // Answers prefetch management. | 376 // Answers prefetch management. |
370 AnswersCache answers_cache_; // Cache for last answers seen. | 377 AnswersCache answers_cache_; // Cache for last answers seen. |
371 AnswersQueryData prefetch_data_; // Data to use for query prefetching. | 378 AnswersQueryData prefetch_data_; // Data to use for query prefetching. |
372 | 379 |
373 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 380 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
374 }; | 381 }; |
375 | 382 |
376 #endif // COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ | 383 #endif // COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ |
OLD | NEW |