Commit e7a215a8 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Display masked password in the autofill drop-down.

The masked password is displayed for non-PSL and non-Android credentials now.
Later when the drop-down supports a bottom label, it'll be shown for all.

Bug: 851021
Change-Id: I491e7c24a58311c1250e8e89cddb9ccae95a9296
Reviewed-on: https://chromium-review.googlesource.com/1135325Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574879}
parent f1f40991
...@@ -45,6 +45,8 @@ namespace password_manager { ...@@ -45,6 +45,8 @@ namespace password_manager {
namespace { namespace {
constexpr base::char16 kPasswordReplacementChar = 0x2022;
// Returns |username| unless it is empty. For an empty |username| returns a // Returns |username| unless it is empty. For an empty |username| returns a
// localised string saying this username is empty. Use this for displaying the // localised string saying this username is empty. Use this for displaying the
// usernames to the user. // usernames to the user.
...@@ -82,13 +84,17 @@ void AppendSuggestionIfMatching( ...@@ -82,13 +84,17 @@ void AppendSuggestionIfMatching(
const std::string& signon_realm, const std::string& signon_realm,
bool show_all, bool show_all,
bool is_password_field, bool is_password_field,
size_t password_length,
std::vector<autofill::Suggestion>* suggestions) { std::vector<autofill::Suggestion>* suggestions) {
base::string16 lower_suggestion = base::i18n::ToLower(field_suggestion); base::string16 lower_suggestion = base::i18n::ToLower(field_suggestion);
base::string16 lower_contents = base::i18n::ToLower(field_contents); base::string16 lower_contents = base::i18n::ToLower(field_contents);
if (show_all || autofill::FieldIsSuggestionSubstringStartingOnTokenBoundary( if (show_all || autofill::FieldIsSuggestionSubstringStartingOnTokenBoundary(
lower_suggestion, lower_contents, true)) { lower_suggestion, lower_contents, true)) {
autofill::Suggestion suggestion(ReplaceEmptyUsername(field_suggestion)); autofill::Suggestion suggestion(ReplaceEmptyUsername(field_suggestion));
suggestion.label = GetHumanReadableRealm(signon_realm); suggestion.label =
signon_realm.empty()
? base::string16(password_length, kPasswordReplacementChar)
: GetHumanReadableRealm(signon_realm);
suggestion.frontend_id = is_password_field suggestion.frontend_id = is_password_field
? autofill::POPUP_ITEM_ID_PASSWORD_ENTRY ? autofill::POPUP_ITEM_ID_PASSWORD_ENTRY
: autofill::POPUP_ITEM_ID_USERNAME_ENTRY; : autofill::POPUP_ITEM_ID_USERNAME_ENTRY;
...@@ -111,14 +117,15 @@ void GetSuggestions(const autofill::PasswordFormFillData& fill_data, ...@@ -111,14 +117,15 @@ void GetSuggestions(const autofill::PasswordFormFillData& fill_data,
bool show_all, bool show_all,
bool is_password_field, bool is_password_field,
std::vector<autofill::Suggestion>* suggestions) { std::vector<autofill::Suggestion>* suggestions) {
AppendSuggestionIfMatching(fill_data.username_field.value, current_username, AppendSuggestionIfMatching(
fill_data.preferred_realm, show_all, fill_data.username_field.value, current_username,
is_password_field, suggestions); fill_data.preferred_realm, show_all, is_password_field,
fill_data.password_field.value.size(), suggestions);
for (const auto& login : fill_data.additional_logins) { for (const auto& login : fill_data.additional_logins) {
AppendSuggestionIfMatching(login.first, current_username, AppendSuggestionIfMatching(login.first, current_username,
login.second.realm, show_all, is_password_field, login.second.realm, show_all, is_password_field,
suggestions); login.second.password.size(), suggestions);
} }
// Prefix matches should precede other token matches. // Prefix matches should precede other token matches.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment