Commit efe8e2cb authored by Reda Tawfik's avatar Reda Tawfik Committed by Commit Bot

[Android][Mfill] Skip the warning dialog for username field

This CL changes the text of "User other password" to
"User other username" if the user is about to fill a username field.
Skips the warning dialog and show the bottom sheet immediately if the
user is about to fill a username field.

Bug: 1104132
Change-Id: Ife3c835cc9a7742c862bd4d71942472cc4686a7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425051
Commit-Queue: Reda Tawfik <redatawfik@google.com>
Reviewed-by: default avatarIoana Pandele <ioanap@chromium.org>
Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811202}
parent 761228e4
...@@ -74,7 +74,12 @@ class AllPasswordsBottomSheetMediator implements ModalDialogProperties.Controlle ...@@ -74,7 +74,12 @@ class AllPasswordsBottomSheetMediator implements ModalDialogProperties.Controlle
} }
void warnAndShow() { void warnAndShow() {
mModalDialogManager.showDialog(mDialogModel, ModalDialogManager.ModalDialogType.APP); // Shows the warning dialog only if the user is about to fill a password field.
if (mIsPasswordField) {
mModalDialogManager.showDialog(mDialogModel, ModalDialogManager.ModalDialogType.APP);
} else {
showCredentials();
}
} }
private void showCredentials() { private void showCredentials() {
......
...@@ -6186,9 +6186,12 @@ the Bookmarks menu."> ...@@ -6186,9 +6186,12 @@ the Bookmarks menu.">
<message name="IDS_PASSWORD_MANAGER_ACCESSORY_ALL_PASSWORDS_LINK" desc="The text of the link in the password sheet that opens the password management section."> <message name="IDS_PASSWORD_MANAGER_ACCESSORY_ALL_PASSWORDS_LINK" desc="The text of the link in the password sheet that opens the password management section.">
Manage passwords Manage passwords
</message> </message>
<message name="IDS_PASSWORD_MANAGER_ACCESSORY_USE_OTHER_PASSWORD" desc="The text of the link in the password sheet that opens a bottom sheet which shows all saved passwords from any origin."> <message name="IDS_PASSWORD_MANAGER_ACCESSORY_USE_OTHER_PASSWORD" desc="The text of the link in the password sheet that opens a bottom sheet which shows all saved passwords from any origin if the user is about to fill a password field.">
Use other password Use other password
</message> </message>
<message name="IDS_PASSWORD_MANAGER_ACCESSORY_USE_OTHER_USERNAME" desc="The text of the link in the password sheet that opens a bottom sheet which shows all saved usernames from any origin if the user is about to fill a username field.">
Use other username
</message>
<message name="IDS_PASSWORD_MANAGER_ACCESSORY_GENERATE_PASSWORD_BUTTON_TITLE" desc="Text for the button used to generate a password."> <message name="IDS_PASSWORD_MANAGER_ACCESSORY_GENERATE_PASSWORD_BUTTON_TITLE" desc="Text for the button used to generate a password.">
Suggest strong password Suggest strong password
</message> </message>
......
9cc9abb7c2db9a53220601220786f44ef5bcbada
\ No newline at end of file
...@@ -273,13 +273,16 @@ void PasswordAccessoryControllerImpl::RefreshSuggestionsForField( ...@@ -273,13 +273,16 @@ void PasswordAccessoryControllerImpl::RefreshSuggestionsForField(
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
password_manager::features::kFillingPasswordsFromAnyOrigin)) { password_manager::features::kFillingPasswordsFromAnyOrigin)) {
// TODO(crbug.com/1104132): Disable the feature in insecure websites and on // TODO(crbug.com/1104132): Disable the feature in insecure websites.
// cross-origin iframes (https://crbug.com/1117015). base::string16 button_title =
base::string16 use_other_password_title = l10n_util::GetStringUTF16( is_password_field
IDS_PASSWORD_MANAGER_ACCESSORY_USE_OTHER_PASSWORD); ? l10n_util::GetStringUTF16(
footer_commands_to_add.push_back( IDS_PASSWORD_MANAGER_ACCESSORY_USE_OTHER_PASSWORD)
FooterCommand(use_other_password_title, : l10n_util::GetStringUTF16(
autofill::AccessoryAction::USE_OTHER_PASSWORD)); IDS_PASSWORD_MANAGER_ACCESSORY_USE_OTHER_USERNAME);
footer_commands_to_add.push_back(FooterCommand(
button_title, autofill::AccessoryAction::USE_OTHER_PASSWORD));
} }
if (is_password_field && is_manual_generation_available) { if (is_password_field && is_manual_generation_available) {
......
...@@ -147,6 +147,11 @@ base::string16 show_other_passwords_str() { ...@@ -147,6 +147,11 @@ base::string16 show_other_passwords_str() {
IDS_PASSWORD_MANAGER_ACCESSORY_USE_OTHER_PASSWORD); IDS_PASSWORD_MANAGER_ACCESSORY_USE_OTHER_PASSWORD);
} }
base::string16 show_other_username_str() {
return l10n_util::GetStringUTF16(
IDS_PASSWORD_MANAGER_ACCESSORY_USE_OTHER_USERNAME);
}
base::string16 manage_passwords_str() { base::string16 manage_passwords_str() {
return l10n_util::GetStringUTF16( return l10n_util::GetStringUTF16(
IDS_PASSWORD_MANAGER_ACCESSORY_ALL_PASSWORDS_LINK); IDS_PASSWORD_MANAGER_ACCESSORY_ALL_PASSWORDS_LINK);
...@@ -651,6 +656,25 @@ TEST_F(PasswordAccessoryControllerTest, AddsShowOtherPasswordsIfEnabled) { ...@@ -651,6 +656,25 @@ TEST_F(PasswordAccessoryControllerTest, AddsShowOtherPasswordsIfEnabled) {
/*is_manual_generation_available=*/false); /*is_manual_generation_available=*/false);
} }
TEST_F(PasswordAccessoryControllerTest, AddsShowOtherUsername) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(
password_manager::features::kFillingPasswordsFromAnyOrigin);
AccessorySheetData::Builder data_builder(AccessoryTabType::PASSWORDS,
passwords_empty_str(kExampleDomain));
data_builder
.AppendFooterCommand(show_other_username_str(),
autofill::AccessoryAction::USE_OTHER_PASSWORD)
.AppendFooterCommand(manage_passwords_str(),
autofill::AccessoryAction::MANAGE_PASSWORDS);
EXPECT_CALL(mock_manual_filling_controller_,
RefreshSuggestions(std::move(data_builder).Build()));
controller()->RefreshSuggestionsForField(
FocusedFieldType::kFillableUsernameField,
/*is_manual_generation_available=*/false);
}
TEST_F(PasswordAccessoryControllerTest, HidesShowOtherPasswordsIfDisabled) { TEST_F(PasswordAccessoryControllerTest, HidesShowOtherPasswordsIfDisabled) {
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature( scoped_feature_list.InitAndDisableFeature(
......
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