Commit b4582cd3 authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

Send only password forms to the browser.

On the removal the old parser on CL
https://chromium-review.googlesource.com/c/chromium/src/+/1814832
Password Manager started to send all forms the browser process, while
only forms with password fields are needed.

Bug: 875768

Change-Id: I7e212a5e8b0ad7a438666644b4a20c3f9437ab12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1950504
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721549}
parent 7cbaed62
......@@ -1153,13 +1153,11 @@ TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_FormWithoutPasswords) {
LoadHTML(kFormWithoutPasswordsHTML);
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(fake_driver_.called_password_forms_parsed());
ASSERT_TRUE(fake_driver_.password_forms_parsed());
EXPECT_FALSE(fake_driver_.password_forms_parsed()->empty());
EXPECT_FALSE(fake_driver_.called_password_forms_parsed());
EXPECT_TRUE(fake_driver_.called_password_forms_rendered());
ASSERT_TRUE(fake_driver_.password_forms_rendered());
EXPECT_FALSE(fake_driver_.password_forms_rendered()->empty());
EXPECT_TRUE(fake_driver_.password_forms_rendered()->empty());
}
TEST_F(PasswordAutofillAgentTest,
......@@ -1172,7 +1170,7 @@ TEST_F(PasswordAutofillAgentTest,
"document.getElementById('random_field').type = 'password';";
ExecuteJavaScriptForTests(script.c_str());
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(fake_driver_.called_password_forms_parsed());
EXPECT_FALSE(fake_driver_.called_password_forms_parsed());
// When the user clicks on the field, a request to the store will be sent.
EXPECT_TRUE(SimulateElementClick("random_field"));
......@@ -1183,7 +1181,7 @@ TEST_F(PasswordAutofillAgentTest,
EXPECT_TRUE(fake_driver_.called_password_forms_rendered());
ASSERT_TRUE(fake_driver_.password_forms_rendered());
EXPECT_FALSE(fake_driver_.password_forms_rendered()->empty());
EXPECT_TRUE(fake_driver_.password_forms_rendered()->empty());
}
TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_NonDisplayedForm) {
......
......@@ -374,7 +374,16 @@ bool IsInCrossOriginIframe(const WebInputElement& element) {
return false;
}
// Whether any of the fields in |form) is a non-empty password field.
// Whether any of the fields in |form| is a password field.
bool FormHasPasswordField(const FormData& form) {
for (const auto& field : form.fields) {
if (field.IsPasswordInputElement())
return true;
}
return false;
}
// Whether any of the fields in |form| is a non-empty password field.
bool FormHasNonEmptyPasswordField(const FormData& form) {
for (const auto& field : form.fields) {
if (field.IsPasswordInputElement()) {
......@@ -957,9 +966,8 @@ void PasswordAutofillAgent::SendPasswordForms(bool only_visible) {
// Checks whether the webpage is a redirect page or an empty page.
if (form_util::IsWebpageEmpty(frame)) {
if (logger) {
if (logger)
logger->LogMessage(Logger::STRING_WEBPAGE_EMPTY);
}
return;
}
......@@ -988,7 +996,7 @@ void PasswordAutofillAgent::SendPasswordForms(bool only_visible) {
std::unique_ptr<PasswordForm> password_form(
GetPasswordFormFromWebForm(form));
if (!password_form)
if (!password_form || !FormHasPasswordField(password_form->form_data))
continue;
if (logger)
......@@ -1484,7 +1492,6 @@ void PasswordAutofillAgent::ProvisionallySavePassword(
const WebInputElement& element,
ProvisionallySaveRestriction restriction) {
DCHECK(!form.IsNull() || !element.IsNull());
SetLastUpdatedFormAndField(form, element);
std::unique_ptr<PasswordForm> password_form;
if (form.IsNull()) {
......
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