| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 5 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/i18n/case_conversion.h" | 12 #include "base/i18n/case_conversion.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "components/autofill/content/renderer/form_autofill_util.h" | 21 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 22 #include "components/autofill/core/common/autofill_regex_constants.h" |
| 23 #include "components/autofill/core/common/autofill_regexes.h" |
| 22 #include "components/autofill/core/common/autofill_util.h" | 24 #include "components/autofill/core/common/autofill_util.h" |
| 23 #include "components/autofill/core/common/password_form.h" | 25 #include "components/autofill/core/common/password_form.h" |
| 24 #include "components/autofill/core/common/password_form_field_prediction_map.h" | 26 #include "components/autofill/core/common/password_form_field_prediction_map.h" |
| 25 #include "google_apis/gaia/gaia_urls.h" | 27 #include "google_apis/gaia/gaia_urls.h" |
| 26 #include "third_party/WebKit/public/platform/WebString.h" | 28 #include "third_party/WebKit/public/platform/WebString.h" |
| 27 #include "third_party/WebKit/public/platform/WebVector.h" | 29 #include "third_party/WebKit/public/platform/WebVector.h" |
| 28 #include "third_party/WebKit/public/web/WebDocument.h" | 30 #include "third_party/WebKit/public/web/WebDocument.h" |
| 29 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 31 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 30 #include "third_party/WebKit/public/web/WebFrame.h" | 32 #include "third_party/WebKit/public/web/WebFrame.h" |
| 31 #include "third_party/WebKit/public/web/WebInputElement.h" | 33 #include "third_party/WebKit/public/web/WebInputElement.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 size_t number_of_non_empty_text_non_password_fields = 0; | 424 size_t number_of_non_empty_text_non_password_fields = 0; |
| 423 for (size_t i = 0; i < form.control_elements.size(); ++i) { | 425 for (size_t i = 0; i < form.control_elements.size(); ++i) { |
| 424 WebFormControlElement control_element = form.control_elements[i]; | 426 WebFormControlElement control_element = form.control_elements[i]; |
| 425 | 427 |
| 426 WebInputElement* input_element = ToWebInputElement(&control_element); | 428 WebInputElement* input_element = ToWebInputElement(&control_element); |
| 427 if (!input_element || !input_element->IsEnabled()) | 429 if (!input_element || !input_element->IsEnabled()) |
| 428 continue; | 430 continue; |
| 429 | 431 |
| 430 if (HasCreditCardAutocompleteAttributes(*input_element)) | 432 if (HasCreditCardAutocompleteAttributes(*input_element)) |
| 431 continue; | 433 continue; |
| 434 if (IsCreditCardVerificationPasswordField(*input_element)) |
| 435 continue; |
| 432 | 436 |
| 433 bool element_is_invisible = !form_util::IsWebElementVisible(*input_element); | 437 bool element_is_invisible = !form_util::IsWebElementVisible(*input_element); |
| 434 if (input_element->IsTextField()) { | 438 if (input_element->IsTextField()) { |
| 435 if (input_element->IsPasswordField()) { | 439 if (input_element->IsPasswordField()) { |
| 436 if (element_is_invisible && ignore_invisible_passwords) | 440 if (element_is_invisible && ignore_invisible_passwords) |
| 437 continue; | 441 continue; |
| 438 layout_sequence.push_back('P'); | 442 layout_sequence.push_back('P'); |
| 439 } else { | 443 } else { |
| 440 if (FieldHasNonscriptModifiedValue(field_value_and_properties_map, | 444 if (FieldHasNonscriptModifiedValue(field_value_and_properties_map, |
| 441 *input_element)) | 445 *input_element)) |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 autocomplete_value_lowercase, base::kWhitespaceASCII, | 763 autocomplete_value_lowercase, base::kWhitespaceASCII, |
| 760 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { | 764 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { |
| 761 if (base::StartsWith(token, kAutocompleteCreditCardPrefix, | 765 if (base::StartsWith(token, kAutocompleteCreditCardPrefix, |
| 762 base::CompareCase::SENSITIVE)) { | 766 base::CompareCase::SENSITIVE)) { |
| 763 return true; | 767 return true; |
| 764 } | 768 } |
| 765 } | 769 } |
| 766 return false; | 770 return false; |
| 767 } | 771 } |
| 768 | 772 |
| 773 bool IsCreditCardVerificationPasswordField( |
| 774 const blink::WebInputElement& field) { |
| 775 if (!field.IsPasswordField()) |
| 776 return false; |
| 777 |
| 778 static const base::string16 kCardCvcReCached = base::UTF8ToUTF16(kCardCvcRe); |
| 779 |
| 780 return MatchesPattern(field.GetAttribute("id").Utf16(), kCardCvcReCached) || |
| 781 MatchesPattern(field.GetAttribute("name").Utf16(), kCardCvcReCached); |
| 782 } |
| 783 |
| 769 } // namespace autofill | 784 } // namespace autofill |
| OLD | NEW |