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

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

Issue 584653004: [AiS] Merge answers into highest-scoring result (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@top-hit
Patch Set: Created 6 years, 3 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/base_search_provider.h" 5 #include "components/omnibox/base_search_provider.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/metrics/proto/omnibox_event.pb.h" 10 #include "components/metrics/proto/omnibox_event.pb.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 // is sufficiently relevant that the user is likely to choose it. 413 // is sufficiently relevant that the user is likely to choose it.
414 // Surely setting the prefetch bit on a match of even higher relevance 414 // Surely setting the prefetch bit on a match of even higher relevance
415 // won't violate this assumption. 415 // won't violate this assumption.
416 should_prefetch |= ShouldPrefetch(i.first->second); 416 should_prefetch |= ShouldPrefetch(i.first->second);
417 i.first->second.RecordAdditionalInfo(kShouldPrefetchKey, 417 i.first->second.RecordAdditionalInfo(kShouldPrefetchKey,
418 should_prefetch ? kTrue : kFalse); 418 should_prefetch ? kTrue : kFalse);
419 if (should_prefetch) 419 if (should_prefetch)
420 i.first->second.RecordAdditionalInfo(kSuggestMetadataKey, metadata); 420 i.first->second.RecordAdditionalInfo(kSuggestMetadataKey, metadata);
421 } 421 }
422 } 422 }
423 // Copy over answer data from lower-ranking item, if necessary.
424 const AutocompleteMatch& less_relevant_match =
425 i.first->second.duplicate_matches.back();
Mark P 2014/09/19 18:56:38 This makes me a little nervous because you're depe
groby-ooo-7-16 2014/09/22 05:49:25 Comment added. I think it's fairly clear, but call
426 if (!less_relevant_match.answer_type.empty()) {
427 DCHECK(i.first->second.answer_type.empty());
Mark P 2014/09/19 18:56:38 Why is this true? Why can't multiple equivalent s
groby-ooo-7-16 2014/09/22 05:49:25 Because suggestions are only provided by the searc
428 i.first->second.answer_type = less_relevant_match.answer_type;
429 i.first->second.answer_contents = less_relevant_match.answer_contents;
430 }
423 } 431 }
424 } 432 }
425 433
426 bool BaseSearchProvider::ParseSuggestResults( 434 bool BaseSearchProvider::ParseSuggestResults(
427 const base::Value& root_val, 435 const base::Value& root_val,
428 int default_result_relevance, 436 int default_result_relevance,
429 bool is_keyword_result, 437 bool is_keyword_result,
430 SearchSuggestionParser::Results* results) { 438 SearchSuggestionParser::Results* results) {
431 if (!SearchSuggestionParser::ParseSuggestResults( 439 if (!SearchSuggestionParser::ParseSuggestResults(
432 root_val, GetInput(is_keyword_result), 440 root_val, GetInput(is_keyword_result),
(...skipping 27 matching lines...) Expand all
460 } 468 }
461 469
462 void BaseSearchProvider::OnDeletionComplete( 470 void BaseSearchProvider::OnDeletionComplete(
463 bool success, SuggestionDeletionHandler* handler) { 471 bool success, SuggestionDeletionHandler* handler) {
464 RecordDeletionResult(success); 472 RecordDeletionResult(success);
465 SuggestionDeletionHandlers::iterator it = std::find( 473 SuggestionDeletionHandlers::iterator it = std::find(
466 deletion_handlers_.begin(), deletion_handlers_.end(), handler); 474 deletion_handlers_.begin(), deletion_handlers_.end(), handler);
467 DCHECK(it != deletion_handlers_.end()); 475 DCHECK(it != deletion_handlers_.end());
468 deletion_handlers_.erase(it); 476 deletion_handlers_.erase(it);
469 } 477 }
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