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 COMPONENTS_OMNIBOX_BASE_SEARCH_PROVIDER_H_ | 9 #ifndef COMPONENTS_OMNIBOX_BASE_SEARCH_PROVIDER_H_ |
10 #define COMPONENTS_OMNIBOX_BASE_SEARCH_PROVIDER_H_ | 10 #define COMPONENTS_OMNIBOX_BASE_SEARCH_PROVIDER_H_ |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 public: | 42 public: |
43 // ID used in creating URLFetcher for default provider's suggest results. | 43 // ID used in creating URLFetcher for default provider's suggest results. |
44 static const int kDefaultProviderURLFetcherID; | 44 static const int kDefaultProviderURLFetcherID; |
45 | 45 |
46 // ID used in creating URLFetcher for keyword provider's suggest results. | 46 // ID used in creating URLFetcher for keyword provider's suggest results. |
47 static const int kKeywordProviderURLFetcherID; | 47 static const int kKeywordProviderURLFetcherID; |
48 | 48 |
49 // ID used in creating URLFetcher for deleting suggestion results. | 49 // ID used in creating URLFetcher for deleting suggestion results. |
50 static const int kDeletionURLFetcherID; | 50 static const int kDeletionURLFetcherID; |
51 | 51 |
52 BaseSearchProvider(TemplateURLService* template_url_service, | 52 BaseSearchProvider(AutocompleteProvider::Type type, |
53 scoped_ptr<AutocompleteProviderClient> client, | 53 AutocompleteProviderClient* client, |
54 AutocompleteProvider::Type type); | 54 TemplateURLService* template_url_service); |
55 | 55 |
56 // Returns whether |match| is flagged as a query that should be prefetched. | 56 // Returns whether |match| is flagged as a query that should be prefetched. |
57 static bool ShouldPrefetch(const AutocompleteMatch& match); | 57 static bool ShouldPrefetch(const AutocompleteMatch& match); |
58 | 58 |
59 // Returns a simpler AutocompleteMatch suitable for persistence like in | 59 // Returns a simpler AutocompleteMatch suitable for persistence like in |
60 // ShortcutsDatabase. This wrapper function uses a number of default values | 60 // ShortcutsDatabase. This wrapper function uses a number of default values |
61 // that may or may not be appropriate for your needs. | 61 // that may or may not be appropriate for your needs. |
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( |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 virtual const AutocompleteInput GetInput(bool is_keyword) const = 0; | 213 virtual const AutocompleteInput GetInput(bool is_keyword) const = 0; |
214 | 214 |
215 // Returns whether the destination URL corresponding to the given |result| | 215 // Returns whether the destination URL corresponding to the given |result| |
216 // should contain command-line-specified query params. | 216 // should contain command-line-specified query params. |
217 virtual bool ShouldAppendExtraParams( | 217 virtual bool ShouldAppendExtraParams( |
218 const SearchSuggestionParser::SuggestResult& result) const = 0; | 218 const SearchSuggestionParser::SuggestResult& result) const = 0; |
219 | 219 |
220 // Records in UMA whether the deletion request resulted in success. | 220 // Records in UMA whether the deletion request resulted in success. |
221 virtual void RecordDeletionResult(bool success) = 0; | 221 virtual void RecordDeletionResult(bool success) = 0; |
222 | 222 |
| 223 AutocompleteProviderClient* client_; |
223 TemplateURLService* template_url_service_; | 224 TemplateURLService* template_url_service_; |
224 scoped_ptr<AutocompleteProviderClient> client_; | |
225 | 225 |
226 // 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 |
227 // 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 |
228 // provider has completed and the response contained | 228 // provider has completed and the response contained |
229 // '"google:fieldtrialtriggered":true'. | 229 // '"google:fieldtrialtriggered":true'. |
230 bool field_trial_triggered_; | 230 bool field_trial_triggered_; |
231 | 231 |
232 // 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 |
233 // session. | 233 // session. |
234 bool field_trial_triggered_in_session_; | 234 bool field_trial_triggered_in_session_; |
(...skipping 13 matching lines...) Expand all Loading... |
248 | 248 |
249 // Each deletion handler in this vector corresponds to an outstanding request | 249 // Each deletion handler in this vector corresponds to an outstanding request |
250 // that a server delete a personalized suggestion. Making this a ScopedVector | 250 // that a server delete a personalized suggestion. Making this a ScopedVector |
251 // causes us to auto-cancel all such requests on shutdown. | 251 // causes us to auto-cancel all such requests on shutdown. |
252 SuggestionDeletionHandlers deletion_handlers_; | 252 SuggestionDeletionHandlers deletion_handlers_; |
253 | 253 |
254 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); | 254 DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); |
255 }; | 255 }; |
256 | 256 |
257 #endif // COMPONENTS_OMNIBOX_BASE_SEARCH_PROVIDER_H_ | 257 #endif // COMPONENTS_OMNIBOX_BASE_SEARCH_PROVIDER_H_ |
OLD | NEW |