| Index: chrome/browser/password_manager/password_form_manager.cc
|
| diff --git a/chrome/browser/password_manager/password_form_manager.cc b/chrome/browser/password_manager/password_form_manager.cc
|
| index fc3ddc232537ae6f625a1c547124cddb9729fc12..b28ba214d60a559356c98e891eb35f041f1fc257 100644
|
| --- a/chrome/browser/password_manager/password_form_manager.cc
|
| +++ b/chrome/browser/password_manager/password_form_manager.cc
|
| @@ -13,12 +13,15 @@
|
| #include "chrome/browser/password_manager/password_store.h"
|
| #include "chrome/browser/password_manager/password_store_factory.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "components/autofill/content/browser/autofill_driver_impl.h"
|
| +#include "components/autofill/core/browser/form_structure.h"
|
| #include "components/autofill/core/browser/validation.h"
|
| #include "components/autofill/core/common/autofill_messages.h"
|
| #include "components/autofill/core/common/password_form.h"
|
| #include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/web_contents.h"
|
|
|
| +using autofill::FormStructure;
|
| using autofill::PasswordForm;
|
| using autofill::PasswordFormMap;
|
| using base::Time;
|
| @@ -486,6 +489,9 @@ void PasswordFormManager::UpdateLogin() {
|
| // Update metadata.
|
| ++pending_credentials_.times_used;
|
|
|
| + // Check to see if this form is a candidate for password generation.
|
| + CheckForAccountCreationForm(pending_credentials_, observed_form_);
|
| +
|
| UpdatePreferredLoginState(password_store);
|
|
|
| // Remove alternate usernames. At this point we assume that we have found
|
| @@ -543,6 +549,31 @@ bool PasswordFormManager::UpdatePendingCredentialsIfOtherPossibleUsername(
|
| return false;
|
| }
|
|
|
| +void PasswordFormManager::CheckForAccountCreationForm(
|
| + const PasswordForm& pending, const PasswordForm& observed) {
|
| + // We check to see if the saved form_data is the same as the observed
|
| + // form_data, which should never be true for passwords saved on account
|
| + // creation forms. This check is only made the first time a password is used
|
| + // to cut down on false positives. Specifically a site may have multiple login
|
| + // forms with different markup, which might look similar to a signup form.
|
| + if (pending.times_used == 1) {
|
| + FormStructure pending_structure(pending.form_data);
|
| + FormStructure observed_structure(observed.form_data);
|
| + if (pending_structure.FormSignature() !=
|
| + observed_structure.FormSignature()) {
|
| + autofill::AutofillDriverImpl* driver =
|
| + autofill::AutofillDriverImpl::FromWebContents(web_contents_);
|
| + if (driver && driver->autofill_manager()) {
|
| + // Note that this doesn't guarantee that the upload succeeded, only that
|
| + // |pending.form_data| is considered uploadable.
|
| + bool success = driver->autofill_manager()->UploadPasswordGenerationForm(
|
| + pending.form_data);
|
| + UMA_HISTOGRAM_BOOLEAN("PasswordGeneration.UploadStarted", success);
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| int PasswordFormManager::ScoreResult(const PasswordForm& candidate) const {
|
| DCHECK_EQ(state_, MATCHING_PHASE);
|
| // For scoring of candidate login data:
|
|
|