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

Unified Diff: chrome/browser/instant/instant_controller.cc

Issue 10949016: Fix case handling in Instant suggestions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebaseline Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/instant/instant_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/instant/instant_controller.cc
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 9ce64f47587ab8038c720ec95c2487f2f4b17662..6b2c0a7e999d262a66c1793f0c6d785c78bd0498 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -509,13 +509,23 @@ void InstantController::SetSuggestions(
last_match_was_search_ = suggestion.type == INSTANT_SUGGESTION_SEARCH;
delegate_->SetSuggestedText(suggestion.text, suggestion.behavior);
} else {
- string16 suggestion_lower = base::i18n::ToLower(suggestion.text);
- string16 user_text_lower = base::i18n::ToLower(last_user_text_);
- if (user_text_lower.size() >= suggestion_lower.size() ||
- suggestion_lower.compare(0, user_text_lower.size(), user_text_lower))
- suggestion.text.clear();
- else
+ // Match case-sensitively first, to preserve suggestion case if possible.
+ // If that fails, match case-insensitively. http://crbug.com/150728
+ if (last_user_text_.size() < suggestion.text.size() &&
+ !suggestion.text.compare(0, last_user_text_.size(), last_user_text_)) {
suggestion.text.erase(0, last_user_text_.size());
+ } else {
+ string16 suggestion_lower = base::i18n::ToLower(suggestion.text);
+ string16 user_text_lower = base::i18n::ToLower(last_user_text_);
+ if (user_text_lower.size() < suggestion_lower.size() &&
+ !suggestion_lower.compare(0, user_text_lower.size(),
+ user_text_lower)) {
+ suggestion.text.assign(suggestion_lower, user_text_lower.size(),
+ suggestion_lower.size() - user_text_lower.size());
+ } else {
+ suggestion.text.clear();
+ }
+ }
last_suggestion_ = suggestion;
if (!last_verbatim_)
« no previous file with comments | « chrome/browser/instant/instant_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698