| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 // AutocompleteProvider: | 70 // AutocompleteProvider: |
| 71 virtual void Stop(bool clear_cached_results) OVERRIDE; | 71 virtual void Stop(bool clear_cached_results) OVERRIDE; |
| 72 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; | 72 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; |
| 73 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; | 73 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; |
| 74 | 74 |
| 75 bool field_trial_triggered_in_session() const { | 75 bool field_trial_triggered_in_session() const { |
| 76 return field_trial_triggered_in_session_; | 76 return field_trial_triggered_in_session_; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void set_in_app_list() { in_app_list_ = true; } | |
| 80 | |
| 81 protected: | 79 protected: |
| 82 // The following keys are used to record additional information on matches. | 80 // The following keys are used to record additional information on matches. |
| 83 | 81 |
| 84 // We annotate our AutocompleteMatches with whether their relevance scores | 82 // We annotate our AutocompleteMatches with whether their relevance scores |
| 85 // were server-provided using this key in the |additional_info| field. | 83 // were server-provided using this key in the |additional_info| field. |
| 86 static const char kRelevanceFromServerKey[]; | 84 static const char kRelevanceFromServerKey[]; |
| 87 | 85 |
| 88 // Indicates whether the server said a match should be prefetched. | 86 // Indicates whether the server said a match should be prefetched. |
| 89 static const char kShouldPrefetchKey[]; | 87 static const char kShouldPrefetchKey[]; |
| 90 | 88 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // |input| is the original user input. Text in the input is used to highlight | 331 // |input| is the original user input. Text in the input is used to highlight |
| 334 // portions of the match contents to distinguish locally-typed text from | 332 // portions of the match contents to distinguish locally-typed text from |
| 335 // suggested text. | 333 // suggested text. |
| 336 // | 334 // |
| 337 // |input| is also necessary for various other details, like whether we should | 335 // |input| is also necessary for various other details, like whether we should |
| 338 // allow inline autocompletion and what the transition type should be. | 336 // allow inline autocompletion and what the transition type should be. |
| 339 // |accepted_suggestion| is used to generate Assisted Query Stats. | 337 // |accepted_suggestion| is used to generate Assisted Query Stats. |
| 340 // |append_extra_query_params| should be set if |template_url| is the default | 338 // |append_extra_query_params| should be set if |template_url| is the default |
| 341 // search engine, so the destination URL will contain any | 339 // search engine, so the destination URL will contain any |
| 342 // command-line-specified query params. | 340 // command-line-specified query params. |
| 343 // |from_app_list| should be set if the search was made from the app list. | |
| 344 static AutocompleteMatch CreateSearchSuggestion( | 341 static AutocompleteMatch CreateSearchSuggestion( |
| 345 AutocompleteProvider* autocomplete_provider, | 342 AutocompleteProvider* autocomplete_provider, |
| 346 const AutocompleteInput& input, | 343 const AutocompleteInput& input, |
| 347 const SuggestResult& suggestion, | 344 const SuggestResult& suggestion, |
| 348 const TemplateURL* template_url, | 345 const TemplateURL* template_url, |
| 349 const SearchTermsData& search_terms_data, | 346 const SearchTermsData& search_terms_data, |
| 350 int accepted_suggestion, | 347 int accepted_suggestion, |
| 351 bool append_extra_query_params, | 348 bool append_extra_query_params); |
| 352 bool from_app_list); | |
| 353 | 349 |
| 354 // Parses JSON response received from the provider, stripping XSSI | 350 // Parses JSON response received from the provider, stripping XSSI |
| 355 // protection if needed. Returns the parsed data if successful, NULL | 351 // protection if needed. Returns the parsed data if successful, NULL |
| 356 // otherwise. | 352 // otherwise. |
| 357 static scoped_ptr<base::Value> DeserializeJsonData(std::string json_data); | 353 static scoped_ptr<base::Value> DeserializeJsonData(std::string json_data); |
| 358 | 354 |
| 359 // Returns whether the requirements for requesting zero suggest results | 355 // Returns whether the requirements for requesting zero suggest results |
| 360 // are met. The requirements are | 356 // are met. The requirements are |
| 361 // * The user is enrolled in a zero suggest experiment. | 357 // * The user is enrolled in a zero suggest experiment. |
| 362 // * The user is not on the NTP. | 358 // * The user is not on the NTP. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 // server to handle the results of the deletion. It will be called after the | 506 // server to handle the results of the deletion. It will be called after the |
| 511 // deletion request completes. | 507 // deletion request completes. |
| 512 void OnDeletionComplete(bool success, | 508 void OnDeletionComplete(bool success, |
| 513 SuggestionDeletionHandler* handler); | 509 SuggestionDeletionHandler* handler); |
| 514 | 510 |
| 515 // Each deletion handler in this vector corresponds to an outstanding request | 511 // Each deletion handler in this vector corresponds to an outstanding request |
| 516 // that a server delete a personalized suggestion. Making this a ScopedVector | 512 // that a server delete a personalized suggestion. Making this a ScopedVector |
| 517 // causes us to auto-cancel all such requests on shutdown. | 513 // causes us to auto-cancel all such requests on shutdown. |
| 518 SuggestionDeletionHandlers deletion_handlers_; | 514 SuggestionDeletionHandlers deletion_handlers_; |
| 519 | 515 |
| 520 // True if this provider's results are being displayed in the app list. By | |
| 521 // default this is false, meaning that the results will be shown in the | |
| 522 // omnibox. | |
| 523 bool in_app_list_; | |
| 524 | |
| 525 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); | 516 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); |
| 526 }; | 517 }; |
| 527 | 518 |
| 528 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 519 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
| OLD | NEW |