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

Unified Diff: components/password_manager/core/browser/password_autofill_manager.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
« no previous file with comments | « components/omnibox/url_prefix.cc ('k') | components/policy/core/common/preg_parser_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/password_autofill_manager.cc
diff --git a/components/password_manager/core/browser/password_autofill_manager.cc b/components/password_manager/core/browser/password_autofill_manager.cc
index a7a71085d9f864199eab2892a8f79ac65636e17c..d0af2753521c2951c6164c0dd33110bc72359fba 100644
--- a/components/password_manager/core/browser/password_autofill_manager.cc
+++ b/components/password_manager/core/browser/password_autofill_manager.cc
@@ -6,6 +6,7 @@
#include <vector>
+#include "base/i18n/case_conversion.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string16.h"
@@ -66,8 +67,11 @@ void GetSuggestions(const autofill::PasswordFormFillData& fill_data,
const base::string16& current_username,
std::vector<autofill::Suggestion>* suggestions,
bool show_all) {
- if (show_all || base::StartsWith(fill_data.username_field.value,
- current_username, false)) {
+ base::string16 lower_username = base::i18n::ToLower(current_username);
+
+ if (show_all ||
+ base::StartsWith(base::i18n::ToLower(fill_data.username_field.value),
+ lower_username, base::CompareCase::SENSITIVE)) {
autofill::Suggestion suggestion(
ReplaceEmptyUsername(fill_data.username_field.value));
suggestion.label = GetHumanReadableRealm(fill_data.preferred_realm);
@@ -76,7 +80,9 @@ void GetSuggestions(const autofill::PasswordFormFillData& fill_data,
}
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), lower_username,
+ base::CompareCase::SENSITIVE)) {
autofill::Suggestion suggestion(ReplaceEmptyUsername(login.first));
suggestion.label = GetHumanReadableRealm(login.second.realm);
suggestion.frontend_id = autofill::POPUP_ITEM_ID_PASSWORD_ENTRY;
@@ -87,7 +93,8 @@ void GetSuggestions(const autofill::PasswordFormFillData& fill_data,
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(usernames.second[i]),
+ lower_username, base::CompareCase::SENSITIVE)) {
autofill::Suggestion suggestion(
ReplaceEmptyUsername(usernames.second[i]));
suggestion.label = GetHumanReadableRealm(usernames.first.realm);
« no previous file with comments | « components/omnibox/url_prefix.cc ('k') | components/policy/core/common/preg_parser_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698