Commit 95fca159 authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Replace SyntheticForm::document with origin

SyntheticForm is an abstraction of a collection of form input elements
for the purpose of creating PasswordForm objects based on DOM tree.

It currently stores a reference to the web document, only to derive
the form's origin from it later.

This CL drops the reference to the web document and replaces it with
the computed origin. This way, SyntheticForm does not keep an
unnecessary amount of data alive. It does introduce one GURL copy, but
that will be addressed in a separate CL by making GetPasswordForm
consume a SyntheticForm instead of looking at its const reference.

Bug: 833838
Change-Id: I33011146289b60bb50898f70f8001af6668a4203
Reviewed-on: https://chromium-review.googlesource.com/1014130
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551423}
parent b7b481ec
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
#include "third_party/blink/public/web/web_input_element.h" #include "third_party/blink/public/web/web_input_element.h"
#include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/re2/src/re2/re2.h" #include "third_party/re2/src/re2/re2.h"
#include "url/gurl.h"
using blink::WebDocument;
using blink::WebFormControlElement; using blink::WebFormControlElement;
using blink::WebFormElement; using blink::WebFormElement;
using blink::WebInputElement; using blink::WebInputElement;
...@@ -71,7 +71,8 @@ struct SyntheticForm { ...@@ -71,7 +71,8 @@ struct SyntheticForm {
// Contains control elements of the represented form, including not fillable // Contains control elements of the represented form, including not fillable
// ones. // ones.
std::vector<blink::WebFormControlElement> control_elements; std::vector<blink::WebFormControlElement> control_elements;
blink::WebDocument document; // The origin of the containing document.
GURL origin;
private: private:
DISALLOW_COPY_AND_ASSIGN(SyntheticForm); DISALLOW_COPY_AND_ASSIGN(SyntheticForm);
...@@ -159,7 +160,8 @@ void PopulateSyntheticFormFromWebForm(const WebFormElement& web_form, ...@@ -159,7 +160,8 @@ void PopulateSyntheticFormFromWebForm(const WebFormElement& web_form,
web_form.GetFormControlElements(web_control_elements); web_form.GetFormControlElements(web_control_elements);
synthetic_form->control_elements.assign(web_control_elements.begin(), synthetic_form->control_elements.assign(web_control_elements.begin(),
web_control_elements.end()); web_control_elements.end());
synthetic_form->document = web_form.GetDocument(); synthetic_form->origin =
form_util::GetCanonicalOriginForDocument(web_form.GetDocument());
} }
// Helper to determine which password is the main (current) one, and which is // Helper to determine which password is the main (current) one, and which is
...@@ -750,8 +752,7 @@ bool GetPasswordForm( ...@@ -750,8 +752,7 @@ bool GetPasswordForm(
password_form->username_value = username_value; password_form->username_value = username_value;
} }
password_form->origin = password_form->origin = form.origin;
form_util::GetCanonicalOriginForDocument(form.document);
password_form->signon_realm = GetSignOnRealm(password_form->origin); password_form->signon_realm = GetSignOnRealm(password_form->origin);
// Convert |possible_usernames| to ValueElementVector. // Convert |possible_usernames| to ValueElementVector.
...@@ -917,7 +918,8 @@ std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements( ...@@ -917,7 +918,8 @@ std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements(
SyntheticForm synthetic_form; SyntheticForm synthetic_form;
synthetic_form.control_elements = form_util::GetUnownedFormFieldElements( synthetic_form.control_elements = form_util::GetUnownedFormFieldElements(
frame.GetDocument().All(), &synthetic_form.fieldsets); frame.GetDocument().All(), &synthetic_form.fieldsets);
synthetic_form.document = frame.GetDocument(); synthetic_form.origin =
form_util::GetCanonicalOriginForDocument(frame.GetDocument());
if (synthetic_form.control_elements.empty()) if (synthetic_form.control_elements.empty())
return std::unique_ptr<PasswordForm>(); return std::unique_ptr<PasswordForm>();
......
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