Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: components/omnibox/search_suggestion_parser.cc

Issue 832943002: Don't set suggestion type to SEARCH_SUGGEST_ANSWER on search responses with Answers attached (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/i18n/icu_string_conversions.h" 7 #include "base/i18n/icu_string_conversions.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 493
494 // Extract the Answer, if provided. 494 // Extract the Answer, if provided.
495 const base::DictionaryValue* answer_json = NULL; 495 const base::DictionaryValue* answer_json = NULL;
496 if (suggestion_detail->GetDictionary("ansa", &answer_json) && 496 if (suggestion_detail->GetDictionary("ansa", &answer_json) &&
497 suggestion_detail->GetString("ansb", &answer_type_str)) { 497 suggestion_detail->GetString("ansb", &answer_type_str)) {
498 bool answer_parsed_successfully = false; 498 bool answer_parsed_successfully = false;
499 answer = SuggestionAnswer::ParseAnswer(answer_json); 499 answer = SuggestionAnswer::ParseAnswer(answer_json);
500 int answer_type = 0; 500 int answer_type = 0;
501 if (answer && base::StringToInt(answer_type_str, &answer_type)) { 501 if (answer && base::StringToInt(answer_type_str, &answer_type)) {
502 answer_parsed_successfully = true; 502 answer_parsed_successfully = true;
503 match_type = AutocompleteMatchType::SEARCH_SUGGEST_ANSWER;
504 503
505 answer->set_type(answer_type); 504 answer->set_type(answer_type);
506 answer->AddImageURLsTo(&results->answers_image_urls); 505 answer->AddImageURLsTo(&results->answers_image_urls);
507 506
508 std::string contents; 507 std::string contents;
509 base::JSONWriter::Write(answer_json, &contents); 508 base::JSONWriter::Write(answer_json, &contents);
510 answer_contents = base::UTF8ToUTF16(contents); 509 answer_contents = base::UTF8ToUTF16(contents);
511 } else { 510 } else {
512 answer_type_str = base::string16(); 511 answer_type_str = base::string16();
513 } 512 }
514 UMA_HISTOGRAM_BOOLEAN("Omnibox.AnswerParseSuccess", 513 UMA_HISTOGRAM_BOOLEAN("Omnibox.AnswerParseSuccess",
515 answer_parsed_successfully); 514 answer_parsed_successfully);
516 } 515 }
517 } 516 }
518 } 517 }
519 518
520 bool should_prefetch = static_cast<int>(index) == prefetch_index; 519 bool should_prefetch = static_cast<int>(index) == prefetch_index;
521 // TODO(kochi): Improve calculator suggestion presentation. 520 // TODO(kochi): Improve calculator suggestion presentation.
522 results->suggest_results.push_back(SuggestResult( 521 results->suggest_results.push_back(SuggestResult(
523 base::CollapseWhitespace(suggestion, false), match_type, 522 base::CollapseWhitespace(suggestion, false), match_type,
524 base::CollapseWhitespace(match_contents, false), 523 base::CollapseWhitespace(match_contents, false),
525 match_contents_prefix, annotation, answer_contents, answer_type_str, 524 match_contents_prefix, annotation, answer_contents, answer_type_str,
526 answer.Pass(), suggest_query_params, deletion_url, is_keyword_result, 525 answer.Pass(), suggest_query_params, deletion_url, is_keyword_result,
527 relevance, relevances != NULL, should_prefetch, trimmed_input)); 526 relevance, relevances != NULL, should_prefetch, trimmed_input));
528 } 527 }
529 } 528 }
530 results->relevances_from_server = relevances != NULL; 529 results->relevances_from_server = relevances != NULL;
531 return true; 530 return true;
532 } 531 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698