Chromium Code Reviews| Index: components/autofill/content/renderer/form_autofill_util.cc |
| diff --git a/components/autofill/content/renderer/form_autofill_util.cc b/components/autofill/content/renderer/form_autofill_util.cc |
| index c6175c9f22729eb75d442d0be697a370eb8cfbb7..461f4e11446d85e1c4b32f8b0c558505c400311a 100644 |
| --- a/components/autofill/content/renderer/form_autofill_util.cc |
| +++ b/components/autofill/content/renderer/form_autofill_util.cc |
| @@ -7,6 +7,7 @@ |
| #include <map> |
| #include "base/command_line.h" |
| +#include "base/command_line.h" |
|
Ilya Sherman
2014/10/21 01:19:11
nit: Duplicate #include.
Evan Stade
2014/10/21 19:12:47
Done.
|
| #include "base/logging.h" |
| #include "base/memory/scoped_vector.h" |
| #include "base/metrics/field_trial.h" |
| @@ -14,6 +15,7 @@ |
| #include "base/strings/utf_string_conversions.h" |
| #include "components/autofill/core/common/autofill_data_validation.h" |
| #include "components/autofill/core/common/autofill_switches.h" |
| +#include "components/autofill/core/common/autofill_switches.h" |
|
Ilya Sherman
2014/10/21 01:19:11
Here too.
Evan Stade
2014/10/21 19:12:47
Done.
|
| #include "components/autofill/core/common/form_data.h" |
| #include "components/autofill/core/common/form_field_data.h" |
| #include "components/autofill/core/common/web_element_descriptor.h" |
| @@ -65,6 +67,13 @@ enum FieldFilterMask { |
| FILTER_NON_FOCUSABLE_ELEMENTS, |
| }; |
| +RequirementsMask ExtractionRequirements() { |
| + return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kIgnoreAutocompleteOffForAutofill) |
| + ? REQUIRE_NONE |
| + : REQUIRE_AUTOCOMPLETE; |
| +} |
| + |
| bool IsOptionElement(const WebElement& element) { |
| CR_DEFINE_STATIC_LOCAL(WebString, kOption, ("option")); |
| return element.hasHTMLTagName(kOption); |
| @@ -480,8 +489,8 @@ void ForEachMatchingFormField(const WebFormElement& form_element, |
| bool force_override, |
| Callback callback) { |
| std::vector<WebFormControlElement> control_elements; |
| - ExtractAutofillableElements(form_element, REQUIRE_AUTOCOMPLETE, |
| - &control_elements); |
| + ExtractAutofillableElements( |
| + form_element, ExtractionRequirements(), &control_elements); |
| if (control_elements.size() != data.fields.size()) { |
|
Ilya Sherman
2014/10/21 01:19:11
Hmm, did you also change which fields are extracte
Evan Stade
2014/10/21 19:12:47
good question. I think if there was a mismatch, it
Ilya Sherman
2014/10/21 23:58:18
Hmm, that's odd. Could you please do a bit of deb
|
| // This case should be reachable only for pathological websites and tests, |
| @@ -1054,8 +1063,8 @@ bool ClearPreviewedFormWithElement(const WebFormControlElement& element, |
| return false; |
| std::vector<WebFormControlElement> control_elements; |
| - ExtractAutofillableElements(form_element, REQUIRE_AUTOCOMPLETE, |
| - &control_elements); |
| + ExtractAutofillableElements( |
| + form_element, ExtractionRequirements(), &control_elements); |
|
Ilya Sherman
2014/10/21 01:19:11
We could probably just always pass REQUIRE_NONE he
Evan Stade
2014/10/21 19:12:47
ditto
|
| for (size_t i = 0; i < control_elements.size(); ++i) { |
| // There might be unrelated elements in this form which have already been |
| // auto-filled. For example, the user might have already filled the address |
| @@ -1114,8 +1123,8 @@ bool FormWithElementIsAutofilled(const WebInputElement& element) { |
| return false; |
| std::vector<WebFormControlElement> control_elements; |
| - ExtractAutofillableElements(form_element, REQUIRE_AUTOCOMPLETE, |
| - &control_elements); |
| + ExtractAutofillableElements( |
| + form_element, ExtractionRequirements(), &control_elements); |
|
Ilya Sherman
2014/10/21 01:19:11
We could probably just always pass REQUIRE_NONE he
Evan Stade
2014/10/21 19:12:47
ditto
|
| for (size_t i = 0; i < control_elements.size(); ++i) { |
| WebInputElement* input_element = toWebInputElement(&control_elements[i]); |
| if (!IsAutofillableInputElement(input_element)) |