| 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 #include "components/omnibox/search_suggestion_parser.h" | 5 #include "components/omnibox/search_suggestion_parser.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/icu_string_conversions.h" | 9 #include "base/i18n/icu_string_conversions.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 bool answer_parsed_successfully = false; | 511 bool answer_parsed_successfully = false; |
| 512 answer = SuggestionAnswer::ParseAnswer(answer_json); | 512 answer = SuggestionAnswer::ParseAnswer(answer_json); |
| 513 int answer_type = 0; | 513 int answer_type = 0; |
| 514 if (answer && base::StringToInt(answer_type_str, &answer_type)) { | 514 if (answer && base::StringToInt(answer_type_str, &answer_type)) { |
| 515 answer_parsed_successfully = true; | 515 answer_parsed_successfully = true; |
| 516 | 516 |
| 517 answer->set_type(answer_type); | 517 answer->set_type(answer_type); |
| 518 answer->AddImageURLsTo(&results->answers_image_urls); | 518 answer->AddImageURLsTo(&results->answers_image_urls); |
| 519 | 519 |
| 520 std::string contents; | 520 std::string contents; |
| 521 base::JSONWriter::Write(answer_json, &contents); | 521 base::JSONWriter::Write(*answer_json, &contents); |
| 522 answer_contents = base::UTF8ToUTF16(contents); | 522 answer_contents = base::UTF8ToUTF16(contents); |
| 523 } else { | 523 } else { |
| 524 answer_type_str = base::string16(); | 524 answer_type_str = base::string16(); |
| 525 } | 525 } |
| 526 UMA_HISTOGRAM_BOOLEAN("Omnibox.AnswerParseSuccess", | 526 UMA_HISTOGRAM_BOOLEAN("Omnibox.AnswerParseSuccess", |
| 527 answer_parsed_successfully); | 527 answer_parsed_successfully); |
| 528 } | 528 } |
| 529 } | 529 } |
| 530 } | 530 } |
| 531 | 531 |
| 532 bool should_prefetch = static_cast<int>(index) == prefetch_index; | 532 bool should_prefetch = static_cast<int>(index) == prefetch_index; |
| 533 results->suggest_results.push_back(SuggestResult( | 533 results->suggest_results.push_back(SuggestResult( |
| 534 base::CollapseWhitespace(suggestion, false), match_type, | 534 base::CollapseWhitespace(suggestion, false), match_type, |
| 535 base::CollapseWhitespace(match_contents, false), | 535 base::CollapseWhitespace(match_contents, false), |
| 536 match_contents_prefix, annotation, answer_contents, answer_type_str, | 536 match_contents_prefix, annotation, answer_contents, answer_type_str, |
| 537 answer.Pass(), suggest_query_params, deletion_url, is_keyword_result, | 537 answer.Pass(), suggest_query_params, deletion_url, is_keyword_result, |
| 538 relevance, relevances != NULL, should_prefetch, trimmed_input)); | 538 relevance, relevances != NULL, should_prefetch, trimmed_input)); |
| 539 } | 539 } |
| 540 } | 540 } |
| 541 results->relevances_from_server = relevances != NULL; | 541 results->relevances_from_server = relevances != NULL; |
| 542 return true; | 542 return true; |
| 543 } | 543 } |
| OLD | NEW |