Index: chrome/browser/autofill/autofill_manager.cc |
=================================================================== |
--- chrome/browser/autofill/autofill_manager.cc (revision 52815) |
+++ chrome/browser/autofill/autofill_manager.cc (working copy) |
@@ -620,10 +620,38 @@ |
if (type.subgroup() == AutoFillType::PHONE_NUMBER) { |
FillPhoneNumberField(profile, field); |
} else { |
- field->set_value(profile->GetFieldText(type)); |
+ if (field->form_control_type() == ASCIIToUTF16("select-one")) |
+ FillSelectOneField(profile, type, field); |
+ else |
+ field->set_value(profile->GetFieldText(type)); |
} |
} |
+void AutoFillManager::FillSelectOneField(const AutoFillProfile* profile, |
+ AutoFillType type, |
+ webkit_glue::FormField* field) { |
+ DCHECK(profile); |
+ DCHECK(field); |
+ DCHECK(field->form_control_type() == ASCIIToUTF16("select-one")); |
+ string16 selected_string = profile->GetFieldText(type); |
+ std::string ascii_value = UTF16ToASCII(selected_string); |
+ for (size_t i = 0; i < field->option_strings().size(); ++i) { |
+ if (profile->GetFieldText(type) == field->option_strings()[i]) { |
+ // An exact match - use it. |
+ selected_string = profile->GetFieldText(type); |
+ break; |
+ } |
+ if (!base::strcasecmp(UTF16ToASCII(field->option_strings()[i]).c_str(), |
+ ascii_value.c_str())) { |
+ // A match, but not in the same case - save it for the case we won't |
+ // find an exact match. |
+ selected_string = field->option_strings()[i]; |
+ } |
+ } |
+ field->set_value(selected_string); |
+} |
+ |
+ |
void AutoFillManager::FillPhoneNumberField(const AutoFillProfile* profile, |
webkit_glue::FormField* field) { |
// If we are filling a phone number, check to see if the size field |