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

Side by Side Diff: components/omnibox/browser/search_provider.cc

Issue 1543803004: Compare case insensitively when copying answers into verbatim matches. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce trimmed_verbatim_lower variable Created 4 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/browser/search_provider.h" 5 #include "components/omnibox/browser/search_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 if (verbatim_relevance > 0) { 919 if (verbatim_relevance > 0) {
920 const base::string16& trimmed_verbatim = 920 const base::string16& trimmed_verbatim =
921 base::CollapseWhitespace(input_.text(), false); 921 base::CollapseWhitespace(input_.text(), false);
922 922
923 // Verbatim results don't get suggestions and hence, answers. 923 // Verbatim results don't get suggestions and hence, answers.
924 // Scan previous matches if the last answer-bearing suggestion matches 924 // Scan previous matches if the last answer-bearing suggestion matches
925 // verbatim, and if so, copy over answer contents. 925 // verbatim, and if so, copy over answer contents.
926 base::string16 answer_contents; 926 base::string16 answer_contents;
927 base::string16 answer_type; 927 base::string16 answer_type;
928 scoped_ptr<SuggestionAnswer> answer; 928 scoped_ptr<SuggestionAnswer> answer;
929 base::string16 trimmed_verbatim_lower =
930 base::i18n::ToLower(trimmed_verbatim);
929 for (ACMatches::iterator it = matches_.begin(); it != matches_.end(); 931 for (ACMatches::iterator it = matches_.begin(); it != matches_.end();
930 ++it) { 932 ++it) {
931 if (it->answer && it->fill_into_edit == trimmed_verbatim) { 933 if (it->answer &&
934 base::i18n::ToLower(it->fill_into_edit) == trimmed_verbatim_lower) {
932 answer_contents = it->answer_contents; 935 answer_contents = it->answer_contents;
933 answer_type = it->answer_type; 936 answer_type = it->answer_type;
934 answer = SuggestionAnswer::copy(it->answer.get()); 937 answer = SuggestionAnswer::copy(it->answer.get());
935 break; 938 break;
936 } 939 }
937 } 940 }
938 941
939 SearchSuggestionParser::SuggestResult verbatim( 942 SearchSuggestionParser::SuggestResult verbatim(
940 trimmed_verbatim, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, 943 trimmed_verbatim, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED,
941 trimmed_verbatim, base::string16(), base::string16(), answer_contents, 944 trimmed_verbatim, base::string16(), base::string16(), answer_contents,
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) 1506 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i)
1504 matches.push_back(i->second); 1507 matches.push_back(i->second);
1505 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); 1508 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant);
1506 1509
1507 // If there is a top scoring entry, find the corresponding answer. 1510 // If there is a top scoring entry, find the corresponding answer.
1508 if (!matches.empty()) 1511 if (!matches.empty())
1509 return answers_cache_.GetTopAnswerEntry(matches[0].contents); 1512 return answers_cache_.GetTopAnswerEntry(matches[0].contents);
1510 1513
1511 return AnswersQueryData(); 1514 return AnswersQueryData();
1512 } 1515 }
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