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

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

Issue 599273002: Revert of Revert of [AiS] Merge answers into highest-scoring result (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@top-hit
Patch Set: Created 6 years, 2 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 | « components/components_tests.gyp ('k') | components/omnibox/base_search_provider_unittest.cc » ('j') | 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 // This depends on the lower-ranking item always being added last - see
425 // use of push_back above.
426 AutocompleteMatch& more_relevant_match = i.first->second;
427 const AutocompleteMatch& less_relevant_match =
428 more_relevant_match.duplicate_matches.back();
429 if (!less_relevant_match.answer_type.empty() &&
430 more_relevant_match.answer_type.empty()) {
431 more_relevant_match.answer_type = less_relevant_match.answer_type;
432 more_relevant_match.answer_contents = less_relevant_match.answer_contents;
433 }
423 } 434 }
424 } 435 }
425 436
426 bool BaseSearchProvider::ParseSuggestResults( 437 bool BaseSearchProvider::ParseSuggestResults(
427 const base::Value& root_val, 438 const base::Value& root_val,
428 int default_result_relevance, 439 int default_result_relevance,
429 bool is_keyword_result, 440 bool is_keyword_result,
430 SearchSuggestionParser::Results* results) { 441 SearchSuggestionParser::Results* results) {
431 if (!SearchSuggestionParser::ParseSuggestResults( 442 if (!SearchSuggestionParser::ParseSuggestResults(
432 root_val, GetInput(is_keyword_result), 443 root_val, GetInput(is_keyword_result),
(...skipping 27 matching lines...) Expand all
460 } 471 }
461 472
462 void BaseSearchProvider::OnDeletionComplete( 473 void BaseSearchProvider::OnDeletionComplete(
463 bool success, SuggestionDeletionHandler* handler) { 474 bool success, SuggestionDeletionHandler* handler) {
464 RecordDeletionResult(success); 475 RecordDeletionResult(success);
465 SuggestionDeletionHandlers::iterator it = std::find( 476 SuggestionDeletionHandlers::iterator it = std::find(
466 deletion_handlers_.begin(), deletion_handlers_.end(), handler); 477 deletion_handlers_.begin(), deletion_handlers_.end(), handler);
467 DCHECK(it != deletion_handlers_.end()); 478 DCHECK(it != deletion_handlers_.end());
468 deletion_handlers_.erase(it); 479 deletion_handlers_.erase(it);
469 } 480 }
OLDNEW
« no previous file with comments | « components/components_tests.gyp ('k') | components/omnibox/base_search_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698