Commit 15b8ed0c authored by Maria Kazinova's avatar Maria Kazinova Committed by Commit Bot

Move kDetectFormSubmissionOnFormClear feature check moment.

Moved the check to the point where submission is actually detected in
order to have more meaningful Finch data.

Bug: 1152433
Change-Id: Ic436fb00307098866dca1aefd27dcd92ae43ad6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2556682Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Commit-Queue: Maria Kazinova <kazinova@google.com>
Cr-Commit-Position: refs/heads/master@{#830590}
parent 0d0a4d9a
......@@ -1375,11 +1375,8 @@ PasswordAutofillAgent::GetFormDataFromUnownedInputElements() {
void PasswordAutofillAgent::InformAboutFormClearing(
const WebFormElement& form) {
if (!FrameCanAccessPasswordManager() ||
!base::FeatureList::IsEnabled(
password_manager::features::kDetectFormSubmissionOnFormClear)) {
if (!FrameCanAccessPasswordManager())
return;
}
for (const auto& element : form.GetFormControlElements()) {
FieldRendererId element_id(element.UniqueRendererFormControlId());
// Notify PasswordManager if |form| has password fields that have user typed
......@@ -1396,10 +1393,6 @@ void PasswordAutofillAgent::InformAboutFieldClearing(
if (!FrameCanAccessPasswordManager())
return;
DCHECK(cleared_element.Value().IsEmpty());
if (!base::FeatureList::IsEnabled(
password_manager::features::kDetectFormSubmissionOnFormClear)) {
return;
}
FieldRendererId field_id(cleared_element.UniqueRendererFormControlId());
// Ignore fields that had no user input or autofill on user trigger.
if (!field_data_manager_->DidUserType(field_id) &&
......
......@@ -1239,7 +1239,9 @@ void PasswordManager::OnPasswordFormCleared(
return;
}
// If a password form was cleared, login is successful.
if (form_data.is_form_tag) {
if (form_data.is_form_tag &&
base::FeatureList::IsEnabled(
password_manager::features::kDetectFormSubmissionOnFormClear)) {
manager->UpdateSubmissionIndicatorEvent(
SubmissionIndicatorEvent::CHANGE_PASSWORD_FORM_CLEARED);
OnLoginSuccessful();
......@@ -1251,7 +1253,9 @@ void PasswordManager::OnPasswordFormCleared(
manager->GetSubmittedForm()->new_password_element_renderer_id;
auto it = base::ranges::find(form_data.fields, new_password_field_id,
&autofill::FormFieldData::unique_renderer_id);
if (it != form_data.fields.end() && it->value.empty()) {
if (it != form_data.fields.end() && it->value.empty() &&
base::FeatureList::IsEnabled(
features::kDetectFormSubmissionOnFormClear)) {
manager->UpdateSubmissionIndicatorEvent(
SubmissionIndicatorEvent::CHANGE_PASSWORD_FORM_CLEARED);
OnLoginSuccessful();
......
......@@ -3722,6 +3722,8 @@ TEST_P(PasswordManagerTest, GenerationOnChangedForm) {
#if !defined(OS_IOS)
TEST_P(PasswordManagerTest, SubmissionDetectedOnClearedForm) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDetectFormSubmissionOnFormClear);
EXPECT_CALL(client_, IsSavingAndFillingEnabled).WillRepeatedly(Return(true));
PasswordForm saved_match(MakeSavedForm());
EXPECT_CALL(*store_, GetLogins)
......@@ -3767,6 +3769,8 @@ TEST_P(PasswordManagerTest, SubmissionDetectedOnClearedForm) {
}
TEST_P(PasswordManagerTest, SubmissionDetectedOnClearedFormlessFields) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDetectFormSubmissionOnFormClear);
EXPECT_CALL(client_, IsSavingAndFillingEnabled).WillRepeatedly(Return(true));
PasswordForm saved_match(MakeSavedForm());
EXPECT_CALL(*store_, GetLogins)
......
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