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

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

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grt's review comments, Mac fix Created 5 years, 5 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/omnibox/base_search_provider.cc ('k') | components/omnibox/suggestion_answer.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/search_suggestion_parser.h" 5 #include "components/omnibox/search_suggestion_parser.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/icu_string_conversions.h" 9 #include "base/i18n/icu_string_conversions.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 ACMatchClassification(0, ACMatchClassification::NONE)); 141 ACMatchClassification(0, ACMatchClassification::NONE));
142 return; 142 return;
143 } 143 }
144 144
145 base::string16 lookup_text = input_text; 145 base::string16 lookup_text = input_text;
146 if (type_ == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { 146 if (type_ == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) {
147 const size_t contents_index = 147 const size_t contents_index =
148 suggestion_.length() - match_contents_.length(); 148 suggestion_.length() - match_contents_.length();
149 // Ensure the query starts with the input text, and ends with the match 149 // Ensure the query starts with the input text, and ends with the match
150 // contents, and the input text has an overlap with contents. 150 // contents, and the input text has an overlap with contents.
151 if (base::StartsWith(suggestion_, input_text, true) && 151 if (base::StartsWith(suggestion_, input_text,
152 base::CompareCase::SENSITIVE) &&
152 base::EndsWith(suggestion_, match_contents_, true) && 153 base::EndsWith(suggestion_, match_contents_, true) &&
153 (input_text.length() > contents_index)) { 154 (input_text.length() > contents_index)) {
154 lookup_text = input_text.substr(contents_index); 155 lookup_text = input_text.substr(contents_index);
155 } 156 }
156 } 157 }
157 // Do a case-insensitive search for |lookup_text|. 158 // Do a case-insensitive search for |lookup_text|.
158 base::string16::const_iterator lookup_position = std::search( 159 base::string16::const_iterator lookup_position = std::search(
159 match_contents_.begin(), match_contents_.end(), lookup_text.begin(), 160 match_contents_.begin(), match_contents_.end(), lookup_text.begin(),
160 lookup_text.end(), base::CaseInsensitiveCompare<base::char16>()); 161 lookup_text.end(), base::CaseInsensitiveCompare<base::char16>());
161 if (!allow_bolding_all && (lookup_position == match_contents_.end())) { 162 if (!allow_bolding_all && (lookup_position == match_contents_.end())) {
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 base::CollapseWhitespace(suggestion, false), match_type, 535 base::CollapseWhitespace(suggestion, false), match_type,
535 base::CollapseWhitespace(match_contents, false), 536 base::CollapseWhitespace(match_contents, false),
536 match_contents_prefix, annotation, answer_contents, answer_type_str, 537 match_contents_prefix, annotation, answer_contents, answer_type_str,
537 answer.Pass(), suggest_query_params, deletion_url, is_keyword_result, 538 answer.Pass(), suggest_query_params, deletion_url, is_keyword_result,
538 relevance, relevances != NULL, should_prefetch, trimmed_input)); 539 relevance, relevances != NULL, should_prefetch, trimmed_input));
539 } 540 }
540 } 541 }
541 results->relevances_from_server = relevances != NULL; 542 results->relevances_from_server = relevances != NULL;
542 return true; 543 return true;
543 } 544 }
OLDNEW
« no previous file with comments | « components/omnibox/base_search_provider.cc ('k') | components/omnibox/suggestion_answer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698