Chromium Code Reviews| Index: components/autofill/content/renderer/password_generation_agent.cc |
| diff --git a/components/autofill/content/renderer/password_generation_agent.cc b/components/autofill/content/renderer/password_generation_agent.cc |
| index 1bdd7b51521d8afc67e86ab2b23ebd0cf1a5fbf4..abfcabaa4f45dea1735af7f5b4a367c5cc88fe84 100644 |
| --- a/components/autofill/content/renderer/password_generation_agent.cc |
| +++ b/components/autofill/content/renderer/password_generation_agent.cc |
| @@ -123,6 +123,13 @@ void PasswordGenerationAgent::DidFinishDocumentLoad( |
| generation_enabled_forms_.clear(); |
| generation_element_.reset(); |
| possible_account_creation_form_.reset(new PasswordForm()); |
| + if (password_elements_.empty()) { |
|
vabr (Chromium)
2014/10/16 07:46:15
If I understand correctly, this logs the event fro
Garrett Casto
2014/10/16 19:14:06
I think that happens rarely enough not to worry ab
|
| + password_generation::LogPasswordGenerationEvent( |
| + password_generation::NO_SIGN_UP_DETECTED); |
| + } else { |
| + password_generation::LogPasswordGenerationEvent( |
| + password_generation::SIGN_UP_DETECTED); |
| + } |
| password_elements_.clear(); |
| password_is_generated_ = false; |
| if (password_edited_) { |
| @@ -145,7 +152,16 @@ void PasswordGenerationAgent::DidFinishDocumentLoad( |
| } |
| } |
| +void PasswordGenerationAgent::OnDynamicFormsSeen(blink::WebLocalFrame* frame) { |
| + FindPossibleGenerationForm(frame); |
| +} |
| + |
| void PasswordGenerationAgent::DidFinishLoad(blink::WebLocalFrame* frame) { |
| + FindPossibleGenerationForm(frame); |
| +} |
| + |
| +void PasswordGenerationAgent::FindPossibleGenerationForm( |
| + blink::WebLocalFrame* frame) { |
| if (!enabled_) |
| return; |
| @@ -154,6 +170,10 @@ void PasswordGenerationAgent::DidFinishLoad(blink::WebLocalFrame* frame) { |
| if (!ShouldAnalyzeDocument(frame->document())) |
| return; |
| + // If we have already found a signup form for this page, no need to continue. |
| + if (!password_elements_.empty()) |
| + return; |
| + |
| blink::WebVector<blink::WebFormElement> forms; |
| frame->document().forms(forms); |
| for (size_t i = 0; i < forms.size(); ++i) { |
| @@ -178,8 +198,6 @@ void PasswordGenerationAgent::DidFinishLoad(blink::WebLocalFrame* frame) { |
| std::vector<blink::WebInputElement> passwords; |
| if (GetAccountCreationPasswordFields(forms[i], &passwords)) { |
| DVLOG(2) << "Account creation form detected"; |
| - password_generation::LogPasswordGenerationEvent( |
| - password_generation::SIGN_UP_DETECTED); |
| password_elements_ = passwords; |
| possible_account_creation_form_.swap(password_form); |
| DetermineGenerationElement(); |
| @@ -187,8 +205,6 @@ void PasswordGenerationAgent::DidFinishLoad(blink::WebLocalFrame* frame) { |
| return; |
| } |
| } |
| - password_generation::LogPasswordGenerationEvent( |
| - password_generation::NO_SIGN_UP_DETECTED); |
| } |
| bool PasswordGenerationAgent::ShouldAnalyzeDocument( |