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/core/browser/autofill_field.h" | 5 #include "components/autofill/core/browser/autofill_field.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 return false; | 163 return false; |
164 } | 164 } |
165 | 165 |
166 // Try to fill a credit card type |value| (Visa, MasterCard, etc.) into the | 166 // Try to fill a credit card type |value| (Visa, MasterCard, etc.) into the |
167 // given |field|. | 167 // given |field|. |
168 bool FillCreditCardTypeSelectControl(const base::string16& value, | 168 bool FillCreditCardTypeSelectControl(const base::string16& value, |
169 FormFieldData* field) { | 169 FormFieldData* field) { |
170 // Try stripping off spaces. | 170 // Try stripping off spaces. |
171 base::string16 value_stripped; | 171 base::string16 value_stripped; |
172 RemoveChars(StringToLowerASCII(value), kWhitespaceUTF16, &value_stripped); | 172 RemoveChars(StringToLowerASCII(value), base::kWhitespaceUTF16, |
| 173 &value_stripped); |
173 | 174 |
174 for (size_t i = 0; i < field->option_values.size(); ++i) { | 175 for (size_t i = 0; i < field->option_values.size(); ++i) { |
175 base::string16 option_value_lowercase; | 176 base::string16 option_value_lowercase; |
176 RemoveChars(StringToLowerASCII(field->option_values[i]), kWhitespaceUTF16, | 177 RemoveChars(StringToLowerASCII(field->option_values[i]), |
177 &option_value_lowercase); | 178 base::kWhitespaceUTF16, &option_value_lowercase); |
178 base::string16 option_contents_lowercase; | 179 base::string16 option_contents_lowercase; |
179 RemoveChars(StringToLowerASCII(field->option_contents[i]), kWhitespaceUTF16, | 180 RemoveChars(StringToLowerASCII(field->option_contents[i]), |
180 &option_contents_lowercase); | 181 base::kWhitespaceUTF16, &option_contents_lowercase); |
181 | 182 |
182 // Perform a case-insensitive comparison; but fill the form with the | 183 // Perform a case-insensitive comparison; but fill the form with the |
183 // original text, not the lowercased version. | 184 // original text, not the lowercased version. |
184 if (value_stripped == option_value_lowercase || | 185 if (value_stripped == option_value_lowercase || |
185 value_stripped == option_contents_lowercase) { | 186 value_stripped == option_contents_lowercase) { |
186 field->value = field->option_values[i]; | 187 field->value = field->option_values[i]; |
187 return true; | 188 return true; |
188 } | 189 } |
189 } | 190 } |
190 | 191 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 FillSelectControl(type, value, app_locale, field_data); | 400 FillSelectControl(type, value, app_locale, field_data); |
400 else if (field_data->form_control_type == "month") | 401 else if (field_data->form_control_type == "month") |
401 FillMonthControl(value, field_data); | 402 FillMonthControl(value, field_data); |
402 else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) | 403 else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) |
403 FillStreetAddress(value, field_data); | 404 FillStreetAddress(value, field_data); |
404 else | 405 else |
405 field_data->value = value; | 406 field_data->value = value; |
406 } | 407 } |
407 | 408 |
408 } // namespace autofill | 409 } // namespace autofill |
OLD | NEW |