| Index: components/autofill/content/renderer/password_autofill_agent.cc
|
| diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc
|
| index aee3f94116bd88b2d321da9d06828be675d15112..5c2ade82e0320fd2c0d1198c0c62de58937ac1ec 100644
|
| --- a/components/autofill/content/renderer/password_autofill_agent.cc
|
| +++ b/components/autofill/content/renderer/password_autofill_agent.cc
|
| @@ -12,11 +12,13 @@
|
| #include <vector>
|
|
|
| #include "base/bind.h"
|
| +#include "base/command_line.h"
|
| #include "base/i18n/case_conversion.h"
|
| #include "base/memory/linked_ptr.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/metrics/histogram_macros.h"
|
| +#include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| @@ -25,6 +27,7 @@
|
| #include "components/autofill/content/renderer/password_form_conversion_utils.h"
|
| #include "components/autofill/content/renderer/renderer_save_password_progress_logger.h"
|
| #include "components/autofill/core/common/autofill_constants.h"
|
| +#include "components/autofill/core/common/autofill_switches.h"
|
| #include "components/autofill/core/common/autofill_util.h"
|
| #include "components/autofill/core/common/form_field_data.h"
|
| #include "components/autofill/core/common/password_form_fill_data.h"
|
| @@ -60,6 +63,9 @@ static const size_t kMaximumTextSizeForAutocomplete = 1000;
|
| const char kDummyUsernameField[] = "anonymous_username";
|
| const char kDummyPasswordField[] = "anonymous_password";
|
|
|
| +const char kDebugAttributeForFormSignature[] = "form_signature";
|
| +const char kDebugAttributeForFieldSignature[] = "field_signature";
|
| +
|
| // Maps element names to the actual elements to simplify form filling.
|
| typedef std::map<base::string16, blink::WebInputElement> FormInputElementMap;
|
|
|
| @@ -562,6 +568,37 @@ bool FillFormOnPasswordReceived(
|
| field_value_and_properties_map, registration_callback, logger);
|
| }
|
|
|
| +// Annotate |forms| with form and field signatures as HTML attributes.
|
| +void AnnotateFormsWithSignatures(
|
| + blink::WebVector<blink::WebFormElement> forms) {
|
| + for (blink::WebFormElement form : forms) {
|
| + std::unique_ptr<PasswordForm> password_form(
|
| + CreatePasswordFormFromWebForm(form, nullptr, nullptr));
|
| + if (password_form) {
|
| + form.setAttribute(
|
| + blink::WebString::fromASCII(kDebugAttributeForFormSignature),
|
| + blink::WebString::fromUTF8(base::Uint64ToString(
|
| + CalculateFormSignature(password_form->form_data))));
|
| +
|
| + blink::WebVector<blink::WebFormControlElement> control_elements =
|
| + form_util::ExtractAutofillableElementsInForm(form);
|
| + DCHECK(control_elements.size() == password_form->form_data.fields.size());
|
| + for (size_t i = 0; i < control_elements.size(); ++i) {
|
| + blink::WebFormControlElement& control_element = control_elements[i];
|
| + if (!form_util::IsAutofillableElement(control_element))
|
| + continue;
|
| +
|
| + const FormFieldData& field = password_form->form_data.fields[i];
|
| + DCHECK(field.name == control_element.nameForAutofill().utf16());
|
| + control_element.setAttribute(
|
| + blink::WebString::fromASCII(kDebugAttributeForFieldSignature),
|
| + blink::WebString::fromUTF8(
|
| + base::Uint64ToString(CalculateFieldSignatureForField(field))));
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -1016,6 +1053,10 @@ void PasswordAutofillAgent::SendPasswordForms(bool only_visible) {
|
|
|
| blink::WebVector<blink::WebFormElement> forms;
|
| frame->document().forms(forms);
|
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kShowAutofillSignatures)) {
|
| + AnnotateFormsWithSignatures(forms);
|
| + }
|
| if (logger)
|
| logger->LogNumber(Logger::STRING_NUMBER_OF_ALL_FORMS, forms.size());
|
|
|
|
|