Ignore blur events caused by the password generation.

When PasswordGenerationAgent copies the password value from the password field
to "Confirm Password" filed, a blur event is generated. It hides the currently
open generation prompt. Those events are just side-effects of how the class
works and should be ignored.

Bug: 899756,850079
Change-Id: Ia5d4f0184900fda97118252c48209ffcf1ce3444
Reviewed-on: https://chromium-review.googlesource.com/c/1327205
Commit-Queue: Vasilii Sukhanov <[email protected]>
Reviewed-by: Sebastien Seguin-Gagnon <[email protected]>
Reviewed-by: Ioana Pandele <[email protected]>
Cr-Commit-Position: refs/heads/master@{#606863}
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc
index 684b2f7..d898b46 100644
--- a/components/autofill/content/renderer/autofill_agent.cc
+++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -311,6 +311,12 @@
 }
 
 void AutofillAgent::TextFieldDidEndEditing(const WebInputElement& element) {
+  // Sometimes "blur" events are side effects of the password generation
+  // handling the page. They should not affect any UI in the browser.
+  if (password_generation_agent_ &&
+      password_generation_agent_->ShouldIgnoreBlur()) {
+    return;
+  }
   GetAutofillDriver()->DidEndTextFieldEditing();
   password_autofill_agent_->DidEndTextFieldEditing();
   if (password_generation_agent_)