| 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 scoped_ptr<SuggestionAnswer> answer, |
| 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); |
| 130 SuggestResult(const SuggestResult& result); |
| 128 virtual ~SuggestResult(); | 131 virtual ~SuggestResult(); |
| 129 | 132 |
| 133 SuggestResult& operator=(const SuggestResult& result); |
| 134 |
| 130 const base::string16& suggestion() const { return suggestion_; } | 135 const base::string16& suggestion() const { return suggestion_; } |
| 131 const base::string16& match_contents_prefix() const { | 136 const base::string16& match_contents_prefix() const { |
| 132 return match_contents_prefix_; | 137 return match_contents_prefix_; |
| 133 } | 138 } |
| 134 const base::string16& annotation() const { return annotation_; } | 139 const base::string16& annotation() const { return annotation_; } |
| 135 const std::string& suggest_query_params() const { | 140 const std::string& suggest_query_params() const { |
| 136 return suggest_query_params_; | 141 return suggest_query_params_; |
| 137 } | 142 } |
| 138 | 143 |
| 139 const base::string16& answer_contents() const { return answer_contents_; } | 144 const base::string16& answer_contents() const { return answer_contents_; } |
| 140 const base::string16& answer_type() const { return answer_type_; } | 145 const base::string16& answer_type() const { return answer_type_; } |
| 146 const SuggestionAnswer* answer() const { return answer_.get(); } |
| 141 | 147 |
| 142 bool should_prefetch() const { return should_prefetch_; } | 148 bool should_prefetch() const { return should_prefetch_; } |
| 143 | 149 |
| 144 // Fills in |match_contents_class_| to reflect how |match_contents_| should | 150 // Fills in |match_contents_class_| to reflect how |match_contents_| should |
| 145 // be displayed and bolded against the current |input_text|. If | 151 // be displayed and bolded against the current |input_text|. If |
| 146 // |allow_bolding_all| is false and |match_contents_class_| would have all | 152 // |allow_bolding_all| is false and |match_contents_class_| would have all |
| 147 // of |match_contents_| bolded, do nothing. | 153 // of |match_contents_| bolded, do nothing. |
| 148 void ClassifyMatchContents(const bool allow_bolding_all, | 154 void ClassifyMatchContents(const bool allow_bolding_all, |
| 149 const base::string16& input_text); | 155 const base::string16& input_text); |
| 150 | 156 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 164 base::string16 match_contents_prefix_; | 170 base::string16 match_contents_prefix_; |
| 165 | 171 |
| 166 // Optional annotation for the |match_contents_| for disambiguation. | 172 // Optional annotation for the |match_contents_| for disambiguation. |
| 167 // This may be displayed in the autocomplete match contents, but is defined | 173 // This may be displayed in the autocomplete match contents, but is defined |
| 168 // separately to facilitate different formatting. | 174 // separately to facilitate different formatting. |
| 169 base::string16 annotation_; | 175 base::string16 annotation_; |
| 170 | 176 |
| 171 // Optional additional parameters to be added to the search URL. | 177 // Optional additional parameters to be added to the search URL. |
| 172 std::string suggest_query_params_; | 178 std::string suggest_query_params_; |
| 173 | 179 |
| 180 // TODO(jdonnelly): Remove the following two properties once the downstream |
| 181 // clients are using the SuggestionAnswer. |
| 174 // Optional formatted Answers result. | 182 // Optional formatted Answers result. |
| 175 base::string16 answer_contents_; | 183 base::string16 answer_contents_; |
| 176 | 184 |
| 177 // Type of optional formatted Answers result. | 185 // Type of optional formatted Answers result. |
| 178 base::string16 answer_type_; | 186 base::string16 answer_type_; |
| 179 | 187 |
| 188 // Optional short answer to the input that produced this suggestion. |
| 189 scoped_ptr<SuggestionAnswer> answer_; |
| 190 |
| 180 // Should this result be prefetched? | 191 // Should this result be prefetched? |
| 181 bool should_prefetch_; | 192 bool should_prefetch_; |
| 182 }; | 193 }; |
| 183 | 194 |
| 184 class NavigationResult : public Result { | 195 class NavigationResult : public Result { |
| 185 public: | 196 public: |
| 186 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier, | 197 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier, |
| 187 const GURL& url, | 198 const GURL& url, |
| 188 AutocompleteMatchType::Type type, | 199 AutocompleteMatchType::Type type, |
| 189 const base::string16& description, | 200 const base::string16& description, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 bool is_keyword_result, | 304 bool is_keyword_result, |
| 294 Results* results); | 305 Results* results); |
| 295 | 306 |
| 296 private: | 307 private: |
| 297 FRIEND_TEST_ALL_PREFIXES(SearchSuggestionParser, | 308 FRIEND_TEST_ALL_PREFIXES(SearchSuggestionParser, |
| 298 GetAnswersImageURLsWithoutImagelines); | 309 GetAnswersImageURLsWithoutImagelines); |
| 299 FRIEND_TEST_ALL_PREFIXES(SearchSuggestionParser, | 310 FRIEND_TEST_ALL_PREFIXES(SearchSuggestionParser, |
| 300 GetAnswersImageURLsWithValidImage); | 311 GetAnswersImageURLsWithValidImage); |
| 301 | 312 |
| 302 // Gets URLs of any images in Answers results. | 313 // Gets URLs of any images in Answers results. |
| 303 static void GetAnswersImageURLs(const base::DictionaryValue* answer_json, | 314 static void GetAnswersImageURLs(const SuggestionAnswer& answer, |
| 304 std::vector<GURL>* urls); | 315 std::vector<GURL>* urls); |
| 305 | 316 |
| 306 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); | 317 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); |
| 307 }; | 318 }; |
| 308 | 319 |
| 309 #endif // COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ | 320 #endif // COMPONENTS_OMNIBOX_SEARCH_SUGGESTION_PARSER_H_ |
| OLD | NEW |