Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: components/autofill/content/renderer/form_autofill_util.cc

Issue 2022123002: Merge autofill::FormFieldData::is_checkable and is_checked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 blink::WebFormControlElement* field) { 882 blink::WebFormControlElement* field) {
883 // Nothing to fill. 883 // Nothing to fill.
884 if (data.value.empty()) 884 if (data.value.empty())
885 return; 885 return;
886 886
887 if (!data.is_autofilled) 887 if (!data.is_autofilled)
888 return; 888 return;
889 889
890 WebInputElement* input_element = toWebInputElement(field); 890 WebInputElement* input_element = toWebInputElement(field);
891 if (IsCheckableElement(input_element)) { 891 if (IsCheckableElement(input_element)) {
892 input_element->setChecked(data.is_checked, true); 892 input_element->setChecked(IsChecked(data.check_status), true);
893 } else { 893 } else {
894 base::string16 value = data.value; 894 base::string16 value = data.value;
895 if (IsTextInput(input_element) || IsMonthInput(input_element)) { 895 if (IsTextInput(input_element) || IsMonthInput(input_element)) {
896 // If the maxlength attribute contains a negative value, maxLength() 896 // If the maxlength attribute contains a negative value, maxLength()
897 // returns the default maxlength value. 897 // returns the default maxlength value.
898 TruncateString(&value, input_element->maxLength()); 898 TruncateString(&value, input_element->maxLength());
899 } 899 }
900 field->setAutofillValue(value); 900 field->setAutofillValue(value);
901 } 901 }
902 // Setting the form might trigger JavaScript, which is capable of 902 // Setting the form might trigger JavaScript, which is capable of
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 field->is_focusable = element.isFocusable(); 1397 field->is_focusable = element.isFocusable();
1398 field->should_autocomplete = element.autoComplete(); 1398 field->should_autocomplete = element.autoComplete();
1399 field->text_direction = element.directionForFormData() == 1399 field->text_direction = element.directionForFormData() ==
1400 "rtl" ? base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT; 1400 "rtl" ? base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT;
1401 } 1401 }
1402 1402
1403 if (IsAutofillableInputElement(input_element)) { 1403 if (IsAutofillableInputElement(input_element)) {
1404 if (IsTextInput(input_element)) 1404 if (IsTextInput(input_element))
1405 field->max_length = input_element->maxLength(); 1405 field->max_length = input_element->maxLength();
1406 1406
1407 field->is_checkable = IsCheckableElement(input_element); 1407 SetCheckStatus(field, IsCheckableElement(input_element),
1408 field->is_checked = input_element->isChecked(); 1408 input_element->isChecked());
1409 } else if (IsTextAreaElement(element)) { 1409 } else if (IsTextAreaElement(element)) {
1410 // Nothing more to do in this case. 1410 // Nothing more to do in this case.
1411 } else if (extract_mask & EXTRACT_OPTIONS) { 1411 } else if (extract_mask & EXTRACT_OPTIONS) {
1412 // Set option strings on the field if available. 1412 // Set option strings on the field if available.
1413 DCHECK(IsSelectElement(element)); 1413 DCHECK(IsSelectElement(element));
1414 const WebSelectElement select_element = element.toConst<WebSelectElement>(); 1414 const WebSelectElement select_element = element.toConst<WebSelectElement>();
1415 GetOptionStringsFromElement(select_element, 1415 GetOptionStringsFromElement(select_element,
1416 &field->option_values, 1416 &field->option_values,
1417 &field->option_contents); 1417 &field->option_contents);
1418 } 1418 }
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 // Zero selection start is for password manager, which can show usernames 1786 // Zero selection start is for password manager, which can show usernames
1787 // that do not begin with the user input value. 1787 // that do not begin with the user input value.
1788 selection_start = (offset == base::string16::npos) ? 0 : offset; 1788 selection_start = (offset == base::string16::npos) ? 0 : offset;
1789 } 1789 }
1790 1790
1791 input_element->setSelectionRange(selection_start, suggestion.length()); 1791 input_element->setSelectionRange(selection_start, suggestion.length());
1792 } 1792 }
1793 1793
1794 } // namespace form_util 1794 } // namespace form_util
1795 } // namespace autofill 1795 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/common/autofill_messages.h ('k') | components/autofill/core/browser/autofill_metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698