Commit fec1c50e authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

Add FormData::is_action_empty.

In case of a form action is absent, FormData::action is set to origin.
That makes it impossible to check whether FormData has an empty action.
And it's used for detection of submission success in Password Manager.
This CL fixed that.

Bug: 1008798
Change-Id: Ic44aaf6ef94df6766fe7eddccbe14a2b030974a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832818Reviewed-by: default avatarEmily Stark <estark@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705890}
parent 4c649764
...@@ -1768,6 +1768,7 @@ bool WebFormElementToFormData( ...@@ -1768,6 +1768,7 @@ bool WebFormElementToFormData(
form->unique_renderer_id = form_element.UniqueRendererFormId(); form->unique_renderer_id = form_element.UniqueRendererFormId();
form->url = GetCanonicalOriginForDocument(frame->GetDocument()); form->url = GetCanonicalOriginForDocument(frame->GetDocument());
form->action = GetCanonicalActionForForm(form_element); form->action = GetCanonicalActionForForm(form_element);
form->is_action_empty = form_element.Action().IsNull();
if (IsAutofillFieldMetadataEnabled()) { if (IsAutofillFieldMetadataEnabled()) {
SCOPED_UMA_HISTOGRAM_TIMER( SCOPED_UMA_HISTOGRAM_TIMER(
"PasswordManager.ButtonTitlePerformance.HasFormTag"); "PasswordManager.ButtonTitlePerformance.HasFormTag");
......
...@@ -120,6 +120,7 @@ void CreateTestAddressFormData(FormData* form, ...@@ -120,6 +120,7 @@ void CreateTestAddressFormData(FormData* form,
mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)}; mojom::ButtonTitleType::BUTTON_ELEMENT_SUBMIT_TYPE)};
form->url = GURL("http://myform.com/form.html"); form->url = GURL("http://myform.com/form.html");
form->action = GURL("http://myform.com/submit.html"); form->action = GURL("http://myform.com/submit.html");
form->is_action_empty = true;
form->main_frame_origin = form->main_frame_origin =
url::Origin::Create(GURL("https://myform_root.com/form.html")); url::Origin::Create(GURL("https://myform_root.com/form.html"));
types->clear(); types->clear();
......
...@@ -98,10 +98,12 @@ bool FormData::SameFormAs(const FormData& form) const { ...@@ -98,10 +98,12 @@ bool FormData::SameFormAs(const FormData& form) const {
bool FormData::SimilarFormAs(const FormData& form) const { bool FormData::SimilarFormAs(const FormData& form) const {
if (name != form.name || id_attribute != form.id_attribute || if (name != form.name || id_attribute != form.id_attribute ||
name_attribute != form.name_attribute || url != form.url || name_attribute != form.name_attribute || url != form.url ||
action != form.action || is_form_tag != form.is_form_tag || action != form.action || is_action_empty != form.is_action_empty ||
is_form_tag != form.is_form_tag ||
is_formless_checkout != form.is_formless_checkout || is_formless_checkout != form.is_formless_checkout ||
fields.size() != form.fields.size()) fields.size() != form.fields.size()) {
return false; return false;
}
for (size_t i = 0; i < fields.size(); ++i) { for (size_t i = 0; i < fields.size(); ++i) {
if (!fields[i].SimilarFieldAs(form.fields[i])) if (!fields[i].SimilarFieldAs(form.fields[i]))
return false; return false;
...@@ -124,7 +126,7 @@ bool FormData::DynamicallySameFormAs(const FormData& form) const { ...@@ -124,7 +126,7 @@ bool FormData::DynamicallySameFormAs(const FormData& form) const {
bool FormData::operator==(const FormData& form) const { bool FormData::operator==(const FormData& form) const {
return name == form.name && id_attribute == form.id_attribute && return name == form.name && id_attribute == form.id_attribute &&
name_attribute == form.name_attribute && url == form.url && name_attribute == form.name_attribute && url == form.url &&
action == form.action && action == form.action && is_action_empty == form.is_action_empty &&
unique_renderer_id == form.unique_renderer_id && unique_renderer_id == form.unique_renderer_id &&
submission_event == form.submission_event && submission_event == form.submission_event &&
is_form_tag == form.is_form_tag && is_form_tag == form.is_form_tag &&
...@@ -237,6 +239,7 @@ LogBuffer& operator<<(LogBuffer& buffer, const FormData& form) { ...@@ -237,6 +239,7 @@ LogBuffer& operator<<(LogBuffer& buffer, const FormData& form) {
buffer << Tr{} << "Unique renderer Id:" << form.unique_renderer_id; buffer << Tr{} << "Unique renderer Id:" << form.unique_renderer_id;
buffer << Tr{} << "URL:" << form.url; buffer << Tr{} << "URL:" << form.url;
buffer << Tr{} << "Action:" << form.action; buffer << Tr{} << "Action:" << form.action;
buffer << Tr{} << "Is action empty:" << form.is_action_empty;
buffer << Tr{} << "Is <form> tag:" << form.is_form_tag; buffer << Tr{} << "Is <form> tag:" << form.is_form_tag;
for (size_t i = 0; i < form.fields.size(); ++i) { for (size_t i = 0; i < form.fields.size(); ++i) {
buffer << Tag{"tr"}; buffer << Tag{"tr"};
......
...@@ -78,6 +78,10 @@ struct FormData { ...@@ -78,6 +78,10 @@ struct FormData {
GURL url; GURL url;
// The action target of the form. // The action target of the form.
GURL action; GURL action;
// If the form in the DOM has an empty action attribute, the |action| field in
// the FormData is set to the frame URL of the embedding document. This field
// indicates whether the action attribute is empty in the form in the DOM.
bool is_action_empty = false;
// The URL of main frame containing this form. // The URL of main frame containing this form.
url::Origin main_frame_origin; url::Origin main_frame_origin;
// True if this form is a form tag. // True if this form is a form tag.
......
...@@ -153,6 +153,7 @@ struct FormData { ...@@ -153,6 +153,7 @@ struct FormData {
array<ButtonTitleInfo> button_titles; array<ButtonTitleInfo> button_titles;
url.mojom.Url url; url.mojom.Url url;
url.mojom.Url action; url.mojom.Url action;
bool is_action_empty;
url.mojom.Origin main_frame_origin; url.mojom.Origin main_frame_origin;
bool is_form_tag; bool is_form_tag;
bool is_formless_checkout; bool is_formless_checkout;
......
...@@ -107,6 +107,7 @@ bool StructTraits<autofill::mojom::FormDataDataView, autofill::FormData>::Read( ...@@ -107,6 +107,7 @@ bool StructTraits<autofill::mojom::FormDataDataView, autofill::FormData>::Read(
return false; return false;
if (!data.ReadAction(&out->action)) if (!data.ReadAction(&out->action))
return false; return false;
out->is_action_empty = data.is_action_empty();
if (!data.ReadMainFrameOrigin(&out->main_frame_origin)) if (!data.ReadMainFrameOrigin(&out->main_frame_origin))
return false; return false;
......
...@@ -196,6 +196,10 @@ struct StructTraits<autofill::mojom::FormDataDataView, autofill::FormData> { ...@@ -196,6 +196,10 @@ struct StructTraits<autofill::mojom::FormDataDataView, autofill::FormData> {
static const GURL& action(const autofill::FormData& r) { return r.action; } static const GURL& action(const autofill::FormData& r) { return r.action; }
static bool is_action_empty(const autofill::FormData& r) {
return r.is_action_empty;
}
static const url::Origin& main_frame_origin(const autofill::FormData& r) { static const url::Origin& main_frame_origin(const autofill::FormData& r) {
return r.main_frame_origin; return r.main_frame_origin;
} }
......
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