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 #ifndef COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ | 5 #ifndef COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ |
6 #define COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ | 6 #define COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "components/omnibox/autocomplete_match.h" | 14 #include "components/omnibox/autocomplete_match.h" |
15 #include "components/omnibox/autocomplete_match_type.h" | 15 #include "components/omnibox/autocomplete_match_type.h" |
16 #include "components/omnibox/suggestion_answer.h" | |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 class AutocompleteInput; | 19 class AutocompleteInput; |
19 class AutocompleteSchemeClassifier; | 20 class AutocompleteSchemeClassifier; |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class DictionaryValue; | 23 class DictionaryValue; |
23 class Value; | 24 class Value; |
24 } | 25 } |
25 | 26 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 | 112 |
112 class SuggestResult : public Result { | 113 class SuggestResult : public Result { |
113 public: | 114 public: |
114 SuggestResult(const base::string16& suggestion, | 115 SuggestResult(const base::string16& suggestion, |
115 AutocompleteMatchType::Type type, | 116 AutocompleteMatchType::Type type, |
116 const base::string16& match_contents, | 117 const base::string16& match_contents, |
117 const base::string16& match_contents_prefix, | 118 const base::string16& match_contents_prefix, |
118 const base::string16& annotation, | 119 const base::string16& annotation, |
119 const base::string16& answer_contents, | 120 const base::string16& answer_contents, |
120 const base::string16& answer_type, | 121 const base::string16& answer_type, |
122 const SuggestionAnswer& answer, | |
groby-ooo-7-16
2014/10/23 00:46:19
Can we roll answer_contents/answer_type into Sugge
Justin Donnelly
2014/10/23 17:59:37
Oh, I see what you're saying now. True, SuggestRe
groby-ooo-7-16
2014/10/23 21:59:54
Works for me
| |
121 const std::string& suggest_query_params, | 123 const std::string& suggest_query_params, |
122 const std::string& deletion_url, | 124 const std::string& deletion_url, |
123 bool from_keyword_provider, | 125 bool from_keyword_provider, |
124 int relevance, | 126 int relevance, |
125 bool relevance_from_server, | 127 bool relevance_from_server, |
126 bool should_prefetch, | 128 bool should_prefetch, |
127 const base::string16& input_text); | 129 const base::string16& input_text); |
128 virtual ~SuggestResult(); | 130 virtual ~SuggestResult(); |
129 | 131 |
130 const base::string16& suggestion() const { return suggestion_; } | 132 const base::string16& suggestion() const { return suggestion_; } |
131 const base::string16& match_contents_prefix() const { | 133 const base::string16& match_contents_prefix() const { |
132 return match_contents_prefix_; | 134 return match_contents_prefix_; |
133 } | 135 } |
134 const base::string16& annotation() const { return annotation_; } | 136 const base::string16& annotation() const { return annotation_; } |
135 const std::string& suggest_query_params() const { | 137 const std::string& suggest_query_params() const { |
136 return suggest_query_params_; | 138 return suggest_query_params_; |
137 } | 139 } |
138 | 140 |
139 const base::string16& answer_contents() const { return answer_contents_; } | 141 const base::string16& answer_contents() const { return answer_contents_; } |
140 const base::string16& answer_type() const { return answer_type_; } | 142 const base::string16& answer_type() const { return answer_type_; } |
143 const SuggestionAnswer& answer() const { return answer_; } | |
141 | 144 |
142 bool should_prefetch() const { return should_prefetch_; } | 145 bool should_prefetch() const { return should_prefetch_; } |
143 | 146 |
144 // Fills in |match_contents_class_| to reflect how |match_contents_| should | 147 // Fills in |match_contents_class_| to reflect how |match_contents_| should |
145 // be displayed and bolded against the current |input_text|. If | 148 // be displayed and bolded against the current |input_text|. If |
146 // |allow_bolding_all| is false and |match_contents_class_| would have all | 149 // |allow_bolding_all| is false and |match_contents_class_| would have all |
147 // of |match_contents_| bolded, do nothing. | 150 // of |match_contents_| bolded, do nothing. |
148 void ClassifyMatchContents(const bool allow_bolding_all, | 151 void ClassifyMatchContents(const bool allow_bolding_all, |
149 const base::string16& input_text); | 152 const base::string16& input_text); |
150 | 153 |
(...skipping 13 matching lines...) Expand all Loading... | |
164 base::string16 match_contents_prefix_; | 167 base::string16 match_contents_prefix_; |
165 | 168 |
166 // Optional annotation for the |match_contents_| for disambiguation. | 169 // Optional annotation for the |match_contents_| for disambiguation. |
167 // This may be displayed in the autocomplete match contents, but is defined | 170 // This may be displayed in the autocomplete match contents, but is defined |
168 // separately to facilitate different formatting. | 171 // separately to facilitate different formatting. |
169 base::string16 annotation_; | 172 base::string16 annotation_; |
170 | 173 |
171 // Optional additional parameters to be added to the search URL. | 174 // Optional additional parameters to be added to the search URL. |
172 std::string suggest_query_params_; | 175 std::string suggest_query_params_; |
173 | 176 |
177 // TODO(jdonnelly): Remove the following two properties once the downstream | |
178 // clients are using the SuggestionAnswer. | |
groby-ooo-7-16
2014/10/23 00:46:19
Ah. See above. Nobody should use the member vars d
Justin Donnelly
2014/10/23 17:59:37
See previous response.
| |
174 // Optional formatted Answers result. | 179 // Optional formatted Answers result. |
175 base::string16 answer_contents_; | 180 base::string16 answer_contents_; |
176 | 181 |
177 // Type of optional formatted Answers result. | 182 // Type of optional formatted Answers result. |
178 base::string16 answer_type_; | 183 base::string16 answer_type_; |
179 | 184 |
185 // Optional short answer to the input that produced this suggestion. | |
186 SuggestionAnswer answer_; | |
187 | |
180 // Should this result be prefetched? | 188 // Should this result be prefetched? |
181 bool should_prefetch_; | 189 bool should_prefetch_; |
182 }; | 190 }; |
183 | 191 |
184 class NavigationResult : public Result { | 192 class NavigationResult : public Result { |
185 public: | 193 public: |
186 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier, | 194 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier, |
187 const GURL& url, | 195 const GURL& url, |
188 AutocompleteMatchType::Type type, | 196 AutocompleteMatchType::Type type, |
189 const base::string16& description, | 197 const base::string16& description, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 bool is_keyword_result, | 301 bool is_keyword_result, |
294 Results* results); | 302 Results* results); |
295 | 303 |
296 private: | 304 private: |
297 FRIEND_TEST_ALL_PREFIXES(SearchSuggestionParser, | 305 FRIEND_TEST_ALL_PREFIXES(SearchSuggestionParser, |
298 GetAnswersImageURLsWithoutImagelines); | 306 GetAnswersImageURLsWithoutImagelines); |
299 FRIEND_TEST_ALL_PREFIXES(SearchSuggestionParser, | 307 FRIEND_TEST_ALL_PREFIXES(SearchSuggestionParser, |
300 GetAnswersImageURLsWithValidImage); | 308 GetAnswersImageURLsWithValidImage); |
301 | 309 |
302 // Gets URLs of any images in Answers results. | 310 // Gets URLs of any images in Answers results. |
303 static void GetAnswersImageURLs(const base::DictionaryValue* answer_json, | 311 static void GetAnswersImageURLs(const SuggestionAnswer& answer, |
304 std::vector<GURL>* urls); | 312 std::vector<GURL>* urls); |
305 | 313 |
306 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); | 314 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); |
307 }; | 315 }; |
308 | 316 |
309 #endif // COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ | 317 #endif // COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ |
OLD | NEW |