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/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 Loading... | |
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 const AutocompleteMatch& less_relevant_match = | |
427 i.first->second.duplicate_matches.back(); | |
428 if (!less_relevant_match.answer_type.empty()) { | |
429 DCHECK(i.first->second.answer_type.empty()); | |
Mark P
2014/09/22 23:54:06
We try to make Chrome work well even when a sugges
groby-ooo-7-16
2014/09/23 03:34:00
Since it's a DCHECK. It'll never trigger outside o
Mark P
2014/09/23 16:26:41
Here are three ideas:
(1) server side monitoring
(
| |
430 i.first->second.answer_type = less_relevant_match.answer_type; | |
431 i.first->second.answer_contents = less_relevant_match.answer_contents; | |
432 } | |
423 } | 433 } |
424 } | 434 } |
425 | 435 |
426 bool BaseSearchProvider::ParseSuggestResults( | 436 bool BaseSearchProvider::ParseSuggestResults( |
427 const base::Value& root_val, | 437 const base::Value& root_val, |
428 int default_result_relevance, | 438 int default_result_relevance, |
429 bool is_keyword_result, | 439 bool is_keyword_result, |
430 SearchSuggestionParser::Results* results) { | 440 SearchSuggestionParser::Results* results) { |
431 if (!SearchSuggestionParser::ParseSuggestResults( | 441 if (!SearchSuggestionParser::ParseSuggestResults( |
432 root_val, GetInput(is_keyword_result), | 442 root_val, GetInput(is_keyword_result), |
(...skipping 27 matching lines...) Expand all Loading... | |
460 } | 470 } |
461 | 471 |
462 void BaseSearchProvider::OnDeletionComplete( | 472 void BaseSearchProvider::OnDeletionComplete( |
463 bool success, SuggestionDeletionHandler* handler) { | 473 bool success, SuggestionDeletionHandler* handler) { |
464 RecordDeletionResult(success); | 474 RecordDeletionResult(success); |
465 SuggestionDeletionHandlers::iterator it = std::find( | 475 SuggestionDeletionHandlers::iterator it = std::find( |
466 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 476 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
467 DCHECK(it != deletion_handlers_.end()); | 477 DCHECK(it != deletion_handlers_.end()); |
468 deletion_handlers_.erase(it); | 478 deletion_handlers_.erase(it); |
469 } | 479 } |
OLD | NEW |