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/form_autofill_util.h" | 5 #include "components/autofill/content/renderer/form_autofill_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 // rename form fields while the user is interacting with the Autofill | 798 // rename form fields while the user is interacting with the Autofill |
799 // popup. I (isherman) am not aware of any such websites, and so am | 799 // popup. I (isherman) am not aware of any such websites, and so am |
800 // optimistically including a NOTREACHED(). If you ever trip this check, | 800 // optimistically including a NOTREACHED(). If you ever trip this check, |
801 // please file a bug against me. | 801 // please file a bug against me. |
802 NOTREACHED(); | 802 NOTREACHED(); |
803 continue; | 803 continue; |
804 } | 804 } |
805 | 805 |
806 bool is_initiating_element = (*element == initiating_element); | 806 bool is_initiating_element = (*element == initiating_element); |
807 | 807 |
808 // Only autofill empty fields and the field that initiated the filling, | 808 // Only autofill empty fields (or those with the field's default value |
809 // i.e. the field the user is currently editing and interacting with. | 809 // attribute) and the field that initiated the filling, i.e. the field the |
| 810 // user is currently editing and interacting with. |
810 const WebInputElement* input_element = toWebInputElement(element); | 811 const WebInputElement* input_element = toWebInputElement(element); |
| 812 CR_DEFINE_STATIC_LOCAL(WebString, kValue, ("value")); |
811 if (!force_override && !is_initiating_element && | 813 if (!force_override && !is_initiating_element && |
812 ((IsAutofillableInputElement(input_element) || | 814 // A text field, with a non-empty value that is NOT the value of the |
813 IsTextAreaElement(*element)) && | 815 // input field's "value" attribute, is skipped. |
814 !element->value().isEmpty())) | 816 (IsAutofillableInputElement(input_element) || |
| 817 IsTextAreaElement(*element)) && |
| 818 !element->value().isEmpty() && |
| 819 (!element->hasAttribute(kValue) || |
| 820 element->getAttribute(kValue) != element->value())) |
815 continue; | 821 continue; |
816 | 822 |
817 if (((filters & FILTER_DISABLED_ELEMENTS) && !element->isEnabled()) || | 823 if (((filters & FILTER_DISABLED_ELEMENTS) && !element->isEnabled()) || |
818 ((filters & FILTER_READONLY_ELEMENTS) && element->isReadOnly()) || | 824 ((filters & FILTER_READONLY_ELEMENTS) && element->isReadOnly()) || |
819 // See description for FILTER_NON_FOCUSABLE_ELEMENTS. | 825 // See description for FILTER_NON_FOCUSABLE_ELEMENTS. |
820 ((filters & FILTER_NON_FOCUSABLE_ELEMENTS) && !element->isFocusable() && | 826 ((filters & FILTER_NON_FOCUSABLE_ELEMENTS) && !element->isFocusable() && |
821 !IsSelectElement(*element))) | 827 !IsSelectElement(*element))) |
822 continue; | 828 continue; |
823 | 829 |
824 callback(data.fields[i], is_initiating_element, element); | 830 callback(data.fields[i], is_initiating_element, element); |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 // Zero selection start is for password manager, which can show usernames | 1757 // Zero selection start is for password manager, which can show usernames |
1752 // that do not begin with the user input value. | 1758 // that do not begin with the user input value. |
1753 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1759 selection_start = (offset == base::string16::npos) ? 0 : offset; |
1754 } | 1760 } |
1755 | 1761 |
1756 input_element->setSelectionRange(selection_start, suggestion.length()); | 1762 input_element->setSelectionRange(selection_start, suggestion.length()); |
1757 } | 1763 } |
1758 | 1764 |
1759 } // namespace form_util | 1765 } // namespace form_util |
1760 } // namespace autofill | 1766 } // namespace autofill |
OLD | NEW |