| 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 non-keyword autocomplete entries that start with | 6 // responsible for all non-keyword autocomplete entries that start with |
| 7 // "Search <engine> for ...", including searching for the current input string, | 7 // "Search <engine> for ...", including searching for the current input string, |
| 8 // search history, and search suggestions. An instance of it gets created and | 8 // search 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 // |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // net::URLFetcherDelegate | 82 // net::URLFetcherDelegate |
| 83 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 83 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 84 | 84 |
| 85 // ID used in creating URLFetcher for default provider's suggest results. | 85 // ID used in creating URLFetcher for default provider's suggest results. |
| 86 static const int kDefaultProviderURLFetcherID; | 86 static const int kDefaultProviderURLFetcherID; |
| 87 | 87 |
| 88 // ID used in creating URLFetcher for keyword provider's suggest results. | 88 // ID used in creating URLFetcher for keyword provider's suggest results. |
| 89 static const int kKeywordProviderURLFetcherID; | 89 static const int kKeywordProviderURLFetcherID; |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
| 92 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); | 93 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); |
| 93 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); | 94 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
| 94 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); | 95 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); |
| 95 | 96 |
| 96 virtual ~SearchProvider(); | 97 virtual ~SearchProvider(); |
| 97 | 98 |
| 98 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers | 99 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers |
| 99 // may be used: | 100 // may be used: |
| 100 // . The default provider. This corresponds to the user's default search | 101 // . The default provider. This corresponds to the user's default search |
| 101 // engine. This is always used, except for the rare case of no default | 102 // engine. This is always used, except for the rare case of no default |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // potentially private data, etc. | 220 // potentially private data, etc. |
| 220 bool IsQuerySuitableForSuggest() const; | 221 bool IsQuerySuitableForSuggest() const; |
| 221 | 222 |
| 222 // Stops the suggest query. | 223 // Stops the suggest query. |
| 223 // NOTE: This does not update |done_|. Callers must do so. | 224 // NOTE: This does not update |done_|. Callers must do so. |
| 224 void StopSuggest(); | 225 void StopSuggest(); |
| 225 | 226 |
| 226 // Clears the current results. | 227 // Clears the current results. |
| 227 void ClearResults(); | 228 void ClearResults(); |
| 228 | 229 |
| 230 // Remove results that cannot inline auto-complete the current input. |
| 231 void RemoveStaleResults(); |
| 232 void RemoveStaleSuggestResults(SuggestResults* list, bool is_keyword); |
| 233 void RemoveStaleNavigationResults(NavigationResults* list, bool is_keyword); |
| 234 |
| 235 // Apply calculated relevance scores to the current results. |
| 236 void ApplyCalculatedRelevance(); |
| 237 void ApplyCalculatedSuggestRelevance(SuggestResults* list, bool is_keyword); |
| 238 void ApplyCalculatedNavigationRelevance(NavigationResults* list, |
| 239 bool is_keyword); |
| 240 |
| 229 // Creates a URLFetcher requesting suggest results from the specified | 241 // Creates a URLFetcher requesting suggest results from the specified |
| 230 // |suggestions_url|. The caller owns the returned URLFetcher. | 242 // |suggestions_url|. The caller owns the returned URLFetcher. |
| 231 net::URLFetcher* CreateSuggestFetcher( | 243 net::URLFetcher* CreateSuggestFetcher( |
| 232 int id, | 244 int id, |
| 233 const TemplateURLRef& suggestions_url, | 245 const TemplateURLRef& suggestions_url, |
| 234 const string16& text); | 246 const string16& text); |
| 235 | 247 |
| 236 // Parses results from the suggest server and updates the appropriate suggest | 248 // Parses results from the suggest server and updates the appropriate suggest |
| 237 // and navigation result lists, depending on whether |is_keyword| is true. | 249 // and navigation result lists, depending on whether |is_keyword| is true. |
| 238 // Returns whether the appropriate result list members were updated. | 250 // Returns whether the appropriate result list members were updated. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 scoped_ptr<net::URLFetcher> default_fetcher_; | 348 scoped_ptr<net::URLFetcher> default_fetcher_; |
| 337 | 349 |
| 338 // Suggestions returned by the Suggest server for the input text. | 350 // Suggestions returned by the Suggest server for the input text. |
| 339 SuggestResults keyword_suggest_results_; | 351 SuggestResults keyword_suggest_results_; |
| 340 SuggestResults default_suggest_results_; | 352 SuggestResults default_suggest_results_; |
| 341 | 353 |
| 342 // Navigational suggestions returned by the server. | 354 // Navigational suggestions returned by the server. |
| 343 NavigationResults keyword_navigation_results_; | 355 NavigationResults keyword_navigation_results_; |
| 344 NavigationResults default_navigation_results_; | 356 NavigationResults default_navigation_results_; |
| 345 | 357 |
| 358 // A flag indicating use of server supplied relevance scores. |
| 359 bool has_suggested_relevance_; |
| 360 |
| 361 // The server supplied verbatim relevance score. Negative values indicate that |
| 362 // there is no suggested score; a value of 0 suppresses the verbatim result. |
| 363 int verbatim_relevance_; |
| 364 |
| 346 // Whether suggest_results_ is valid. | 365 // Whether suggest_results_ is valid. |
| 347 bool have_suggest_results_; | 366 bool have_suggest_results_; |
| 348 | 367 |
| 349 // Has FinalizeInstantQuery been invoked since the last |Start|? | 368 // Has FinalizeInstantQuery been invoked since the last |Start|? |
| 350 bool instant_finalized_; | 369 bool instant_finalized_; |
| 351 | 370 |
| 352 // The |suggest_text| parameter passed to FinalizeInstantQuery. | 371 // The |suggest_text| parameter passed to FinalizeInstantQuery. |
| 353 string16 default_provider_suggest_text_; | 372 string16 default_provider_suggest_text_; |
| 354 | 373 |
| 355 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 374 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 356 }; | 375 }; |
| 357 | 376 |
| 358 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 377 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| OLD | NEW |