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

Unified Diff: chrome/browser/autofill/autofill_manager.cc

Issue 2832064: Fix for: State in small letters should be auto-filled from the profile.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698