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/browser/search_suggestion_parser.h" | 5 #include "components/omnibox/browser/search_suggestion_parser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 suggestion_detail->GetString("q", &suggest_query_params); | 517 suggestion_detail->GetString("q", &suggest_query_params); |
518 | 518 |
519 // Extract the Answer, if provided. | 519 // Extract the Answer, if provided. |
520 const base::DictionaryValue* answer_json = NULL; | 520 const base::DictionaryValue* answer_json = NULL; |
521 if (suggestion_detail->GetDictionary("ansa", &answer_json) && | 521 if (suggestion_detail->GetDictionary("ansa", &answer_json) && |
522 suggestion_detail->GetString("ansb", &answer_type_str)) { | 522 suggestion_detail->GetString("ansb", &answer_type_str)) { |
523 bool answer_parsed_successfully = false; | 523 bool answer_parsed_successfully = false; |
524 answer = SuggestionAnswer::ParseAnswer(answer_json); | 524 answer = SuggestionAnswer::ParseAnswer(answer_json); |
525 int answer_type = 0; | 525 int answer_type = 0; |
526 if (answer && base::StringToInt(answer_type_str, &answer_type)) { | 526 if (answer && base::StringToInt(answer_type_str, &answer_type)) { |
| 527 UMA_HISTOGRAM_SPARSE_SLOWLY("Omnibox.AnswerParseType", |
| 528 answer_type); |
527 answer_parsed_successfully = true; | 529 answer_parsed_successfully = true; |
528 | 530 |
529 answer->set_type(answer_type); | 531 answer->set_type(answer_type); |
530 answer->AddImageURLsTo(&results->answers_image_urls); | 532 answer->AddImageURLsTo(&results->answers_image_urls); |
531 | 533 |
532 std::string contents; | 534 std::string contents; |
533 base::JSONWriter::Write(*answer_json, &contents); | 535 base::JSONWriter::Write(*answer_json, &contents); |
534 answer_contents = base::UTF8ToUTF16(contents); | 536 answer_contents = base::UTF8ToUTF16(contents); |
535 } else { | 537 } else { |
536 answer_type_str = base::string16(); | 538 answer_type_str = base::string16(); |
(...skipping 10 matching lines...) Expand all Loading... |
547 base::CollapseWhitespace(match_contents, false), | 549 base::CollapseWhitespace(match_contents, false), |
548 match_contents_prefix, annotation, answer_contents, answer_type_str, | 550 match_contents_prefix, annotation, answer_contents, answer_type_str, |
549 std::move(answer), suggest_query_params, deletion_url, | 551 std::move(answer), suggest_query_params, deletion_url, |
550 is_keyword_result, relevance, relevances != NULL, should_prefetch, | 552 is_keyword_result, relevance, relevances != NULL, should_prefetch, |
551 trimmed_input)); | 553 trimmed_input)); |
552 } | 554 } |
553 } | 555 } |
554 results->relevances_from_server = relevances != NULL; | 556 results->relevances_from_server = relevances != NULL; |
555 return true; | 557 return true; |
556 } | 558 } |
OLD | NEW |