summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 19:53:23 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 19:53:23 +0000
commit41e342f3745b27ba8eeaa87187e3465de484c2a4 (patch)
tree450e86b869f04fe823e0a28465d7899ce0b9f590 /chrome/browser/autofill
parente8cf47b31dde03bf5e14d10af9834eaf12cba3c5 (diff)
downloadchromium_src-41e342f3745b27ba8eeaa87187e3465de484c2a4.zip
chromium_src-41e342f3745b27ba8eeaa87187e3465de484c2a4.tar.gz
chromium_src-41e342f3745b27ba8eeaa87187e3465de484c2a4.tar.bz2
Fix for: State in small letters should be auto-filled from the profile.
BUG=38222 TEST=in the bug Patch by George Yakovleg <georgey@chromium.org> Review URL: http://codereview.chromium.org/2832064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_manager.cc30
-rw-r--r--chrome/browser/autofill/autofill_manager.h7
2 files changed, 36 insertions, 1 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index d1c2950..127cc56 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -643,10 +643,38 @@ void AutoFillManager::FillFormField(const AutoFillProfile* profile,
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
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index fe4d7bd..f6574d1 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -141,6 +141,13 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
AutoFillType type,
webkit_glue::FormField* field);
+ // Select matching data in the |field|. For now only fixes the cases of the
+ // wrong case, in the future should do extended matching (for example,
+ // Hawaii -> HI).
+ void FillSelectOneField(const AutoFillProfile* profile,
+ AutoFillType type,
+ webkit_glue::FormField* field);
+
// Set |field| argument's value for phone number based on contents of the
// |profile|.
void FillPhoneNumberField(const AutoFillProfile* profile,