Chromium Code Reviews| Index: components/omnibox/browser/search_suggestion_parser.cc |
| diff --git a/components/omnibox/browser/search_suggestion_parser.cc b/components/omnibox/browser/search_suggestion_parser.cc |
| index 04e10a02ba461d6d5b8f60b09e06c229b207673a..b4be6c9a6fd46e2b759d245bfa23e5b9964f7832 100644 |
| --- a/components/omnibox/browser/search_suggestion_parser.cc |
| +++ b/components/omnibox/browser/search_suggestion_parser.cc |
| @@ -20,6 +20,7 @@ |
| #include "base/values.h" |
| #include "components/omnibox/browser/autocomplete_i18n.h" |
| #include "components/omnibox/browser/autocomplete_input.h" |
| +#include "components/omnibox/browser/omnibox_field_trial.h" |
| #include "components/omnibox/browser/url_prefix.h" |
| #include "components/url_formatter/url_fixer.h" |
| #include "components/url_formatter/url_formatter.h" |
| @@ -229,7 +230,8 @@ SearchSuggestionParser::NavigationResult::NavigationResult( |
| bool from_keyword_provider, |
| int relevance, |
| bool relevance_from_server, |
| - const base::string16& input_text) |
| + const base::string16& input_text, |
| + const std::string& zero_suggest_specific_type) |
| : Result(from_keyword_provider, |
| relevance, |
| relevance_from_server, |
| @@ -246,11 +248,14 @@ SearchSuggestionParser::NavigationResult::NavigationResult( |
| nullptr, |
| nullptr), |
| scheme_classifier)), |
| - description_(description) { |
| + description_(description), |
| + zero_suggest_specific_type_(zero_suggest_specific_type) { |
| DCHECK(url_.is_valid()); |
| CalculateAndClassifyMatchContents(true, input_text); |
| } |
| +SearchSuggestionParser::NavigationResult::NavigationResult( |
| + const NavigationResult& nav) = default; |
| SearchSuggestionParser::NavigationResult::~NavigationResult() {} |
| void |
| @@ -447,6 +452,13 @@ bool SearchSuggestionParser::ParseSuggestResults( |
| json_serializer.Serialize(*extras); |
| } |
| + // Get zero suggest subtypes. |
| + const base::ListValue* zero_suggest_subtypes = NULL; |
|
Mark P
2017/03/14 20:17:50
If we're getting stuff from the server, it should
gcomanici
2017/03/14 20:42:55
I agree. Although the server side puts this values
|
| + if (root_list->GetList(5, &zero_suggest_subtypes) && |
| + zero_suggest_subtypes->GetSize() != results_list->GetSize()) { |
| + zero_suggest_subtypes = NULL; |
| + } |
| + |
| // Clear the previous results now that new results are available. |
| results->suggest_results.clear(); |
| results->navigation_results.clear(); |
| @@ -486,9 +498,15 @@ bool SearchSuggestionParser::ParseSuggestResults( |
| base::string16 title; |
| if (descriptions != NULL) |
| descriptions->GetString(index, &title); |
| + // add zero suggest subtype |
| + std::string zero_suggest_specific_type; |
| + if (zero_suggest_subtypes) { |
| + zero_suggest_subtypes->GetString(index, &zero_suggest_specific_type); |
|
Mark P
2017/03/14 20:17:49
I'm curious: why do you have the server send down
gcomanici
2017/03/14 20:42:55
The short answer is that it makes it easy to use t
Mark P
2017/03/14 21:04:09
The elephant in the room here is that regardless o
gcomanici
2017/03/15 01:35:56
I would go with the latter proposal (i.e. use ints
|
| + } |
| results->navigation_results.push_back(NavigationResult( |
| scheme_classifier, url, match_type, title, deletion_url, |
| - is_keyword_result, relevance, relevances != NULL, input.text())); |
| + is_keyword_result, relevance, relevances != NULL, input.text(), |
| + zero_suggest_specific_type)); |
| } |
| } else { |
| // TODO(dschuyler) If the "= " is no longer sent from the back-end |