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 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 autofillable_elements->push_back(element); | 774 autofillable_elements->push_back(element); |
775 } | 775 } |
776 } | 776 } |
777 | 777 |
778 void WebFormControlElementToFormField(const WebFormControlElement& element, | 778 void WebFormControlElementToFormField(const WebFormControlElement& element, |
779 ExtractMask extract_mask, | 779 ExtractMask extract_mask, |
780 FormFieldData* field) { | 780 FormFieldData* field) { |
781 DCHECK(field); | 781 DCHECK(field); |
782 DCHECK(!element.isNull()); | 782 DCHECK(!element.isNull()); |
783 CR_DEFINE_STATIC_LOCAL(WebString, kAutocomplete, ("autocomplete")); | 783 CR_DEFINE_STATIC_LOCAL(WebString, kAutocomplete, ("autocomplete")); |
| 784 CR_DEFINE_STATIC_LOCAL(WebString, kRole, ("role")); |
784 | 785 |
785 // The label is not officially part of a WebFormControlElement; however, the | 786 // The label is not officially part of a WebFormControlElement; however, the |
786 // labels for all form control elements are scraped from the DOM and set in | 787 // labels for all form control elements are scraped from the DOM and set in |
787 // WebFormElementToFormData. | 788 // WebFormElementToFormData. |
788 field->name = element.nameForAutofill(); | 789 field->name = element.nameForAutofill(); |
789 field->form_control_type = base::UTF16ToUTF8(element.formControlType()); | 790 field->form_control_type = base::UTF16ToUTF8(element.formControlType()); |
790 field->autocomplete_attribute = | 791 field->autocomplete_attribute = |
791 base::UTF16ToUTF8(element.getAttribute(kAutocomplete)); | 792 base::UTF16ToUTF8(element.getAttribute(kAutocomplete)); |
792 if (field->autocomplete_attribute.size() > kMaxDataLength) { | 793 if (field->autocomplete_attribute.size() > kMaxDataLength) { |
793 // Discard overly long attribute values to avoid DOS-ing the browser | 794 // Discard overly long attribute values to avoid DOS-ing the browser |
794 // process. However, send over a default string to indicate that the | 795 // process. However, send over a default string to indicate that the |
795 // attribute was present. | 796 // attribute was present. |
796 field->autocomplete_attribute = "x-max-data-length-exceeded"; | 797 field->autocomplete_attribute = "x-max-data-length-exceeded"; |
797 } | 798 } |
| 799 field->role = base::UTF16ToUTF8(element.getAttribute(kRole)); |
| 800 if (field->role.size() > kMaxDataLength) { |
| 801 field->role = "x-max-data-length-exceeded"; |
| 802 } |
798 | 803 |
799 if (!IsAutofillableElement(element)) | 804 if (!IsAutofillableElement(element)) |
800 return; | 805 return; |
801 | 806 |
802 const WebInputElement* input_element = toWebInputElement(&element); | 807 const WebInputElement* input_element = toWebInputElement(&element); |
803 if (IsAutofillableInputElement(input_element) || | 808 if (IsAutofillableInputElement(input_element) || |
804 IsTextAreaElement(element)) { | 809 IsTextAreaElement(element)) { |
805 field->is_autofilled = element.isAutofilled(); | 810 field->is_autofilled = element.isAutofilled(); |
806 field->is_focusable = element.isFocusable(); | 811 field->is_focusable = element.isFocusable(); |
807 field->should_autocomplete = element.autoComplete(); | 812 field->should_autocomplete = element.autoComplete(); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 | 1190 |
1186 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { | 1191 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { |
1187 gfx::Rect bounding_box(element->boundsInViewportSpace()); | 1192 gfx::Rect bounding_box(element->boundsInViewportSpace()); |
1188 return gfx::RectF(bounding_box.x() * scale, | 1193 return gfx::RectF(bounding_box.x() * scale, |
1189 bounding_box.y() * scale, | 1194 bounding_box.y() * scale, |
1190 bounding_box.width() * scale, | 1195 bounding_box.width() * scale, |
1191 bounding_box.height() * scale); | 1196 bounding_box.height() * scale); |
1192 } | 1197 } |
1193 | 1198 |
1194 } // namespace autofill | 1199 } // namespace autofill |
OLD | NEW |