| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, | 81 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, |
| 79 DontInlineAutocompleteAsynchronously); | 82 DontInlineAutocompleteAsynchronously); |
| 80 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); | 83 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); |
| 81 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); | 84 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); |
| 82 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); | 85 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
| 83 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); | 86 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
| 84 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, TestDeleteMatch); | 87 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, TestDeleteMatch); |
| 85 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestQueryUsesToken); | 88 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestQueryUsesToken); |
| 86 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SessionToken); | 89 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SessionToken); |
| 87 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, AnswersCache); | 90 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, AnswersCache); |
| 91 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveExtraAnswers); |
| 88 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); | 92 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); |
| 89 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); | 93 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); |
| 90 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery); | 94 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery); |
| 91 | 95 |
| 92 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers | 96 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers |
| 93 // may be used: | 97 // may be used: |
| 94 // . The default provider. This corresponds to the user's default search | 98 // . The default provider. This corresponds to the user's default search |
| 95 // engine. This is always used, except for the rare case of no default | 99 // engine. This is always used, except for the rare case of no default |
| 96 // engine. | 100 // engine. |
| 97 // . The keyword provider. This is used if the user has typed in a keyword. | 101 // . The keyword provider. This is used if the user has typed in a keyword. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 228 |
| 225 // Starts a new URLFetcher requesting suggest results from |template_url|; | 229 // Starts a new URLFetcher requesting suggest results from |template_url|; |
| 226 // callers own the returned URLFetcher, which is NULL for invalid providers. | 230 // callers own the returned URLFetcher, which is NULL for invalid providers. |
| 227 net::URLFetcher* CreateSuggestFetcher(int id, | 231 net::URLFetcher* CreateSuggestFetcher(int id, |
| 228 const TemplateURL* template_url, | 232 const TemplateURL* template_url, |
| 229 const AutocompleteInput& input); | 233 const AutocompleteInput& input); |
| 230 | 234 |
| 231 // Converts the parsed results to a set of AutocompleteMatches, |matches_|. | 235 // Converts the parsed results to a set of AutocompleteMatches, |matches_|. |
| 232 void ConvertResultsToAutocompleteMatches(); | 236 void ConvertResultsToAutocompleteMatches(); |
| 233 | 237 |
| 238 // Remove answer contents from each match in |matches| other than the first |
| 239 // that appears. |
| 240 static void RemoveExtraAnswers(ACMatches* matches); |
| 241 |
| 234 // Returns an iterator to the first match in |matches_| which might | 242 // Returns an iterator to the first match in |matches_| which might |
| 235 // be chosen as default. | 243 // be chosen as default. |
| 236 ACMatches::const_iterator FindTopMatch() const; | 244 ACMatches::const_iterator FindTopMatch() const; |
| 237 | 245 |
| 238 // Checks if suggested relevances violate an expected constraint. | 246 // Checks if suggested relevances violate an expected constraint. |
| 239 // See UpdateMatches() for the use and explanation of this constraint | 247 // See UpdateMatches() for the use and explanation of this constraint |
| 240 // and other constraints enforced without the use of helper functions. | 248 // and other constraints enforced without the use of helper functions. |
| 241 bool IsTopMatchSearchWithURLInput() const; | 249 bool IsTopMatchSearchWithURLInput() const; |
| 242 | 250 |
| 243 // Converts an appropriate number of navigation results in | 251 // 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_; | 375 base::TimeTicks token_expiration_time_; |
| 368 | 376 |
| 369 // Answers prefetch management. | 377 // Answers prefetch management. |
| 370 AnswersCache answers_cache_; // Cache for last answers seen. | 378 AnswersCache answers_cache_; // Cache for last answers seen. |
| 371 AnswersQueryData prefetch_data_; // Data to use for query prefetching. | 379 AnswersQueryData prefetch_data_; // Data to use for query prefetching. |
| 372 | 380 |
| 373 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 381 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 374 }; | 382 }; |
| 375 | 383 |
| 376 #endif // COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ | 384 #endif // COMPONENTS_OMNIBOX_SEARCH_PROVIDER_H_ |
| OLD | NEW |