Chromium Code Reviews| 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 <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 void WebFormControlElementToFormField( | 1361 void WebFormControlElementToFormField( |
| 1362 const WebFormControlElement& element, | 1362 const WebFormControlElement& element, |
| 1363 const FieldValueAndPropertiesMaskMap* field_value_and_properties_map, | 1363 const FieldValueAndPropertiesMaskMap* field_value_and_properties_map, |
| 1364 ExtractMask extract_mask, | 1364 ExtractMask extract_mask, |
| 1365 FormFieldData* field) { | 1365 FormFieldData* field) { |
| 1366 DCHECK(field); | 1366 DCHECK(field); |
| 1367 DCHECK(!element.isNull()); | 1367 DCHECK(!element.isNull()); |
| 1368 CR_DEFINE_STATIC_LOCAL(WebString, kAutocomplete, ("autocomplete")); | 1368 CR_DEFINE_STATIC_LOCAL(WebString, kAutocomplete, ("autocomplete")); |
| 1369 CR_DEFINE_STATIC_LOCAL(WebString, kId, ("id")); | |
| 1369 CR_DEFINE_STATIC_LOCAL(WebString, kRole, ("role")); | 1370 CR_DEFINE_STATIC_LOCAL(WebString, kRole, ("role")); |
| 1370 CR_DEFINE_STATIC_LOCAL(WebString, kPlaceholder, ("placeholder")); | 1371 CR_DEFINE_STATIC_LOCAL(WebString, kPlaceholder, ("placeholder")); |
| 1371 CR_DEFINE_STATIC_LOCAL(WebString, kClass, ("class")); | 1372 CR_DEFINE_STATIC_LOCAL(WebString, kClass, ("class")); |
| 1372 | 1373 |
| 1373 // The label is not officially part of a WebFormControlElement; however, the | 1374 // The label is not officially part of a WebFormControlElement; however, the |
| 1374 // labels for all form control elements are scraped from the DOM and set in | 1375 // labels for all form control elements are scraped from the DOM and set in |
| 1375 // WebFormElementToFormData. | 1376 // WebFormElementToFormData. |
| 1376 field->name = element.nameForAutofill(); | 1377 field->name = element.nameForAutofill(); |
| 1378 base::string16 id = element.getAttribute(kId); | |
| 1379 if (id != field->name) | |
|
sebsg
2017/01/18 19:22:49
Can you also just make a quick note or refer to HT
kolos1
2017/01/19 11:09:16
Done.
Also removed the comment about the label. A
| |
| 1380 field->id = id; | |
| 1377 field->form_control_type = element.formControlType().utf8(); | 1381 field->form_control_type = element.formControlType().utf8(); |
| 1378 field->autocomplete_attribute = element.getAttribute(kAutocomplete).utf8(); | 1382 field->autocomplete_attribute = element.getAttribute(kAutocomplete).utf8(); |
| 1379 if (field->autocomplete_attribute.size() > kMaxDataLength) { | 1383 if (field->autocomplete_attribute.size() > kMaxDataLength) { |
| 1380 // Discard overly long attribute values to avoid DOS-ing the browser | 1384 // Discard overly long attribute values to avoid DOS-ing the browser |
| 1381 // process. However, send over a default string to indicate that the | 1385 // process. However, send over a default string to indicate that the |
| 1382 // attribute was present. | 1386 // attribute was present. |
| 1383 field->autocomplete_attribute = "x-max-data-length-exceeded"; | 1387 field->autocomplete_attribute = "x-max-data-length-exceeded"; |
| 1384 } | 1388 } |
| 1385 if (base::LowerCaseEqualsASCII( | 1389 if (base::LowerCaseEqualsASCII( |
| 1386 base::StringPiece16(element.getAttribute(kRole)), "presentation")) | 1390 base::StringPiece16(element.getAttribute(kRole)), "presentation")) |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1806 // Zero selection start is for password manager, which can show usernames | 1810 // Zero selection start is for password manager, which can show usernames |
| 1807 // that do not begin with the user input value. | 1811 // that do not begin with the user input value. |
| 1808 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1812 selection_start = (offset == base::string16::npos) ? 0 : offset; |
| 1809 } | 1813 } |
| 1810 | 1814 |
| 1811 input_element->setSelectionRange(selection_start, suggestion.length()); | 1815 input_element->setSelectionRange(selection_start, suggestion.length()); |
| 1812 } | 1816 } |
| 1813 | 1817 |
| 1814 } // namespace form_util | 1818 } // namespace form_util |
| 1815 } // namespace autofill | 1819 } // namespace autofill |
| OLD | NEW |