Commit 18541055 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[Passwords] Reject Empty Usernames for Leak Detection

This change implements logic rejecting forms with empty usernames for
the leak detection feature. Also it adds a DCHECK that the password is
non-empty.

Bug: 986298
Change-Id: I178da166e0f7c0f9baa17ad6ed1452446c2e998e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763692Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689024}
parent ff24116c
...@@ -30,9 +30,14 @@ void LeakDetectionDelegate::StartLeakCheck(const autofill::PasswordForm& form) { ...@@ -30,9 +30,14 @@ void LeakDetectionDelegate::StartLeakCheck(const autofill::PasswordForm& form) {
return; return;
if (!client_->GetPrefs()->GetBoolean( if (!client_->GetPrefs()->GetBoolean(
password_manager::prefs::kPasswordLeakDetectionEnabled)) password_manager::prefs::kPasswordLeakDetectionEnabled)) {
return;
}
if (form.username_value.empty())
return; return;
DCHECK(!form.password_value.empty());
leak_check_ = leak_factory_->TryCreateLeakCheck( leak_check_ = leak_factory_->TryCreateLeakCheck(
this, client_->GetIdentityManager(), client_->GetURLLoaderFactory()); this, client_->GetIdentityManager(), client_->GetURLLoaderFactory());
if (leak_check_) { if (leak_check_) {
......
...@@ -110,6 +110,16 @@ TEST_F(LeakDetectionDelegateTest, PrefIsFalse) { ...@@ -110,6 +110,16 @@ TEST_F(LeakDetectionDelegateTest, PrefIsFalse) {
EXPECT_FALSE(delegate().leak_check()); EXPECT_FALSE(delegate().leak_check());
} }
TEST_F(LeakDetectionDelegateTest, UsernameIsEmpty) {
autofill::PasswordForm form = CreateTestForm();
form.username_value.clear();
EXPECT_CALL(factory(), TryCreateLeakCheck).Times(0);
delegate().StartLeakCheck(form);
EXPECT_FALSE(delegate().leak_check());
}
TEST_F(LeakDetectionDelegateTest, StartCheck) { TEST_F(LeakDetectionDelegateTest, StartCheck) {
const autofill::PasswordForm form = CreateTestForm(); const autofill::PasswordForm form = CreateTestForm();
EXPECT_CALL(client(), IsIncognito).WillOnce(Return(false)); EXPECT_CALL(client(), IsIncognito).WillOnce(Return(false));
......
...@@ -1186,7 +1186,7 @@ void PasswordManager::OnLoginSuccessful() { ...@@ -1186,7 +1186,7 @@ void PasswordManager::OnLoginSuccessful() {
client_->GetStoreResultFilter()->ReportFormLoginSuccess(*submitted_manager); client_->GetStoreResultFilter()->ReportFormLoginSuccess(*submitted_manager);
#if !defined(OS_IOS) #if !defined(OS_IOS)
leak_delegate_.StartLeakCheck(*submitted_manager->GetSubmittedForm()); leak_delegate_.StartLeakCheck(submitted_manager->GetPendingCredentials());
#endif #endif
auto submission_event = auto submission_event =
......
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