Commit 08ce6fc4 authored by Reda Tawfik's avatar Reda Tawfik Committed by Commit Bot

[Android][Mfill] Trigger PhishGuard only for selected passwords

Bug: 1138612, 1104132, 1006430
Change-Id: Ie9cb6105cb7612f56caa2d23b4cae010702f443d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2497441
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@{#820778}
parent 523b6a2b
...@@ -80,17 +80,17 @@ void AllPasswordsBottomSheetController::OnCredentialSelected( ...@@ -80,17 +80,17 @@ void AllPasswordsBottomSheetController::OnCredentialSelected(
DCHECK(driver_); DCHECK(driver_);
if (is_password_field) { if (is_password_field) {
driver_->FillIntoFocusedField(is_password_field, password); driver_->FillIntoFocusedField(is_password_field, password);
// `client_` is guaranteed to be valid here.
// Both the `client_` and `PasswordAccessoryController` are attached to
// WebContents. And AllPasswordBottomSheetController is owned by
// PasswordAccessoryController.
DCHECK(client_);
client_->OnPasswordSelected(password);
} else { } else {
driver_->FillIntoFocusedField(is_password_field, username); driver_->FillIntoFocusedField(is_password_field, username);
} }
// `client_` is guaranteed to be valid here.
// Both the `client_` and `PasswordAccessoryController` are attached to
// WebContents. And AllPasswordBottomSheetController is owned by
// PasswordAccessoryController.
DCHECK(client_);
client_->OnPasswordSelected(password);
// Consumes the dismissal callback to destroy the native controller and java // Consumes the dismissal callback to destroy the native controller and java
// controller after the user selects a credential. // controller after the user selects a credential.
OnDismiss(); OnDismiss();
......
...@@ -92,6 +92,11 @@ PasswordForm MakeSavedPassword(const std::string& signon_realm, ...@@ -92,6 +92,11 @@ PasswordForm MakeSavedPassword(const std::string& signon_realm,
class AllPasswordsBottomSheetControllerTest : public testing::Test { class AllPasswordsBottomSheetControllerTest : public testing::Test {
protected: protected:
AllPasswordsBottomSheetControllerTest() { AllPasswordsBottomSheetControllerTest() {
createAllPasswordsController(FocusedFieldType::kFillablePasswordField);
}
void createAllPasswordsController(
autofill::mojom::FocusedFieldType focused_field_type) {
std::unique_ptr<MockAllPasswordsBottomSheetView> mock_view_unique_ptr = std::unique_ptr<MockAllPasswordsBottomSheetView> mock_view_unique_ptr =
std::make_unique<MockAllPasswordsBottomSheetView>(); std::make_unique<MockAllPasswordsBottomSheetView>();
mock_view_ = mock_view_unique_ptr.get(); mock_view_ = mock_view_unique_ptr.get();
...@@ -99,8 +104,7 @@ class AllPasswordsBottomSheetControllerTest : public testing::Test { ...@@ -99,8 +104,7 @@ class AllPasswordsBottomSheetControllerTest : public testing::Test {
std::make_unique<AllPasswordsBottomSheetController>( std::make_unique<AllPasswordsBottomSheetController>(
util::PassKey<AllPasswordsBottomSheetControllerTest>(), util::PassKey<AllPasswordsBottomSheetControllerTest>(),
std::move(mock_view_unique_ptr), driver_.AsWeakPtr(), store_.get(), std::move(mock_view_unique_ptr), driver_.AsWeakPtr(), store_.get(),
dissmissal_callback_.Get(), dissmissal_callback_.Get(), focused_field_type,
FocusedFieldType::kFillablePasswordField,
mock_pwd_manager_client_.get()); mock_pwd_manager_client_.get());
} }
...@@ -178,3 +182,12 @@ TEST_F(AllPasswordsBottomSheetControllerTest, ...@@ -178,3 +182,12 @@ TEST_F(AllPasswordsBottomSheetControllerTest,
all_passwords_controller()->OnCredentialSelected( all_passwords_controller()->OnCredentialSelected(
base::UTF8ToUTF16(kUsername1), base::UTF8ToUTF16(kPassword)); base::UTF8ToUTF16(kUsername1), base::UTF8ToUTF16(kPassword));
} }
TEST_F(AllPasswordsBottomSheetControllerTest,
PhishGuardIsNotCalledForUsername) {
createAllPasswordsController(FocusedFieldType::kFillableUsernameField);
EXPECT_CALL(client(), OnPasswordSelected).Times(0);
all_passwords_controller()->OnCredentialSelected(
base::UTF8ToUTF16(kUsername1), base::UTF8ToUTF16(kPassword));
}
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