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 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 DeleteMatch(const AutocompleteMatch& match) override; | 72 void DeleteMatch(const AutocompleteMatch& match) override; |
73 virtual void AddProviderInfo(ProvidersInfo* provider_info) const override; | 73 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 protected: | 79 protected: |
80 // The following keys are used to record additional information on matches. | 80 // The following keys are used to record additional information on matches. |
81 | 81 |
82 // We annotate our AutocompleteMatches with whether their relevance scores | 82 // We annotate our AutocompleteMatches with whether their relevance scores |
83 // were server-provided using this key in the |additional_info| field. | 83 // were server-provided using this key in the |additional_info| field. |
84 static const char kRelevanceFromServerKey[]; | 84 static const char kRelevanceFromServerKey[]; |
85 | 85 |
86 // Indicates whether the server said a match should be prefetched. | 86 // Indicates whether the server said a match should be prefetched. |
87 static const char kShouldPrefetchKey[]; | 87 static const char kShouldPrefetchKey[]; |
88 | 88 |
89 // Used to store metadata from the server response, which is needed for | 89 // Used to store metadata from the server response, which is needed for |
90 // prefetching. | 90 // prefetching. |
91 static const char kSuggestMetadataKey[]; | 91 static const char kSuggestMetadataKey[]; |
92 | 92 |
93 // Used to store a deletion request url for server-provided suggestions. | 93 // Used to store a deletion request url for server-provided suggestions. |
94 static const char kDeletionUrlKey[]; | 94 static const char kDeletionUrlKey[]; |
95 | 95 |
96 // These are the values for the above keys. | 96 // These are the values for the above keys. |
97 static const char kTrue[]; | 97 static const char kTrue[]; |
98 static const char kFalse[]; | 98 static const char kFalse[]; |
99 | 99 |
100 virtual ~BaseSearchProvider(); | 100 ~BaseSearchProvider() override; |
101 | 101 |
102 typedef std::pair<base::string16, std::string> MatchKey; | 102 typedef std::pair<base::string16, std::string> MatchKey; |
103 typedef std::map<MatchKey, AutocompleteMatch> MatchMap; | 103 typedef std::map<MatchKey, AutocompleteMatch> MatchMap; |
104 typedef ScopedVector<SuggestionDeletionHandler> SuggestionDeletionHandlers; | 104 typedef ScopedVector<SuggestionDeletionHandler> SuggestionDeletionHandlers; |
105 | 105 |
106 // Returns an AutocompleteMatch with the given |autocomplete_provider| | 106 // Returns an AutocompleteMatch with the given |autocomplete_provider| |
107 // for the search |suggestion|, which represents a search via |template_url|. | 107 // for the search |suggestion|, which represents a search via |template_url|. |
108 // If |template_url| is NULL, returns a match with an invalid destination URL. | 108 // If |template_url| is NULL, returns a match with an invalid destination URL. |
109 // | 109 // |
110 // |input| is the original user input. Text in the input is used to highlight | 110 // |input| is the original user input. Text in the input is used to highlight |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |