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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 void AddNavigationResultsToMatches( | 241 void AddNavigationResultsToMatches( |
| 242 const SearchSuggestionParser::NavigationResults& navigation_results, | 242 const SearchSuggestionParser::NavigationResults& navigation_results, |
| 243 ACMatches* matches); | 243 ACMatches* matches); |
| 244 | 244 |
| 245 // Adds a match for each result in |results| to |map|. |is_keyword| indicates | 245 // Adds a match for each result in |results| to |map|. |is_keyword| indicates |
| 246 // whether the results correspond to the keyword provider or default provider. | 246 // whether the results correspond to the keyword provider or default provider. |
| 247 void AddHistoryResultsToMap(const HistoryResults& results, | 247 void AddHistoryResultsToMap(const HistoryResults& results, |
| 248 bool is_keyword, | 248 bool is_keyword, |
| 249 int did_not_accept_suggestion, | 249 int did_not_accept_suggestion, |
| 250 MatchMap* map); | 250 MatchMap* map); |
| 251 // Adds a match for each scored result in |results| to |map|. | |
|
Mark P
2014/09/05 22:18:16
I don't really like the notion of calling these "s
Mark P
2014/09/05 22:18:16
nit: missing blank line
groby-ooo-7-16
2014/09/10 23:21:38
Done.
groby-ooo-7-16
2014/09/10 23:21:38
Not really, so I'll stick with the suggestion :)
| |
| 252 void AddScoredHistoryResultsToMap( | |
| 253 const SearchSuggestionParser::SuggestResults& results, | |
| 254 int did_not_accept_suggestion, | |
| 255 MatchMap* map); | |
| 251 | 256 |
| 252 // Calculates relevance scores for all |results|. | 257 // Calculates relevance scores for all |results|. |
| 253 SearchSuggestionParser::SuggestResults ScoreHistoryResults( | 258 SearchSuggestionParser::SuggestResults ScoreHistoryResults( |
| 254 const HistoryResults& results, | 259 const HistoryResults& results, |
| 255 bool base_prevent_inline_autocomplete, | 260 bool base_prevent_inline_autocomplete, |
| 256 bool input_multiple_words, | 261 bool input_multiple_words, |
| 257 const base::string16& input_text, | 262 const base::string16& input_text, |
| 258 bool is_keyword); | 263 bool is_keyword); |
| 259 | 264 void ScoreHistoryResultsMultiWord( |
|
Mark P
2014/09/05 22:18:16
I originally read this and added the comment
"opti
groby-ooo-7-16
2014/09/10 23:21:38
The name is based on the comment in DoHistoryQuery
| |
| 265 const HistoryResults& results, | |
| 266 bool is_keyword, | |
| 267 SearchSuggestionParser::SuggestResults* scored_results); | |
| 260 // Adds matches for |results| to |map|. | 268 // Adds matches for |results| to |map|. |
|
Mark P
2014/09/05 22:18:16
nit: missing blank line
groby-ooo-7-16
2014/09/10 23:21:38
Done.
| |
| 261 void AddSuggestResultsToMap( | 269 void AddSuggestResultsToMap( |
| 262 const SearchSuggestionParser::SuggestResults& results, | 270 const SearchSuggestionParser::SuggestResults& results, |
| 263 const std::string& metadata, | 271 const std::string& metadata, |
| 264 MatchMap* map); | 272 MatchMap* map); |
| 265 | 273 |
| 266 // Gets the relevance score for the verbatim result. This value may be | 274 // Gets the relevance score for the verbatim result. This value may be |
| 267 // provided by the suggest server or calculated locally; if | 275 // provided by the suggest server or calculated locally; if |
| 268 // |relevance_from_server| is non-NULL, it will be set to indicate which of | 276 // |relevance_from_server| is non-NULL, it will be set to indicate which of |
| 269 // those is true. | 277 // those is true. |
| 270 int GetVerbatimRelevance(bool* relevance_from_server) const; | 278 int GetVerbatimRelevance(bool* relevance_from_server) const; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 AutocompleteMatch NavigationToMatch( | 311 AutocompleteMatch NavigationToMatch( |
| 304 const SearchSuggestionParser::NavigationResult& navigation); | 312 const SearchSuggestionParser::NavigationResult& navigation); |
| 305 | 313 |
| 306 // Updates the value of |done_| from the internal state. | 314 // Updates the value of |done_| from the internal state. |
| 307 void UpdateDone(); | 315 void UpdateDone(); |
| 308 | 316 |
| 309 // Obtains a session token, regenerating if necessary. | 317 // Obtains a session token, regenerating if necessary. |
| 310 std::string GetSessionToken(); | 318 std::string GetSessionToken(); |
| 311 | 319 |
| 312 // Answers prefetch handling - finds previously displayed answer matching the | 320 // Answers prefetch handling - finds previously displayed answer matching the |
| 313 // current |input| and sets |prefetch_data_|. | 321 // current |input| and sets |prefetch_data_|. |
|
Mark P
2014/09/05 22:18:16
This comment doesn't seem appropriate anymore. Pl
groby-ooo-7-16
2014/09/10 23:21:38
Done.
| |
| 314 void DoAnswersQuery(const AutocompleteInput& input); | 322 AnswersQueryData FindAnswersPrefetchData(const base::string16& input); |
| 315 | 323 |
| 316 // The amount of time to wait before sending a new suggest request after the | 324 // The amount of time to wait before sending a new suggest request after the |
| 317 // previous one. Non-const because some unittests modify this value. | 325 // previous one. Non-const because some unittests modify this value. |
| 318 static int kMinimumTimeBetweenSuggestQueriesMs; | 326 static int kMinimumTimeBetweenSuggestQueriesMs; |
| 319 | 327 |
| 320 AutocompleteProviderListener* listener_; | 328 AutocompleteProviderListener* listener_; |
| 321 | 329 |
| 322 // The number of suggest results that haven't yet arrived. If it's greater | 330 // The number of suggest results that haven't yet arrived. If it's greater |
| 323 // than 0, it indicates that one of the URLFetchers is still running. | 331 // than 0, it indicates that one of the URLFetchers is still running. |
| 324 int suggest_results_pending_; | 332 int suggest_results_pending_; |
| 325 | 333 |
| 326 // Maintains the TemplateURLs used. | 334 // Maintains the TemplateURLs used. |
| 327 Providers providers_; | 335 Providers providers_; |
| 328 | 336 |
| 329 // The user's input. | 337 // The user's input. |
| 330 AutocompleteInput input_; | 338 AutocompleteInput input_; |
| 331 | 339 |
| 332 // Input when searching against the keyword provider. | 340 // Input when searching against the keyword provider. |
| 333 AutocompleteInput keyword_input_; | 341 AutocompleteInput keyword_input_; |
| 334 | 342 |
| 335 // Searches in the user's history that begin with the input text. | 343 // Searches in the user's history that begin with the input text. |
| 336 HistoryResults keyword_history_results_; | 344 HistoryResults keyword_history_results_; |
| 337 HistoryResults default_history_results_; | 345 HistoryResults default_history_results_; |
| 338 | 346 |
| 347 // Scored searches in the user's history - based on xxx_history_results_. | |
|
Mark P
2014/09/05 22:18:16
nit: xxx_history_results_. -> keyword_history_resu
groby-ooo-7-16
2014/09/10 23:21:38
Done.
| |
| 348 SearchSuggestionParser::SuggestResults scored_keyword_history_results_; | |
| 349 SearchSuggestionParser::SuggestResults scored_default_history_results_; | |
| 350 | |
| 339 // A timer to start a query to the suggest server after the user has stopped | 351 // A timer to start a query to the suggest server after the user has stopped |
| 340 // typing for long enough. | 352 // typing for long enough. |
| 341 base::OneShotTimer<SearchProvider> timer_; | 353 base::OneShotTimer<SearchProvider> timer_; |
| 342 | 354 |
| 343 // The time at which we sent a query to the suggest server. | 355 // The time at which we sent a query to the suggest server. |
| 344 base::TimeTicks time_suggest_request_sent_; | 356 base::TimeTicks time_suggest_request_sent_; |
| 345 | 357 |
| 346 // Fetchers used to retrieve results for the keyword and default providers. | 358 // Fetchers used to retrieve results for the keyword and default providers. |
| 347 scoped_ptr<net::URLFetcher> keyword_fetcher_; | 359 scoped_ptr<net::URLFetcher> keyword_fetcher_; |
| 348 scoped_ptr<net::URLFetcher> default_fetcher_; | 360 scoped_ptr<net::URLFetcher> default_fetcher_; |
| 349 | 361 |
| 350 // Results from the default and keyword search providers. | 362 // Results from the default and keyword search providers. |
| 351 SearchSuggestionParser::Results default_results_; | 363 SearchSuggestionParser::Results default_results_; |
| 352 SearchSuggestionParser::Results keyword_results_; | 364 SearchSuggestionParser::Results keyword_results_; |
| 353 | 365 |
| 354 GURL current_page_url_; | 366 GURL current_page_url_; |
| 355 | 367 |
| 356 // Session token management. | 368 // Session token management. |
| 357 std::string current_token_; | 369 std::string current_token_; |
| 358 base::TimeTicks token_expiration_time_; | 370 base::TimeTicks token_expiration_time_; |
| 359 | 371 |
| 360 // Answers prefetch management. | 372 // Answers prefetch management. |
| 361 AnswersCache answers_cache_; // Cache for last answers seen. | 373 AnswersCache answers_cache_; // Cache for last answers seen. |
| 362 AnswersQueryData prefetch_data_; // Data to use for query prefetching. | 374 AnswersQueryData prefetch_data_; // Data to use for query prefetching. |
| 363 | 375 |
| 364 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 376 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 365 }; | 377 }; |
| 366 | 378 |
| 367 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 379 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| OLD | NEW |