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

Unified Diff: components/autofill/content/renderer/password_autofill_agent.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, 6 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
Index: components/autofill/content/renderer/password_autofill_agent.cc
diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc
index f0dcefd80475482fc096bf1c14839fd18cab75d4..9999d26e2c38dbc120a14996b5593fa49264096f 100644
--- a/components/autofill/content/renderer/password_autofill_agent.cc
+++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/i18n/case_conversion.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/field_trial.h"
@@ -225,7 +226,7 @@ bool DoUsernamesMatch(const base::string16& username1,
bool exact_match) {
if (exact_match)
return username1 == username2;
- return base::StartsWith(username1, username2, true);
+ return base::StartsWith(username1, username2, base::CompareCase::SENSITIVE);
}
// Returns |true| if the given element is editable. Otherwise, returns |false|.
@@ -284,25 +285,32 @@ bool GetSuggestionsStats(const PasswordFormFillData& fill_data,
bool show_all,
bool* suggestions_present) {
*suggestions_present = false;
+ base::string16 current_username_lower = base::i18n::ToLower(current_username);
for (const auto& usernames : fill_data.other_possible_usernames) {
for (size_t i = 0; i < usernames.second.size(); ++i) {
if (show_all ||
- base::StartsWith(usernames.second[i], current_username, false)) {
+ base::StartsWith(
+ base::i18n::ToLower(base::string16(usernames.second[i])),
+ current_username_lower, base::CompareCase::SENSITIVE)) {
*suggestions_present = true;
return true;
}
}
}
- if (show_all || base::StartsWith(fill_data.username_field.value,
- current_username, false)) {
+ if (show_all ||
+ base::StartsWith(base::i18n::ToLower(fill_data.username_field.value),
+ current_username_lower, base::CompareCase::SENSITIVE)) {
*suggestions_present = true;
return false;
}
for (const auto& login : fill_data.additional_logins) {
- if (show_all || base::StartsWith(login.first, current_username, false)) {
+ if (show_all ||
+ base::StartsWith(base::i18n::ToLower(login.first),
+ current_username_lower,
+ base::CompareCase::SENSITIVE)) {
*suggestions_present = true;
return false;
}

Powered by Google App Engine
This is Rietveld 408576698