summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-14 19:21:18 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-14 19:21:18 +0000
commitee0e2d945e34a794f5268137f71fc9e7d1cdc82b (patch)
treeceac50e53dc7d55b85e9ca2d0ab359fa9a236deb /chrome/browser/autofill
parent1b2b9e175adf3b51215ca88f75ea66605f74ef33 (diff)
downloadchromium_src-ee0e2d945e34a794f5268137f71fc9e7d1cdc82b.zip
chromium_src-ee0e2d945e34a794f5268137f71fc9e7d1cdc82b.tar.gz
chromium_src-ee0e2d945e34a794f5268137f71fc9e7d1cdc82b.tar.bz2
Form AutoFill Phone number should be displayed as xxx-xxx-xxxx
Modifies the AutoFill label inferencing logic to skip over <img> tags when deriving labels. It is common to use small images as spacers between elements. Also, extends the phone number heuristics to recognize numbers that are split into three fields of the form [xxx]-[yyy]-[zzzz] where xxx is the area code, yyy is the phone number prefix and zzz is the phone number suffix. Note: This change has a dependency on WebKit change: https://bugs.webkit.org/show_bug.cgi?id=38825. Will need to wait for that to land before committing this change. BUG=38218 TEST=FormManagerTest.LabelsInferredWithImageTags:FormStructureTest.ThreePartPhoneNumber:PhoneFieldTest.ThreePartPhoneNumber Review URL: http://codereview.chromium.org/1979008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/address_field_unittest.cc57
-rw-r--r--chrome/browser/autofill/autofill_download_unittest.cc33
-rw-r--r--chrome/browser/autofill/autofill_manager.cc39
-rw-r--r--chrome/browser/autofill/autofill_manager.h10
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc2
-rw-r--r--chrome/browser/autofill/credit_card_field_unittest.cc81
-rw-r--r--chrome/browser/autofill/fax_field_unittest.cc3
-rw-r--r--chrome/browser/autofill/form_structure_unittest.cc289
-rw-r--r--chrome/browser/autofill/name_field_unittest.cc39
-rw-r--r--chrome/browser/autofill/phone_field.cc20
-rw-r--r--chrome/browser/autofill/phone_field_unittest.cc69
11 files changed, 477 insertions, 165 deletions
diff --git a/chrome/browser/autofill/address_field_unittest.cc b/chrome/browser/autofill/address_field_unittest.cc
index 8b82dda..7e3c2dd 100644
--- a/chrome/browser/autofill/address_field_unittest.cc
+++ b/chrome/browser/autofill/address_field_unittest.cc
@@ -44,7 +44,8 @@ TEST_F(AddressFieldTest, ParseOneLineAddress) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -63,7 +64,8 @@ TEST_F(AddressFieldTest, ParseOneLineAddressEcml) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
kEcmlShipToAddress1,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -82,13 +84,15 @@ TEST_F(AddressFieldTest, ParseTwoLineAddress) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
string16(),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -110,19 +114,22 @@ TEST_F(AddressFieldTest, ParseThreeLineAddress) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address Line3"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -146,13 +153,15 @@ TEST_F(AddressFieldTest, ParseTwoLineAddressEcml) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
kEcmlShipToAddress1,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
kEcmlShipToAddress2,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -174,7 +183,8 @@ TEST_F(AddressFieldTest, ParseCity) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("city1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -193,7 +203,8 @@ TEST_F(AddressFieldTest, ParseCityEcml) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("City"),
kEcmlShipToCity,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("city1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -212,7 +223,8 @@ TEST_F(AddressFieldTest, ParseState) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("State"),
ASCIIToUTF16("state"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("state1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -231,7 +243,8 @@ TEST_F(AddressFieldTest, ParseStateEcml) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("State"),
kEcmlShipToStateProv,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("state1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -250,7 +263,8 @@ TEST_F(AddressFieldTest, ParseZip) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Zip"),
ASCIIToUTF16("zip"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("zip1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -269,7 +283,8 @@ TEST_F(AddressFieldTest, ParseZipEcml) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Zip"),
kEcmlShipToPostalCode,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("zip1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -288,7 +303,8 @@ TEST_F(AddressFieldTest, ParseCountry) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Country"),
ASCIIToUTF16("country"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("country1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -307,7 +323,8 @@ TEST_F(AddressFieldTest, ParseCountryEcml) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Country"),
kEcmlShipToCountry,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("country1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -326,13 +343,15 @@ TEST_F(AddressFieldTest, ParseTwoLineAddressMissingLabel) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("bogus"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("addr2")));
list_.push_back(NULL);
iter_ = list_.begin();
diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc
index 085059f..3074ecd 100644
--- a/chrome/browser/autofill/autofill_download_unittest.cc
+++ b/chrome/browser/autofill/autofill_download_unittest.cc
@@ -98,31 +98,38 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
ASCIIToUTF16("username"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("firstname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email"),
ASCIIToUTF16("email"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email2"),
ASCIIToUTF16("email2"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
- ASCIIToUTF16("password")));
+ ASCIIToUTF16("password"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
FormStructure *form_structure = new FormStructure(form);
ScopedVector<FormStructure> form_structures;
@@ -132,19 +139,23 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("address"),
ASCIIToUTF16("address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("address2"),
ASCIIToUTF16("address2"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("city"),
ASCIIToUTF16("address2"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure = new FormStructure(form);
form_structures.push_back(form_structure);
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 8ba0030..5c49249 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -27,6 +27,12 @@ namespace {
// The rate for positive/negative matches potentially could be different.
const double kAutoFillPositiveUploadRateDefaultValue = 0.01;
const double kAutoFillNegativeUploadRateDefaultValue = 0.01;
+
+// Size and offset of the prefix and suffix portions of phone numbers.
+const int kAutoFillPhoneNumberPrefixOffset = 0;
+const int kAutoFillPhoneNumberPrefixCount = 3;
+const int kAutoFillPhoneNumberSuffixOffset = 3;
+const int kAutoFillPhoneNumberSuffixCount = 4;
} // namespace
// TODO(jhawkins): Maybe this should be in a grd file?
@@ -239,7 +245,7 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
result.fields[i].set_value(
credit_card->GetFieldText(autofill_type));
} else if (profile) {
- result.fields[i].set_value(profile->GetFieldText(autofill_type));
+ FillFormField(profile, autofill_type, &result.fields[i]);
}
}
}
@@ -459,3 +465,34 @@ void AutoFillManager::GetCreditCardSuggestions(const FormField& field,
}
}
}
+
+void AutoFillManager::FillFormField(const AutoFillProfile* profile,
+ AutoFillType type,
+ webkit_glue::FormField* field) {
+ DCHECK(profile);
+ DCHECK(field);
+
+ if (type.subgroup() == AutoFillType::PHONE_NUMBER) {
+ FillPhoneNumberField(profile, field);
+ } else {
+ field->set_value(profile->GetFieldText(type));
+ }
+}
+
+void AutoFillManager::FillPhoneNumberField(const AutoFillProfile* profile,
+ webkit_glue::FormField* field) {
+ // If we are filling a phone number, check to see if the size field
+ // matches the "prefix" or "suffix" sizes and fill accordingly.
+ string16 number = profile->GetFieldText(AutoFillType(PHONE_HOME_NUMBER));
+ if (field->size() == kAutoFillPhoneNumberPrefixCount) {
+ number = number.substr(kAutoFillPhoneNumberPrefixOffset,
+ kAutoFillPhoneNumberPrefixCount);
+ field->set_value(number);
+ } else if (field->size() == kAutoFillPhoneNumberSuffixCount) {
+ number = number.substr(kAutoFillPhoneNumberSuffixOffset,
+ kAutoFillPhoneNumberSuffixCount);
+ field->set_value(number);
+ } else {
+ field->set_value(number);
+ }
+}
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index 0a7a523..c33ae7e 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -115,6 +115,16 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
std::vector<string16>* values,
std::vector<string16>* labels);
+ // Set |field| argument's value based on |type| and contents of the |profile|.
+ void FillFormField(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,
+ webkit_glue::FormField* field);
+
// The TabContents hosting this AutoFillManager.
// Weak reference.
// May not be NULL.
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 1997a3c..cbb050a 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -95,7 +95,7 @@ void CreateTestFormField(const char* label,
const char* type,
webkit_glue::FormField* field) {
*field = webkit_glue::FormField(ASCIIToUTF16(label), ASCIIToUTF16(name),
- ASCIIToUTF16(value), ASCIIToUTF16(type));
+ ASCIIToUTF16(value), ASCIIToUTF16(type), 0);
}
void CreateTestFormData(FormData* form) {
diff --git a/chrome/browser/autofill/credit_card_field_unittest.cc b/chrome/browser/autofill/credit_card_field_unittest.cc
index e972c62..684ac78 100644
--- a/chrome/browser/autofill/credit_card_field_unittest.cc
+++ b/chrome/browser/autofill/credit_card_field_unittest.cc
@@ -44,13 +44,15 @@ TEST_F(CreditCardFieldTest, ParseCreditCardNoNumber) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("year1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -63,7 +65,8 @@ TEST_F(CreditCardFieldTest, ParseCreditCardNoDate) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("number1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -76,19 +79,22 @@ TEST_F(CreditCardFieldTest, ParseMiniumCreditCard) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("number1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("year1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -112,19 +118,22 @@ TEST_F(CreditCardFieldTest, ParseMiniumCreditCardEcml) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
kEcmlCardNumber,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("number1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
kEcmlCardExpireMonth,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
kEcmlCardExpireYear,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("year1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -148,31 +157,36 @@ TEST_F(CreditCardFieldTest, ParseFullCreditCard) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
ASCIIToUTF16("name on card"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("number1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("year1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Verification"),
ASCIIToUTF16("verification"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("cvc1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -203,31 +217,36 @@ TEST_F(CreditCardFieldTest, ParseFullCreditCardEcml) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
kEcmlCardHolder,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
kEcmlCardNumber,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("number1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
kEcmlCardExpireMonth,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("month1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
kEcmlCardExpireYear,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("year1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Verification"),
kEcmlCardVerification,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("cvc1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -258,27 +277,31 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
ASCIIToUTF16("Name"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("Card"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("number")));
list_.push_back(
new AutoFillField(
webkit_glue::FormField(ASCIIToUTF16("ExpDate Month / Year"),
ASCIIToUTF16("ExpDate"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("month")));
list_.push_back(
new AutoFillField(
webkit_glue::FormField(ASCIIToUTF16("ExpDate Month / Year"),
ASCIIToUTF16("ExpDate"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("year")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -305,27 +328,31 @@ TEST_F(CreditCardFieldTest, ParseExpMonthYear2) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
ASCIIToUTF16("Name"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("Card"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("number")));
list_.push_back(
new AutoFillField(
webkit_glue::FormField(ASCIIToUTF16("Expiration date Month / Year"),
ASCIIToUTF16("ExpDate"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("month")));
list_.push_back(
new AutoFillField(
webkit_glue::FormField(ASCIIToUTF16("Expiration date Month / Year"),
ASCIIToUTF16("ExpDate"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("year")));
list_.push_back(NULL);
iter_ = list_.begin();
diff --git a/chrome/browser/autofill/fax_field_unittest.cc b/chrome/browser/autofill/fax_field_unittest.cc
index 4cccac4..258f8d0 100644
--- a/chrome/browser/autofill/fax_field_unittest.cc
+++ b/chrome/browser/autofill/fax_field_unittest.cc
@@ -44,7 +44,8 @@ TEST_F(FaxFieldTest, ParseOneLineFax) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Fax"),
ASCIIToUTF16("faxnumber"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("fax1")));
list_.push_back(NULL);
iter_ = list_.begin();
diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc
index 1286f9a..f8f8f87 100644
--- a/chrome/browser/autofill/form_structure_unittest.cc
+++ b/chrome/browser/autofill/form_structure_unittest.cc
@@ -43,15 +43,18 @@ TEST(FormStructureTest, FieldCount) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
ASCIIToUTF16("username"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
- ASCIIToUTF16("password")));
+ ASCIIToUTF16("password"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
FormStructure form_structure(form);
// All fields are counted.
@@ -64,19 +67,23 @@ TEST(FormStructureTest, AutoFillCount) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
ASCIIToUTF16("username"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
- ASCIIToUTF16("password")));
+ ASCIIToUTF16("password"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("state"),
ASCIIToUTF16("state"),
string16(),
- ASCIIToUTF16("select-one")));
+ ASCIIToUTF16("select-one"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
FormStructure form_structure(form);
// Only text and select fields that are heuristically matched are counted.
@@ -89,19 +96,23 @@ TEST(FormStructureTest, ConvertToFormData) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
ASCIIToUTF16("username"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
- ASCIIToUTF16("password")));
+ ASCIIToUTF16("password"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("state"),
ASCIIToUTF16("state"),
string16(),
- ASCIIToUTF16("select")));
+ ASCIIToUTF16("select"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
FormStructure form_structure(form);
FormData converted = form_structure.ConvertToFormData();
@@ -117,11 +128,13 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit1"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit2"),
ASCIIToUTF16("dummy value"),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->HasAutoFillableValues());
@@ -129,11 +142,13 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Email"),
ASCIIToUTF16("email"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("state"),
ASCIIToUTF16("state"),
string16(),
- ASCIIToUTF16("select-one")));
+ ASCIIToUTF16("select-one"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->HasAutoFillableValues());
@@ -141,11 +156,13 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("firstname"),
ASCIIToUTF16("John"),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
ASCIIToUTF16("Dear"),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->HasAutoFillableValues());
@@ -155,11 +172,13 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Field1"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Field2"),
ASCIIToUTF16("dummy value"),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->HasAutoFillableValues());
@@ -168,7 +187,8 @@ TEST(FormStructureTest, HasAutoFillableValues) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Full Name"),
ASCIIToUTF16("fullname"),
ASCIIToUTF16("John Dear"),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->HasAutoFillableValues());
}
@@ -182,15 +202,18 @@ TEST(FormStructureTest, IsAutoFillable) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"),
ASCIIToUTF16("username"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"),
ASCIIToUTF16("password"),
string16(),
- ASCIIToUTF16("password")));
+ ASCIIToUTF16("password"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->IsAutoFillable());
@@ -198,11 +221,13 @@ TEST(FormStructureTest, IsAutoFillable) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("firstname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_FALSE(form_structure->IsAutoFillable());
@@ -210,7 +235,8 @@ TEST(FormStructureTest, IsAutoFillable) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Email"),
ASCIIToUTF16("email"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
@@ -239,39 +265,48 @@ TEST(FormStructureTest, HeuristicsContactInfo) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("firstname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("lastname"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
ASCIIToUTF16("email"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16("phone"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
ASCIIToUTF16("fax"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
ASCIIToUTF16("zipcode"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
@@ -309,52 +344,62 @@ TEST(FormStructureTest, HeuristicsSample8) {
webkit_glue::FormField(ASCIIToUTF16("Your First Name:"),
ASCIIToUTF16("bill.first"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Your Last Name:"),
ASCIIToUTF16("bill.last"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Street Address Line 1:"),
ASCIIToUTF16("bill.street1"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Street Address Line 2:"),
ASCIIToUTF16("bill.street2"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City:"),
ASCIIToUTF16("bill.city"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("State (U.S.):"),
ASCIIToUTF16("bill.state"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Zip/Postal Code:"),
ASCIIToUTF16("BillTo.PostalCode"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Country:"),
ASCIIToUTF16("bill.country"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Phone Number:"),
ASCIIToUTF16("BillTo.Phone"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(10U, form_structure->field_count());
@@ -392,39 +437,46 @@ TEST(FormStructureTest, HeuristicsSample6) {
webkit_glue::FormField(ASCIIToUTF16("E-mail address"),
ASCIIToUTF16("email"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Full name"),
ASCIIToUTF16("name"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Company"),
ASCIIToUTF16("company"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address"),
ASCIIToUTF16("address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
// TODO(jhawkins): Add state select control.
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Zip Code"),
ASCIIToUTF16("Home.PostalCode"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
// TODO(jhawkins): Phone number.
form.fields.push_back(
webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
ASCIIToUTF16("continue"),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(7U, form_structure->field_count());
@@ -457,39 +509,48 @@ TEST(FormStructureTest, HeuristicsLabelsOnly) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"),
string16(),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(9U, form_structure->field_count());
@@ -524,27 +585,33 @@ TEST(FormStructureTest, HeuristicsCreditCardInfo) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
ASCIIToUTF16("name on card"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"),
ASCIIToUTF16("verification"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(6U, form_structure->field_count());
@@ -574,33 +641,40 @@ TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) {
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"),
ASCIIToUTF16("name on card"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
// This is not a field we know how to process. But we should skip over it
// and process the other fields in the card block.
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Type"),
ASCIIToUTF16("card_type"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"),
ASCIIToUTF16("card_number"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"),
ASCIIToUTF16("ccmonth"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"),
ASCIIToUTF16("ccyear"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"),
ASCIIToUTF16("verification"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(webkit_glue::FormField(string16(),
ASCIIToUTF16("Submit"),
string16(),
- ASCIIToUTF16("submit")));
+ ASCIIToUTF16("submit"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(7U, form_structure->field_count());
@@ -633,22 +707,26 @@ TEST(FormStructureTest, ThreeAddressLines) {
webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line3"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("City"),
ASCIIToUTF16("city"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(4U, form_structure->field_count());
@@ -673,17 +751,20 @@ TEST(FormStructureTest, HeuristicsStateWithProvince) {
webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
ASCIIToUTF16("Address"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form.fields.push_back(
webkit_glue::FormField(ASCIIToUTF16("State/Province/Region"),
ASCIIToUTF16("State"),
string16(),
- ASCIIToUTF16("text")));
+ ASCIIToUTF16("text"),
+ 0));
form_structure.reset(new FormStructure(form));
EXPECT_TRUE(form_structure->IsAutoFillable());
ASSERT_EQ(3U, form_structure->field_count());
@@ -697,4 +778,50 @@ TEST(FormStructureTest, HeuristicsStateWithProvince) {
EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type());
}
+TEST(FormStructureTest, ThreePartPhoneNumber) {
+ scoped_ptr<FormStructure> form_structure;
+ FormData form;
+
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("Phone:"),
+ ASCIIToUTF16("dayphone1"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("-"),
+ ASCIIToUTF16("dayphone2"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("-"),
+ ASCIIToUTF16("dayphone3"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("ext.:"),
+ ASCIIToUTF16("dayphone4"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form_structure.reset(new FormStructure(form));
+ EXPECT_TRUE(form_structure->IsAutoFillable());
+ ASSERT_EQ(4U, form_structure->field_count());
+ ASSERT_EQ(3U, form_structure->autofill_count());
+
+ // Area code.
+ EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type());
+ // Phone number suffix.
+ EXPECT_EQ(PHONE_HOME_NUMBER,
+ form_structure->field(1)->heuristic_type());
+ // Phone number suffix.
+ EXPECT_EQ(PHONE_HOME_NUMBER,
+ form_structure->field(2)->heuristic_type());
+ // Unknown.
+ EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(3)->heuristic_type());
+}
+
} // namespace
diff --git a/chrome/browser/autofill/name_field_unittest.cc b/chrome/browser/autofill/name_field_unittest.cc
index 438bef3..11e453e 100644
--- a/chrome/browser/autofill/name_field_unittest.cc
+++ b/chrome/browser/autofill/name_field_unittest.cc
@@ -30,19 +30,22 @@ TEST_F(NameFieldTest, FirstMiddleLast) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("First"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Middle Name"),
ASCIIToUTF16("Middle"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("Last"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -65,19 +68,22 @@ TEST_F(NameFieldTest, FirstMiddleLast2) {
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("firstName"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("middleName"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("lastName"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -100,13 +106,15 @@ TEST_F(NameFieldTest, FirstLast) {
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("first_name"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(string16(),
ASCIIToUTF16("last_name"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -126,13 +134,15 @@ TEST_F(NameFieldTest, FirstLast2) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Name"),
ASCIIToUTF16("first_name"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Name"),
ASCIIToUTF16("last_name"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name2")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -152,19 +162,22 @@ TEST_F(NameFieldTest, FirstLastMiddleWithSpaces) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("First Name"),
ASCIIToUTF16("first name"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Middle Name"),
ASCIIToUTF16("middle name"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name2")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
ASCIIToUTF16("last name"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("name3")));
list_.push_back(NULL);
iter_ = list_.begin();
diff --git a/chrome/browser/autofill/phone_field.cc b/chrome/browser/autofill/phone_field.cc
index dfecceb..6092fe4 100644
--- a/chrome/browser/autofill/phone_field.cc
+++ b/chrome/browser/autofill/phone_field.cc
@@ -99,9 +99,23 @@ bool PhoneField::GetFieldInfo(FieldTypeMap* field_type_map) const {
ok = Add(field_type_map, area_code_, AutoFillType(PHONE_HOME_CITY_CODE));
DCHECK(ok);
- // NOTE: we ignore the prefix/suffix thing here.
- ok = ok && Add(field_type_map, phone_, AutoFillType(PHONE_HOME_NUMBER));
- DCHECK(ok);
+ if (prefix_ != NULL) {
+ // We tag the prefix as PHONE_HOME_NUMBER, then when filling the form
+ // we fill only the prefix depending on the size of the input field.
+ ok = ok && Add(field_type_map,
+ prefix_,
+ AutoFillType(PHONE_HOME_NUMBER));
+ DCHECK(ok);
+ // We tag the suffix as PHONE_HOME_NUMBER, then when filling the form
+ // we fill only the suffix depending on the size of the input field.
+ ok = ok && Add(field_type_map,
+ phone_,
+ AutoFillType(PHONE_HOME_NUMBER));
+ DCHECK(ok);
+ } else {
+ ok = ok && Add(field_type_map, phone_, AutoFillType(PHONE_HOME_NUMBER));
+ DCHECK(ok);
+ }
} else {
ok = Add(field_type_map, phone_, AutoFillType(PHONE_HOME_WHOLE_NUMBER));
DCHECK(ok);
diff --git a/chrome/browser/autofill/phone_field_unittest.cc b/chrome/browser/autofill/phone_field_unittest.cc
index f2fa01f..bf7d9fb 100644
--- a/chrome/browser/autofill/phone_field_unittest.cc
+++ b/chrome/browser/autofill/phone_field_unittest.cc
@@ -44,7 +44,8 @@ TEST_F(PhoneFieldTest, ParseOneLinePhone) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16("phone"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -61,7 +62,8 @@ TEST_F(PhoneFieldTest, ParseOneLinePhoneEcml) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"),
kEcmlShipToPhone,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -78,13 +80,15 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhone) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Area Code"),
ASCIIToUTF16("area code"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("areacode1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"),
ASCIIToUTF16("phone"),
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -104,13 +108,15 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhoneEcmlShipTo) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Area Code"),
kEcmlShipToPostalCode,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("areacode1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"),
kEcmlShipToPhone,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -130,13 +136,15 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhoneEcmlBillTo) {
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Area Code"),
kEcmlBillToPostalCode,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("areacode1")));
list_.push_back(
new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone"),
kEcmlBillToPhone,
string16(),
- ASCIIToUTF16("text")),
+ ASCIIToUTF16("text"),
+ 0),
ASCIIToUTF16("phone1")));
list_.push_back(NULL);
iter_ = list_.begin();
@@ -151,4 +159,49 @@ TEST_F(PhoneFieldTest, ParseTwoLinePhoneEcmlBillTo) {
EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("phone1")]);
}
+TEST_F(PhoneFieldTest, ThreePartPhoneNumber) {
+ list_.push_back(
+ new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Phone:"),
+ ASCIIToUTF16("dayphone1"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0),
+ ASCIIToUTF16("areacode1")));
+ list_.push_back(
+ new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("-"),
+ ASCIIToUTF16("dayphone2"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0),
+ ASCIIToUTF16("prefix1")));
+ list_.push_back(
+ new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("-"),
+ ASCIIToUTF16("dayphone3"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0),
+ ASCIIToUTF16("suffix1")));
+ list_.push_back(
+ new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("ext.:"),
+ ASCIIToUTF16("dayphone4"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0),
+ ASCIIToUTF16("ext1")));
+ list_.push_back(NULL);
+ iter_ = list_.begin();
+ field_.reset(PhoneField::Parse(&iter_, false));
+ ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get());
+ ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(
+ field_type_map_.find(ASCIIToUTF16("areacode1")) != field_type_map_.end());
+ EXPECT_EQ(PHONE_HOME_CITY_CODE, field_type_map_[ASCIIToUTF16("areacode1")]);
+ ASSERT_TRUE(
+ field_type_map_.find(ASCIIToUTF16("prefix1")) != field_type_map_.end());
+ EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("prefix1")]);
+ ASSERT_TRUE(
+ field_type_map_.find(ASCIIToUTF16("suffix1")) != field_type_map_.end());
+ EXPECT_EQ(PHONE_HOME_NUMBER, field_type_map_[ASCIIToUTF16("suffix1")]);
+}
+
} // namespace