| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // NOTE: Use with care. Most likely you want the other CreateSearchSuggestion | 62 // NOTE: Use with care. Most likely you want the other CreateSearchSuggestion |
| 63 // with protected access. | 63 // with protected access. |
| 64 static AutocompleteMatch CreateSearchSuggestion( | 64 static AutocompleteMatch CreateSearchSuggestion( |
| 65 const base::string16& suggestion, | 65 const base::string16& suggestion, |
| 66 AutocompleteMatchType::Type type, | 66 AutocompleteMatchType::Type type, |
| 67 bool from_keyword_provider, | 67 bool from_keyword_provider, |
| 68 const TemplateURL* template_url, | 68 const TemplateURL* template_url, |
| 69 const SearchTermsData& search_terms_data); | 69 const SearchTermsData& search_terms_data); |
| 70 | 70 |
| 71 // AutocompleteProvider: | 71 // AutocompleteProvider: |
| 72 virtual void Stop(bool clear_cached_results) OVERRIDE; | |
| 73 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; | 72 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; |
| 74 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; | 73 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; |
| 75 | 74 |
| 76 bool field_trial_triggered_in_session() const { | 75 bool field_trial_triggered_in_session() const { |
| 77 return field_trial_triggered_in_session_; | 76 return field_trial_triggered_in_session_; |
| 78 } | 77 } |
| 79 | 78 |
| 80 protected: | 79 protected: |
| 81 // The following keys are used to record additional information on matches. | 80 // The following keys are used to record additional information on matches. |
| 82 | 81 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 210 |
| 212 // Returns the AutocompleteInput for keyword provider or default provider | 211 // Returns the AutocompleteInput for keyword provider or default provider |
| 213 // based on the value of |is_keyword|. | 212 // based on the value of |is_keyword|. |
| 214 virtual const AutocompleteInput GetInput(bool is_keyword) const = 0; | 213 virtual const AutocompleteInput GetInput(bool is_keyword) const = 0; |
| 215 | 214 |
| 216 // Returns whether the destination URL corresponding to the given |result| | 215 // Returns whether the destination URL corresponding to the given |result| |
| 217 // should contain command-line-specified query params. | 216 // should contain command-line-specified query params. |
| 218 virtual bool ShouldAppendExtraParams( | 217 virtual bool ShouldAppendExtraParams( |
| 219 const SearchSuggestionParser::SuggestResult& result) const = 0; | 218 const SearchSuggestionParser::SuggestResult& result) const = 0; |
| 220 | 219 |
| 221 // Stops the suggest query. | |
| 222 // NOTE: This does not update |done_|. Callers must do so. | |
| 223 virtual void StopSuggest() = 0; | |
| 224 | |
| 225 // Clears the current results. | |
| 226 virtual void ClearAllResults() = 0; | |
| 227 | |
| 228 // Records in UMA whether the deletion request resulted in success. | 220 // Records in UMA whether the deletion request resulted in success. |
| 229 virtual void RecordDeletionResult(bool success) = 0; | 221 virtual void RecordDeletionResult(bool success) = 0; |
| 230 | 222 |
| 231 // Modify provider-specific UMA statistics. | |
| 232 virtual void ModifyProviderInfo( | |
| 233 metrics::OmniboxEventProto_ProviderInfo* provider_info) const; | |
| 234 | |
| 235 TemplateURLService* template_url_service_; | 223 TemplateURLService* template_url_service_; |
| 236 Profile* profile_; | 224 Profile* profile_; |
| 237 | 225 |
| 238 // Whether a field trial, if any, has triggered in the most recent | 226 // Whether a field trial, if any, has triggered in the most recent |
| 239 // autocomplete query. This field is set to true only if the suggestion | 227 // autocomplete query. This field is set to true only if the suggestion |
| 240 // provider has completed and the response contained | 228 // provider has completed and the response contained |
| 241 // '"google:fieldtrialtriggered":true'. | 229 // '"google:fieldtrialtriggered":true'. |
| 242 bool field_trial_triggered_; | 230 bool field_trial_triggered_; |
| 243 | 231 |
| 244 // Same as above except that it is maintained across the current Omnibox | 232 // Same as above except that it is maintained across the current Omnibox |
| (...skipping 15 matching lines...) Expand all Loading... |
| 260 | 248 |
| 261 // Each deletion handler in this vector corresponds to an outstanding request | 249 // Each deletion handler in this vector corresponds to an outstanding request |
| 262 // that a server delete a personalized suggestion. Making this a ScopedVector | 250 // that a server delete a personalized suggestion. Making this a ScopedVector |
| 263 // causes us to auto-cancel all such requests on shutdown. | 251 // causes us to auto-cancel all such requests on shutdown. |
| 264 SuggestionDeletionHandlers deletion_handlers_; | 252 SuggestionDeletionHandlers deletion_handlers_; |
| 265 | 253 |
| 266 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); | 254 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); |
| 267 }; | 255 }; |
| 268 | 256 |
| 269 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ | 257 #endif // CHROME_BROWSER_AUTOCOMPLETE_BASE_SEARCH_PROVIDER_H_ |
| OLD | NEW |