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