summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-19 00:28:55 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-19 00:28:55 +0000
commit2dd8e7fdab91dfbd1ed6478808f2aae5c2d9c064 (patch)
treee20154116affea06f0ca8ea16282b339c5d4daed /chrome/browser
parent0a85d7be7b67b07e2e20cd7bd16e0732aae831b9 (diff)
downloadchromium_src-2dd8e7fdab91dfbd1ed6478808f2aae5c2d9c064.zip
chromium_src-2dd8e7fdab91dfbd1ed6478808f2aae5c2d9c064.tar.gz
chromium_src-2dd8e7fdab91dfbd1ed6478808f2aae5c2d9c064.tar.bz2
Set the address field type based on how many address fields we encountered.
BUG=none TEST=none Review URL: http://codereview.chromium.org/501092 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35011 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autofill/form_field.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/chrome/browser/autofill/form_field.cc b/chrome/browser/autofill/form_field.cc
index e6e375b..4d4c76f 100644
--- a/chrome/browser/autofill/form_field.cc
+++ b/chrome/browser/autofill/form_field.cc
@@ -135,6 +135,10 @@ string16 FormField::GetEcmlPattern(const string16& ecml_name1,
}
FormFieldSet::FormFieldSet(FormStructure* fields) {
+ std::vector<AddressField*> addresses;
+
+ // First, find if there is one form field with an ECML name. If there is,
+ // then we will match an element only if it is in the standard.
bool is_ecml = CheckECML(fields);
// Parse fields.
@@ -147,6 +151,29 @@ FormFieldSet::FormFieldSet(FormStructure* fields) {
}
push_back(form_field);
+
+ if (form_field->GetFormFieldType() == kAddressType) {
+ AddressField* address = static_cast<AddressField*>(form_field);
+ if (address->IsFullAddress())
+ addresses.push_back(address);
+ }
+ }
+
+ // Now determine an address type for each address. Note, if this is an ECML
+ // form, then we already got this info from the field names.
+ if (!is_ecml && !addresses.empty()) {
+ if (addresses.size() == 1) {
+ addresses[0]->SetType(addresses[0]->FindType());
+ } else {
+ AddressType type0 = addresses[0]->FindType();
+ AddressType type1 = addresses[1]->FindType();
+
+ // When there are two addresses on a page, they almost always appear in
+ // the order (billing, shipping).
+ bool reversed = (type0 == kShippingAddress && type1 == kBillingAddress);
+ addresses[0]->SetType(reversed ? kShippingAddress : kBillingAddress);
+ addresses[1]->SetType(reversed ? kBillingAddress : kShippingAddress);
+ }
}
}