Chromium Code Reviews| Index: components/password_manager/core/browser/password_form_manager.cc |
| diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc |
| index c4ad94d5ed6c368ab3ecb10b22145a76110a2829..93225a3364451a625b815c05ca2e8aefc80e21a4 100644 |
| --- a/components/password_manager/core/browser/password_form_manager.cc |
| +++ b/components/password_manager/core/browser/password_form_manager.cc |
| @@ -197,6 +197,14 @@ void LabelFields(const FieldTypeMap& field_types, |
| } |
| } |
| +// Check whether |form_data| corresponds to a 2 field form with 1 text field and |
| +// 1 password field. Such form is likely sign-in form. |
| +bool IsSignInSubmission(const FormData& form_data) { |
|
Roger McFarlane (Chromium)
2017/04/04 19:09:42
This is only for forms that you've otherwise someh
dvadym
2017/04/05 13:28:28
Yes. This is only for forms on which Password Mana
|
| + return form_data.fields.size() == 2 && |
| + form_data.fields[0].form_control_type == "text" && |
| + form_data.fields[1].form_control_type == "password"; |
| +} |
| + |
| } // namespace |
| PasswordFormManager::PasswordFormManager( |
| @@ -1290,6 +1298,11 @@ void PasswordFormManager::SendVotesOnSave() { |
| if (observed_form_.IsPossibleChangePasswordFormWithoutUsername()) |
| return; |
| + if (IsSignInSubmission(pending_credentials_.form_data)) { |
| + SendSignInVote(pending_credentials_.form_data); |
| + return; |
| + } |
| + |
| // Upload credentials the first time they are saved. This data is used |
| // by password generation to help determine account creation sites. |
| // Credentials that have been previously used (e.g., PSL matches) are checked |
| @@ -1308,6 +1321,20 @@ void PasswordFormManager::SendVotesOnSave() { |
| SendVoteOnCredentialsReuse(observed_form_, &pending_credentials_); |
| } |
| +void PasswordFormManager::SendSignInVote(const FormData& form_data) { |
| + autofill::AutofillManager* autofill_manager = |
| + client_->GetAutofillManagerForMainFrame(); |
| + if (!autofill_manager) |
| + return; |
| + std::unique_ptr<FormStructure> form_structure(new FormStructure(form_data)); |
| + form_structure->set_is_signin_upload(true); |
| + DCHECK(form_structure->ShouldBeCrowdsourced()); |
| + DCHECK(form_structure->field_count() == 2); |
| + form_structure->field(1)->set_possible_types({autofill::PASSWORD}); |
| + autofill_manager->StartUploadProcess(std::move(form_structure), |
| + base::TimeTicks::Now(), true); |
| +} |
| + |
| void PasswordFormManager::SetUserAction(UserAction user_action) { |
| if (user_action == kUserActionChoose) { |
| base::RecordAction( |