Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 class contains common functionality for search-based autocomplete | 5 // This class contains common functionality for search-based autocomplete |
| 6 // providers. Search provider and zero suggest provider both use it for common | 6 // providers. Search provider and zero suggest provider both use it for common |
| 7 // functionality. | 7 // functionality. |
| 8 | 8 |
| 9 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 9 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
| 10 #define CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 10 #define CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 | 66 |
| 67 // AutocompleteProvider: | 67 // AutocompleteProvider: |
| 68 virtual void Stop(bool clear_cached_results) OVERRIDE; | 68 virtual void Stop(bool clear_cached_results) OVERRIDE; |
| 69 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; | 69 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; |
| 70 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; | 70 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; |
| 71 | 71 |
| 72 bool field_trial_triggered_in_session() const { | 72 bool field_trial_triggered_in_session() const { |
| 73 return field_trial_triggered_in_session_; | 73 return field_trial_triggered_in_session_; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Sets this as being in the app list. | |
|
Peter Kasting
2014/04/09 02:12:33
Nit: No need for a comment here as long as the one
Sam McNally
2014/04/09 05:33:44
Done.
| |
| 77 void set_in_app_list() { in_app_list_ = true; } | |
| 78 | |
| 76 protected: | 79 protected: |
| 77 // The following keys are used to record additional information on matches. | 80 // The following keys are used to record additional information on matches. |
| 78 | 81 |
| 79 // We annotate our AutocompleteMatches with whether their relevance scores | 82 // We annotate our AutocompleteMatches with whether their relevance scores |
| 80 // were server-provided using this key in the |additional_info| field. | 83 // were server-provided using this key in the |additional_info| field. |
| 81 static const char kRelevanceFromServerKey[]; | 84 static const char kRelevanceFromServerKey[]; |
| 82 | 85 |
| 83 // Indicates whether the server said a match should be prefetched. | 86 // Indicates whether the server said a match should be prefetched. |
| 84 static const char kShouldPrefetchKey[]; | 87 static const char kShouldPrefetchKey[]; |
| 85 | 88 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 // portions of the match contents to distinguish locally-typed text from | 323 // portions of the match contents to distinguish locally-typed text from |
| 321 // suggested text. | 324 // suggested text. |
| 322 // | 325 // |
| 323 // |input| is also necessary for various other details, like whether we should | 326 // |input| is also necessary for various other details, like whether we should |
| 324 // allow inline autocompletion and what the transition type should be. | 327 // allow inline autocompletion and what the transition type should be. |
| 325 // |accepted_suggestion| and |omnibox_start_margin| are used to generate | 328 // |accepted_suggestion| and |omnibox_start_margin| are used to generate |
| 326 // Assisted Query Stats. | 329 // Assisted Query Stats. |
| 327 // |append_extra_query_params| should be set if |template_url| is the default | 330 // |append_extra_query_params| should be set if |template_url| is the default |
| 328 // search engine, so the destination URL will contain any | 331 // search engine, so the destination URL will contain any |
| 329 // command-line-specified query params. | 332 // command-line-specified query params. |
| 333 // |from_app_list| should be set if the search was made from the app list. | |
| 330 static AutocompleteMatch CreateSearchSuggestion( | 334 static AutocompleteMatch CreateSearchSuggestion( |
| 331 AutocompleteProvider* autocomplete_provider, | 335 AutocompleteProvider* autocomplete_provider, |
| 332 const AutocompleteInput& input, | 336 const AutocompleteInput& input, |
| 333 const SuggestResult& suggestion, | 337 const SuggestResult& suggestion, |
| 334 const TemplateURL* template_url, | 338 const TemplateURL* template_url, |
| 335 int accepted_suggestion, | 339 int accepted_suggestion, |
| 336 int omnibox_start_margin, | 340 int omnibox_start_margin, |
| 337 bool append_extra_query_params); | 341 bool append_extra_query_params, |
| 342 bool from_app_list); | |
| 338 | 343 |
| 339 // Parses JSON response received from the provider, stripping XSSI | 344 // Parses JSON response received from the provider, stripping XSSI |
| 340 // protection if needed. Returns the parsed data if successful, NULL | 345 // protection if needed. Returns the parsed data if successful, NULL |
| 341 // otherwise. | 346 // otherwise. |
| 342 static scoped_ptr<base::Value> DeserializeJsonData(std::string json_data); | 347 static scoped_ptr<base::Value> DeserializeJsonData(std::string json_data); |
| 343 | 348 |
| 344 // Returns whether the requirements for requesting zero suggest results | 349 // Returns whether the requirements for requesting zero suggest results |
| 345 // are met. The requirements are | 350 // are met. The requirements are |
| 346 // * The user is enrolled in a zero suggest experiment. | 351 // * The user is enrolled in a zero suggest experiment. |
| 347 // * The user is not on the NTP. | 352 // * The user is not on the NTP. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 // server to handle the results of the deletion. It will be called after the | 478 // server to handle the results of the deletion. It will be called after the |
| 474 // deletion request completes. | 479 // deletion request completes. |
| 475 void OnDeletionComplete(bool success, | 480 void OnDeletionComplete(bool success, |
| 476 SuggestionDeletionHandler* handler); | 481 SuggestionDeletionHandler* handler); |
| 477 | 482 |
| 478 // Each deletion handler in this vector corresponds to an outstanding request | 483 // Each deletion handler in this vector corresponds to an outstanding request |
| 479 // that a server delete a personalized suggestion. Making this a ScopedVector | 484 // that a server delete a personalized suggestion. Making this a ScopedVector |
| 480 // causes us to auto-cancel all such requests on shutdown. | 485 // causes us to auto-cancel all such requests on shutdown. |
| 481 SuggestionDeletionHandlers deletion_handlers_; | 486 SuggestionDeletionHandlers deletion_handlers_; |
| 482 | 487 |
| 488 // True if this is in the app list. Otherwise, this is in the omnibox. | |
|
Peter Kasting
2014/04/09 02:12:33
Nit: Maybe:
True if this provider's results are b
Sam McNally
2014/04/09 05:33:44
Done.
| |
| 489 bool in_app_list_; | |
| 490 | |
| 483 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); | 491 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); |
| 484 }; | 492 }; |
| 485 | 493 |
| 486 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 494 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
| OLD | NEW |