Chromium Code Reviews| 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_BROWSER_SEARCH_SUGGESTION_PARSER_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_ |
| 6 #define COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 class NavigationResult : public Result { | 194 class NavigationResult : public Result { |
| 195 public: | 195 public: |
| 196 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier, | 196 NavigationResult(const AutocompleteSchemeClassifier& scheme_classifier, |
| 197 const GURL& url, | 197 const GURL& url, |
| 198 AutocompleteMatchType::Type type, | 198 AutocompleteMatchType::Type type, |
| 199 const base::string16& description, | 199 const base::string16& description, |
| 200 const std::string& deletion_url, | 200 const std::string& deletion_url, |
| 201 bool from_keyword_provider, | 201 bool from_keyword_provider, |
| 202 int relevance, | 202 int relevance, |
| 203 bool relevance_from_server, | 203 bool relevance_from_server, |
| 204 const base::string16& input_text); | 204 const base::string16& input_text, |
| 205 int specific_type_identifier); | |
|
Mark P
2017/03/21 19:54:25
Please hoist this logic up to SuggestResult. Ther
gcomanici
2017/03/22 02:39:03
Done.
| |
| 206 NavigationResult(const NavigationResult& nav); | |
|
Mark P
2017/03/21 19:54:25
Curious: why do you need to add a copy constructor
gcomanici
2017/03/22 02:39:03
I removed it. It was there because the compiler wa
| |
| 205 ~NavigationResult() override; | 207 ~NavigationResult() override; |
| 206 | 208 |
| 207 const GURL& url() const { return url_; } | 209 const GURL& url() const { return url_; } |
| 208 const base::string16& description() const { return description_; } | 210 const base::string16& description() const { return description_; } |
| 209 const base::string16& formatted_url() const { return formatted_url_; } | 211 const base::string16& formatted_url() const { return formatted_url_; } |
| 212 int specific_type_identifier() const { return specific_type_identifier_; } | |
| 210 | 213 |
| 211 // Fills in |match_contents_| and |match_contents_class_| to reflect how | 214 // Fills in |match_contents_| and |match_contents_class_| to reflect how |
| 212 // the URL should be displayed and bolded against the current |input_text|. | 215 // the URL should be displayed and bolded against the current |input_text|. |
| 213 // If |allow_bolding_nothing| is false and |match_contents_class_| would | 216 // If |allow_bolding_nothing| is false and |match_contents_class_| would |
| 214 // result in an entirely unbolded |match_contents_|, do nothing. | 217 // result in an entirely unbolded |match_contents_|, do nothing. |
| 215 void CalculateAndClassifyMatchContents(const bool allow_bolding_nothing, | 218 void CalculateAndClassifyMatchContents(const bool allow_bolding_nothing, |
| 216 const base::string16& input_text); | 219 const base::string16& input_text); |
| 217 | 220 |
| 218 // Result: | 221 // Result: |
| 219 int CalculateRelevance(const AutocompleteInput& input, | 222 int CalculateRelevance(const AutocompleteInput& input, |
| 220 bool keyword_provider_requested) const override; | 223 bool keyword_provider_requested) const override; |
| 221 | 224 |
| 222 private: | 225 private: |
| 223 // The suggested url for navigation. | 226 // The suggested url for navigation. |
| 224 GURL url_; | 227 GURL url_; |
| 225 | 228 |
| 226 // The properly formatted ("fixed up") URL string with equivalent meaning | 229 // The properly formatted ("fixed up") URL string with equivalent meaning |
| 227 // to the one in |url_|. | 230 // to the one in |url_|. |
| 228 base::string16 formatted_url_; | 231 base::string16 formatted_url_; |
| 229 | 232 |
| 230 // The suggested navigational result description; generally the site name. | 233 // The suggested navigational result description; generally the site name. |
| 231 base::string16 description_; | 234 base::string16 description_; |
| 235 | |
| 236 // Used to identify the specific source / type of suggestion for suggestions | |
| 237 // provided by the suggest server. For meaning of individual values, see | |
| 238 // the server-side enum. | |
| 239 int specific_type_identifier_; | |
| 232 }; | 240 }; |
| 233 | 241 |
| 234 typedef std::vector<SuggestResult> SuggestResults; | 242 typedef std::vector<SuggestResult> SuggestResults; |
| 235 typedef std::vector<NavigationResult> NavigationResults; | 243 typedef std::vector<NavigationResult> NavigationResults; |
| 236 | 244 |
| 237 // A simple structure bundling most of the information (including | 245 // A simple structure bundling most of the information (including |
| 238 // both SuggestResults and NavigationResults) returned by a call to | 246 // both SuggestResults and NavigationResults) returned by a call to |
| 239 // the suggest server. | 247 // the suggest server. |
| 240 // | 248 // |
| 241 // This has to be declared after the typedefs since it relies on some of them. | 249 // This has to be declared after the typedefs since it relies on some of them. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 const AutocompleteSchemeClassifier& scheme_classifier, | 305 const AutocompleteSchemeClassifier& scheme_classifier, |
| 298 int default_result_relevance, | 306 int default_result_relevance, |
| 299 bool is_keyword_result, | 307 bool is_keyword_result, |
| 300 Results* results); | 308 Results* results); |
| 301 | 309 |
| 302 private: | 310 private: |
| 303 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); | 311 DISALLOW_COPY_AND_ASSIGN(SearchSuggestionParser); |
| 304 }; | 312 }; |
| 305 | 313 |
| 306 #endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_ | 314 #endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_SUGGESTION_PARSER_H_ |
| OLD | NEW |