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

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

Issue 2073143002: [Password Generation] Run the form classifier only if AutofillMetadata is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pg_classifier_votes
Patch Set: Removed unnecessary ';' Created 4 years, 6 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
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 0aee6066417ecfc1014b5b12b9b2490dfba13969..1264b0ce1cf270e3f43d8bc48bf4707fc9cb2dd4 100644
--- a/components/autofill/content/renderer/password_generation_agent.cc
+++ b/components/autofill/content/renderer/password_generation_agent.cc
@@ -126,6 +126,7 @@ PasswordGenerationAgent::PasswordGenerationAgent(
generation_popup_shown_(false),
editing_popup_shown_(false),
enabled_(password_generation::IsPasswordGenerationEnabled()),
+ form_classifier_enabled_(false),
password_agent_(password_agent) {
VLOG(2) << "Password Generation is " << (enabled_ ? "Enabled" : "Disabled");
}
@@ -195,9 +196,15 @@ void PasswordGenerationAgent::OnDynamicFormsSeen() {
FindPossibleGenerationForm();
}
+void PasswordGenerationAgent::OnAllowToRunFormClassifier() {
+ form_classifier_enabled_ = true;
+}
+
void PasswordGenerationAgent::RunFormClassifierAndSaveVote(
const blink::WebFormElement& web_form,
const PasswordForm& form) {
+ DCHECK(form_classifier_enabled_);
+
base::string16 generation_field;
ClassifyFormAndFindGenerationField(web_form, &generation_field);
Send(new AutofillHostMsg_SaveGenerationFieldDetectedByClassifier(
@@ -242,7 +249,8 @@ void PasswordGenerationAgent::FindPossibleGenerationForm() {
if (GetAccountCreationPasswordFields(
form_util::ExtractAutofillableElementsInForm(forms[i]),
&passwords)) {
- RunFormClassifierAndSaveVote(forms[i], *password_form);
+ if (form_classifier_enabled_)
+ RunFormClassifierAndSaveVote(forms[i], *password_form);
AccountCreationFormData ac_form_data(
make_linked_ptr(password_form.release()), passwords);
possible_account_creation_forms_.push_back(ac_form_data);
@@ -283,6 +291,8 @@ bool PasswordGenerationAgent::OnMessageReceived(const IPC::Message& message) {
OnFormsEligibleForGenerationFound);
IPC_MESSAGE_HANDLER(AutofillMsg_UserTriggeredGeneratePassword,
OnUserTriggeredGeneratePassword);
+ IPC_MESSAGE_HANDLER(AutofillMsg_AllowToRunFormClassifier,
+ OnAllowToRunFormClassifier);
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
« no previous file with comments | « components/autofill/content/renderer/password_generation_agent.h ('k') | components/autofill/core/browser/form_structure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698