OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 | 709 |
710 // Search results don't look like URLs. | 710 // Search results don't look like URLs. |
711 match.transition = | 711 match.transition = |
712 is_keyword ? PageTransition::KEYWORD : PageTransition::GENERATED; | 712 is_keyword ? PageTransition::KEYWORD : PageTransition::GENERATED; |
713 | 713 |
714 // Try to add |match| to |map|. If a match for |query_string| is already in | 714 // Try to add |match| to |map|. If a match for |query_string| is already in |
715 // |map|, replace it if |match| is more relevant. | 715 // |map|, replace it if |match| is more relevant. |
716 // NOTE: Keep this ToLower() call in sync with url_database.cc. | 716 // NOTE: Keep this ToLower() call in sync with url_database.cc. |
717 const std::pair<MatchMap::iterator, bool> i = map->insert( | 717 const std::pair<MatchMap::iterator, bool> i = map->insert( |
718 std::pair<std::wstring, AutocompleteMatch>( | 718 std::pair<std::wstring, AutocompleteMatch>( |
719 l10n_util::ToLower(query_string), match)); | 719 UTF16ToWide(l10n_util::ToLower(WideToUTF16(query_string))), match)); |
720 // NOTE: We purposefully do a direct relevance comparison here instead of | 720 // NOTE: We purposefully do a direct relevance comparison here instead of |
721 // using AutocompleteMatch::MoreRelevant(), so that we'll prefer "items added | 721 // using AutocompleteMatch::MoreRelevant(), so that we'll prefer "items added |
722 // first" rather than "items alphabetically first" when the scores are equal. | 722 // first" rather than "items alphabetically first" when the scores are equal. |
723 // The only case this matters is when a user has results with the same score | 723 // The only case this matters is when a user has results with the same score |
724 // that differ only by capitalization; because the history system returns | 724 // that differ only by capitalization; because the history system returns |
725 // results sorted by recency, this means we'll pick the most recent such | 725 // results sorted by recency, this means we'll pick the most recent such |
726 // result even if the precision of our relevance score is too low to | 726 // result even if the precision of our relevance score is too low to |
727 // distinguish the two. | 727 // distinguish the two. |
728 if (!i.second && (match.relevance > i.first->second.relevance)) | 728 if (!i.second && (match.relevance > i.first->second.relevance)) |
729 i.first->second = match; | 729 i.first->second = match; |
(...skipping 25 matching lines...) Expand all Loading... |
755 if (input_.type() == AutocompleteInput::FORCED_QUERY) | 755 if (input_.type() == AutocompleteInput::FORCED_QUERY) |
756 match.fill_into_edit.assign(L"?"); | 756 match.fill_into_edit.assign(L"?"); |
757 match.fill_into_edit.append( | 757 match.fill_into_edit.append( |
758 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url, | 758 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url, |
759 match.contents)); | 759 match.contents)); |
760 // TODO(pkasting): http://b/1112879 These should perhaps be | 760 // TODO(pkasting): http://b/1112879 These should perhaps be |
761 // inline-autocompletable? | 761 // inline-autocompletable? |
762 | 762 |
763 return match; | 763 return match; |
764 } | 764 } |
OLD | NEW |