Commit 2e8f7a2c authored by Christoph Schwering's avatar Christoph Schwering Committed by Commit Bot

[Autofill] Migrated AutofillAgent::submitted_forms_ to unique renderer IDs.

This CL turns AutofillAgent::submitted_forms_ from a std::set<FormData>
with custom comparator into a set of renderer IDs.

The sole purpose of this set is to avoid duplicate submission events per
form. Unique renderer IDs suffice for this. And since the comparator
used before this CL was generally not sound (false positives), this
at least theoretically solves some missing form-submission bugs.

Bug: 896689, 1007974
Change-Id: I8fab1ee692c26c26b2cc061b0045b9757820b553
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2297527Reviewed-by: default avatarMatthias Körber <koerber@google.com>
Commit-Queue: Christoph Schwering <schwering@google.com>
Cr-Commit-Position: refs/heads/master@{#788794}
parent b6527140
......@@ -153,12 +153,6 @@ void AutofillAgent::BindPendingReceiver(
receiver_.Bind(std::move(pending_receiver));
}
bool AutofillAgent::FormDataCompare::operator()(const FormData& lhs,
const FormData& rhs) const {
return std::tie(lhs.name, lhs.url, lhs.action, lhs.is_form_tag) <
std::tie(rhs.name, rhs.url, rhs.action, rhs.is_form_tag);
}
void AutofillAgent::DidCommitProvisionalLoad(ui::PageTransition transition) {
blink::WebFrame* frame = render_frame()->GetWebFrame();
// TODO(dvadym): check if we need to check if it is main frame navigation
......@@ -288,7 +282,7 @@ void AutofillAgent::FireHostSubmitEvents(const FormData& form_data,
bool known_success,
SubmissionSource source) {
// We don't want to fire duplicate submission event.
if (!submitted_forms_.insert(form_data).second)
if (!submitted_forms_.insert(form_data.unique_renderer_id).second)
return;
GetAutofillDriver()->FormSubmitted(form_data, known_success, source);
......
......@@ -129,12 +129,6 @@ class AutofillAgent : public content::RenderFrameObserver,
private:
friend class FormControlClickDetectionTest;
// Functor used as a simplified comparison function for FormData. Only
// compares forms at a high level (notably name, origin, action).
struct FormDataCompare {
bool operator()(const FormData& lhs, const FormData& rhs) const;
};
// Flags passed to ShowSuggestions.
struct ShowSuggestionsOptions {
// All fields are default initialized to false.
......@@ -322,8 +316,7 @@ class AutofillAgent : public content::RenderFrameObserver,
// WILL_SEND_SUBMIT_EVENT and form submitted are both fired for same form.
// The submitted_forms_ is cleared when we know no more submission could
// happen for that form.
// We use a simplified comparison function.
std::set<FormData, FormDataCompare> submitted_forms_;
std::set<FormRendererId> submitted_forms_;
// The query node autofill state prior to previewing the form.
blink::WebAutofillState query_node_autofill_state_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment