Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Unified Diff: components/autofill/content/renderer/password_generation_agent.cc

Issue 662493002: [Password Generation] Enable generation for dynamically created forms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/content/renderer/password_generation_agent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3eaf1b8ccd8b3bafc0d711a7089f6849c3474816..af8f16eadea7d975ac6478ecb8d774f7b16be44d 100644
--- a/components/autofill/content/renderer/password_generation_agent.cc
+++ b/components/autofill/content/renderer/password_generation_agent.cc
@@ -121,6 +121,15 @@ void PasswordGenerationAgent::DidFinishDocumentLoad(
generation_enabled_forms_.clear();
generation_element_.reset();
possible_account_creation_form_.reset(new PasswordForm());
+
+ // Log statistics after navigation so that we only log once per page.
+ if (password_elements_.empty()) {
+ 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_) {
@@ -143,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;
@@ -152,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) {
@@ -176,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();
@@ -185,8 +205,6 @@ void PasswordGenerationAgent::DidFinishLoad(blink::WebLocalFrame* frame) {
return;
}
}
- password_generation::LogPasswordGenerationEvent(
- password_generation::NO_SIGN_UP_DETECTED);
}
bool PasswordGenerationAgent::ShouldAnalyzeDocument(
« no previous file with comments | « components/autofill/content/renderer/password_generation_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698