Chromium Code Reviews| 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 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 void set_current_page_url(const GURL& current_page_url) { | 62 void set_current_page_url(const GURL& current_page_url) { |
| 63 current_page_url_ = current_page_url; | 63 current_page_url_ = current_page_url; |
| 64 } | 64 } |
| 65 | 65 |
| 66 protected: | 66 protected: |
| 67 virtual ~SearchProvider(); | 67 virtual ~SearchProvider(); |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 friend class SearchProviderTest; | 70 friend class SearchProviderTest; |
| 71 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, CanSendURL); | 71 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, CanSendURL); |
| 72 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, | |
| 73 DontInlineAutocompleteAsynchronously); | |
| 72 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); | 74 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); |
| 73 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); | 75 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); |
| 74 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); | 76 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
| 75 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); | 77 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); |
| 76 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); | 78 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
| 77 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, TestDeleteMatch); | 79 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, TestDeleteMatch); |
| 78 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestQueryUsesToken); | 80 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestQueryUsesToken); |
| 79 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SessionToken); | 81 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SessionToken); |
| 80 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, AnswersCache); | 82 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, AnswersCache); |
| 81 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); | 83 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 virtual void Start(const AutocompleteInput& input, | 163 virtual void Start(const AutocompleteInput& input, |
| 162 bool minimal_changes) OVERRIDE; | 164 bool minimal_changes) OVERRIDE; |
| 163 | 165 |
| 164 // BaseSearchProvider: | 166 // BaseSearchProvider: |
| 165 virtual void SortResults(bool is_keyword, | 167 virtual void SortResults(bool is_keyword, |
| 166 SearchSuggestionParser::Results* results) OVERRIDE; | 168 SearchSuggestionParser::Results* results) OVERRIDE; |
| 167 virtual const TemplateURL* GetTemplateURL(bool is_keyword) const OVERRIDE; | 169 virtual const TemplateURL* GetTemplateURL(bool is_keyword) const OVERRIDE; |
| 168 virtual const AutocompleteInput GetInput(bool is_keyword) const OVERRIDE; | 170 virtual const AutocompleteInput GetInput(bool is_keyword) const OVERRIDE; |
| 169 virtual SearchSuggestionParser::Results* GetResultsToFill( | 171 virtual SearchSuggestionParser::Results* GetResultsToFill( |
| 170 bool is_keyword) OVERRIDE; | 172 bool is_keyword) OVERRIDE; |
| 173 virtual void HandleReceivedResults(bool is_keyword) OVERRIDE; | |
| 171 virtual bool ShouldAppendExtraParams( | 174 virtual bool ShouldAppendExtraParams( |
| 172 const SearchSuggestionParser::SuggestResult& result) const OVERRIDE; | 175 const SearchSuggestionParser::SuggestResult& result) const OVERRIDE; |
| 173 virtual void StopSuggest() OVERRIDE; | 176 virtual void StopSuggest() OVERRIDE; |
| 174 virtual void ClearAllResults() OVERRIDE; | 177 virtual void ClearAllResults() OVERRIDE; |
| 175 virtual int GetDefaultResultRelevance() const OVERRIDE; | 178 virtual int GetDefaultResultRelevance() const OVERRIDE; |
| 176 virtual void RecordDeletionResult(bool success) OVERRIDE; | 179 virtual void RecordDeletionResult(bool success) OVERRIDE; |
| 177 virtual void LogFetchComplete(bool success, bool is_keyword) OVERRIDE; | 180 virtual void LogFetchComplete(bool success, bool is_keyword) OVERRIDE; |
| 178 virtual bool IsKeywordFetcher(const net::URLFetcher* fetcher) const OVERRIDE; | 181 virtual bool IsKeywordFetcher(const net::URLFetcher* fetcher) const OVERRIDE; |
| 179 virtual void UpdateMatches() OVERRIDE; | 182 virtual void UpdateMatches() OVERRIDE; |
| 180 | 183 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 // typing for long enough. | 325 // typing for long enough. |
| 323 base::OneShotTimer<SearchProvider> timer_; | 326 base::OneShotTimer<SearchProvider> timer_; |
| 324 | 327 |
| 325 // The time at which we sent a query to the suggest server. | 328 // The time at which we sent a query to the suggest server. |
| 326 base::TimeTicks time_suggest_request_sent_; | 329 base::TimeTicks time_suggest_request_sent_; |
| 327 | 330 |
| 328 // Fetchers used to retrieve results for the keyword and default providers. | 331 // Fetchers used to retrieve results for the keyword and default providers. |
| 329 scoped_ptr<net::URLFetcher> keyword_fetcher_; | 332 scoped_ptr<net::URLFetcher> keyword_fetcher_; |
| 330 scoped_ptr<net::URLFetcher> default_fetcher_; | 333 scoped_ptr<net::URLFetcher> default_fetcher_; |
| 331 | 334 |
| 332 // Results from the default and keyword search providers. | 335 // Results from the default and keyword search providers. The orig results |
|
msw
2014/08/14 02:57:23
nit: s/orig/original/ in comments and identifiers.
Mark P
2014/08/15 00:05:56
Now obsolete. (Got rid of the orig members.)
| |
| 336 // hold the original reply from the server; the non-orig results are the | |
| 337 // ones that should be used for most purposes. They may have been modified | |
| 338 // in some ways from the orig results, for instance, to demote a brand | |
| 339 // new suggestion that would be inline autocompleted. (We don't want | |
| 340 // asynchronous inline autocompletions.) | |
| 333 SearchSuggestionParser::Results default_results_; | 341 SearchSuggestionParser::Results default_results_; |
| 334 SearchSuggestionParser::Results keyword_results_; | 342 SearchSuggestionParser::Results keyword_results_; |
| 343 SearchSuggestionParser::Results orig_default_results_; | |
|
msw
2014/08/14 02:57:23
Why do we need a copy of the originals? Can't we m
Mark P
2014/08/15 00:05:56
Removed copy of the originals. Good idea.
| |
| 344 SearchSuggestionParser::Results orig_keyword_results_; | |
| 335 | 345 |
| 336 GURL current_page_url_; | 346 GURL current_page_url_; |
| 337 | 347 |
| 338 // Session token management. | 348 // Session token management. |
| 339 std::string current_token_; | 349 std::string current_token_; |
| 340 base::TimeTicks token_expiration_time_; | 350 base::TimeTicks token_expiration_time_; |
| 341 | 351 |
| 342 // Answers prefetch management. | 352 // Answers prefetch management. |
| 343 AnswersQueryData prefetch_data_; // Data to use for query prefetching. | 353 AnswersQueryData prefetch_data_; // Data to use for query prefetching. |
| 344 AnswersQueryData last_answer_seen_; // Last answer seen. | 354 AnswersQueryData last_answer_seen_; // Last answer seen. |
| 345 | 355 |
| 346 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 356 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 347 }; | 357 }; |
| 348 | 358 |
| 349 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 359 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| OLD | NEW |