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

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

Issue 1233453011: Revert of Remove some legacy versions of StartsWith and EndsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/browser/search_suggestion_parser.h" 5 #include "components/omnibox/browser/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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 base::string16 lookup_text = input_text; 146 base::string16 lookup_text = input_text;
147 if (type_ == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { 147 if (type_ == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) {
148 const size_t contents_index = 148 const size_t contents_index =
149 suggestion_.length() - match_contents_.length(); 149 suggestion_.length() - match_contents_.length();
150 // Ensure the query starts with the input text, and ends with the match 150 // Ensure the query starts with the input text, and ends with the match
151 // contents, and the input text has an overlap with contents. 151 // contents, and the input text has an overlap with contents.
152 if (base::StartsWith(suggestion_, input_text, 152 if (base::StartsWith(suggestion_, input_text,
153 base::CompareCase::SENSITIVE) && 153 base::CompareCase::SENSITIVE) &&
154 base::EndsWith(suggestion_, match_contents_, 154 base::EndsWith(suggestion_, match_contents_, true) &&
155 base::CompareCase::SENSITIVE) &&
156 (input_text.length() > contents_index)) { 155 (input_text.length() > contents_index)) {
157 lookup_text = input_text.substr(contents_index); 156 lookup_text = input_text.substr(contents_index);
158 } 157 }
159 } 158 }
160 // Do a case-insensitive search for |lookup_text|. 159 // Do a case-insensitive search for |lookup_text|.
161 base::string16::const_iterator lookup_position = std::search( 160 base::string16::const_iterator lookup_position = std::search(
162 match_contents_.begin(), match_contents_.end(), lookup_text.begin(), 161 match_contents_.begin(), match_contents_.end(), lookup_text.begin(),
163 lookup_text.end(), SimpleCaseInsensitiveCompareUCS2()); 162 lookup_text.end(), SimpleCaseInsensitiveCompareUCS2());
164 if (!allow_bolding_all && (lookup_position == match_contents_.end())) { 163 if (!allow_bolding_all && (lookup_position == match_contents_.end())) {
165 // Bail if the code below to update the bolding would bold the whole 164 // Bail if the code below to update the bolding would bold the whole
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 base::CollapseWhitespace(suggestion, false), match_type, 536 base::CollapseWhitespace(suggestion, false), match_type,
538 base::CollapseWhitespace(match_contents, false), 537 base::CollapseWhitespace(match_contents, false),
539 match_contents_prefix, annotation, answer_contents, answer_type_str, 538 match_contents_prefix, annotation, answer_contents, answer_type_str,
540 answer.Pass(), suggest_query_params, deletion_url, is_keyword_result, 539 answer.Pass(), suggest_query_params, deletion_url, is_keyword_result,
541 relevance, relevances != NULL, should_prefetch, trimmed_input)); 540 relevance, relevances != NULL, should_prefetch, trimmed_input));
542 } 541 }
543 } 542 }
544 results->relevances_from_server = relevances != NULL; 543 results->relevances_from_server = relevances != NULL;
545 return true; 544 return true;
546 } 545 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/keyword_provider.cc ('k') | components/pairing/bluetooth_controller_pairing_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698