Index: components/autofill/browser/autofill_manager.cc |
diff --git a/components/autofill/browser/autofill_manager.cc b/components/autofill/browser/autofill_manager.cc |
index ceecddb17fa24df776146692322544e1e01bedff..51fd1e4a571b3d45c2d314e8932c0ce27d20589a 100644 |
--- a/components/autofill/browser/autofill_manager.cc |
+++ b/components/autofill/browser/autofill_manager.cc |
@@ -455,19 +455,28 @@ bool AutofillManager::OnFormSubmitted(const FormData& form, |
void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms, |
const TimeTicks& timestamp, |
- bool has_more_forms) { |
+ autofill::FormsSeenState state) { |
+ bool is_post_document_load = state & autofill::DYNAMIC_FORMS_SEEN; |
+ bool has_more_forms = state & autofill::PARTIAL_FORMS_SEEN; |
+ // If new forms were added via AJAX or DHML, treat as new page. |
+ if (is_post_document_load) |
+ Reset(); |
+ |
RenderViewHost* host = web_contents()->GetRenderViewHost(); |
if (!host) |
return; |
if (!GetAutocheckoutURLPrefix().empty()) { |
- host->Send( |
- new AutofillMsg_WhitelistedForAutocheckout(host->GetRoutingID())); |
// If whitelisted URL, fetch all the forms. |
- if (has_more_forms) { |
+ if (has_more_forms) |
host->Send(new AutofillMsg_GetAllForms(host->GetRoutingID())); |
- return; |
+ if (!is_post_document_load) { |
+ host->Send( |
+ new AutofillMsg_WhitelistedForAutocheckout(host->GetRoutingID())); |
} |
+ // Now return early, as OnFormsSeen will get called again with all forms. |
+ if (has_more_forms) |
+ return; |
} |
autocheckout_manager_.OnFormsSeen(); |