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 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 } | 1359 } |
1360 | 1360 |
1361 void WebFormControlElementToFormField(const WebFormControlElement& element, | 1361 void WebFormControlElementToFormField(const WebFormControlElement& element, |
1362 ExtractMask extract_mask, | 1362 ExtractMask extract_mask, |
1363 FormFieldData* field) { | 1363 FormFieldData* field) { |
1364 DCHECK(field); | 1364 DCHECK(field); |
1365 DCHECK(!element.isNull()); | 1365 DCHECK(!element.isNull()); |
1366 CR_DEFINE_STATIC_LOCAL(WebString, kAutocomplete, ("autocomplete")); | 1366 CR_DEFINE_STATIC_LOCAL(WebString, kAutocomplete, ("autocomplete")); |
1367 CR_DEFINE_STATIC_LOCAL(WebString, kRole, ("role")); | 1367 CR_DEFINE_STATIC_LOCAL(WebString, kRole, ("role")); |
1368 CR_DEFINE_STATIC_LOCAL(WebString, kPlaceholder, ("placeholder")); | 1368 CR_DEFINE_STATIC_LOCAL(WebString, kPlaceholder, ("placeholder")); |
| 1369 CR_DEFINE_STATIC_LOCAL(WebString, kClass, ("class")); |
1369 | 1370 |
1370 // The label is not officially part of a WebFormControlElement; however, the | 1371 // The label is not officially part of a WebFormControlElement; however, the |
1371 // labels for all form control elements are scraped from the DOM and set in | 1372 // labels for all form control elements are scraped from the DOM and set in |
1372 // WebFormElementToFormData. | 1373 // WebFormElementToFormData. |
1373 field->name = element.nameForAutofill(); | 1374 field->name = element.nameForAutofill(); |
1374 field->form_control_type = element.formControlType().utf8(); | 1375 field->form_control_type = element.formControlType().utf8(); |
1375 field->autocomplete_attribute = element.getAttribute(kAutocomplete).utf8(); | 1376 field->autocomplete_attribute = element.getAttribute(kAutocomplete).utf8(); |
1376 if (field->autocomplete_attribute.size() > kMaxDataLength) { | 1377 if (field->autocomplete_attribute.size() > kMaxDataLength) { |
1377 // Discard overly long attribute values to avoid DOS-ing the browser | 1378 // Discard overly long attribute values to avoid DOS-ing the browser |
1378 // process. However, send over a default string to indicate that the | 1379 // process. However, send over a default string to indicate that the |
1379 // attribute was present. | 1380 // attribute was present. |
1380 field->autocomplete_attribute = "x-max-data-length-exceeded"; | 1381 field->autocomplete_attribute = "x-max-data-length-exceeded"; |
1381 } | 1382 } |
1382 if (base::LowerCaseEqualsASCII( | 1383 if (base::LowerCaseEqualsASCII( |
1383 base::StringPiece16(element.getAttribute(kRole)), "presentation")) | 1384 base::StringPiece16(element.getAttribute(kRole)), "presentation")) |
1384 field->role = FormFieldData::ROLE_ATTRIBUTE_PRESENTATION; | 1385 field->role = FormFieldData::ROLE_ATTRIBUTE_PRESENTATION; |
1385 | 1386 |
1386 field->placeholder = element.getAttribute(kPlaceholder); | 1387 field->placeholder = element.getAttribute(kPlaceholder); |
| 1388 if (element.hasAttribute(kClass)) |
| 1389 field->css_classes = element.getAttribute(kClass); |
1387 | 1390 |
1388 if (!IsAutofillableElement(element)) | 1391 if (!IsAutofillableElement(element)) |
1389 return; | 1392 return; |
1390 | 1393 |
1391 const WebInputElement* input_element = toWebInputElement(&element); | 1394 const WebInputElement* input_element = toWebInputElement(&element); |
1392 if (IsAutofillableInputElement(input_element) || | 1395 if (IsAutofillableInputElement(input_element) || |
1393 IsTextAreaElement(element) || | 1396 IsTextAreaElement(element) || |
1394 IsSelectElement(element)) { | 1397 IsSelectElement(element)) { |
1395 field->is_autofilled = element.isAutofilled(); | 1398 field->is_autofilled = element.isAutofilled(); |
1396 if (!g_prevent_layout) | 1399 if (!g_prevent_layout) |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 // Zero selection start is for password manager, which can show usernames | 1789 // Zero selection start is for password manager, which can show usernames |
1787 // that do not begin with the user input value. | 1790 // that do not begin with the user input value. |
1788 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1791 selection_start = (offset == base::string16::npos) ? 0 : offset; |
1789 } | 1792 } |
1790 | 1793 |
1791 input_element->setSelectionRange(selection_start, suggestion.length()); | 1794 input_element->setSelectionRange(selection_start, suggestion.length()); |
1792 } | 1795 } |
1793 | 1796 |
1794 } // namespace form_util | 1797 } // namespace form_util |
1795 } // namespace autofill | 1798 } // namespace autofill |
OLD | NEW |