summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2013-08-07 11:04:47 +0100
committerBen Murdoch <benm@google.com>2013-08-07 11:04:47 +0100
commit3240926e260ce088908e02ac07a6cf7b0c0cbf44 (patch)
tree5ff5fa16b2fb9278c6d731b3d19123731f3f8626 /components
parent3b21a50ee4fe6f71bb117cbee9998a4f465eea9d (diff)
downloadchromium_org-3240926e260ce088908e02ac07a6cf7b0c0cbf44.tar.gz
Merge from Chromium at DEPS revision r216133
This commit was generated by merge_to_master.py. Change-Id: I541d5d1d8520b6b3829fbc1fa18552bf9ad4a5c7
Diffstat (limited to 'components')
-rw-r--r--components/autofill/content/browser/autocheckout_manager.cc30
-rw-r--r--components/autofill/content/browser/autocheckout_manager_unittest.cc8
-rw-r--r--components/autofill/content/browser/wallet/form_field_error.cc2
-rw-r--r--components/autofill/content/browser/wallet/form_field_error.h4
-rw-r--r--components/autofill/content/browser/wallet/full_wallet.cc8
-rw-r--r--components/autofill/content/browser/wallet/full_wallet.h5
-rw-r--r--components/autofill/content/browser/wallet/full_wallet_unittest.cc20
-rw-r--r--components/autofill/content/browser/wallet/wallet_address.cc5
-rw-r--r--components/autofill/content/browser/wallet/wallet_address.h6
-rw-r--r--components/autofill/content/browser/wallet/wallet_items.cc6
-rw-r--r--components/autofill/content/browser/wallet/wallet_items.h6
-rw-r--r--components/autofill/content/renderer/autofill_agent.cc8
-rw-r--r--components/autofill/core/browser/address.cc43
-rw-r--r--components/autofill/core/browser/address.h20
-rw-r--r--components/autofill/core/browser/address_field.cc16
-rw-r--r--components/autofill/core/browser/address_field.h2
-rw-r--r--components/autofill/core/browser/address_field_unittest.cc2
-rw-r--r--components/autofill/core/browser/address_unittest.cc43
-rw-r--r--components/autofill/core/browser/android/auxiliary_profiles_android.cc3
-rw-r--r--components/autofill/core/browser/autofill_common_test.cc3
-rw-r--r--components/autofill/core/browser/autofill_data_model.cc19
-rw-r--r--components/autofill/core/browser/autofill_data_model.h2
-rw-r--r--components/autofill/core/browser/autofill_data_model_unittest.cc6
-rw-r--r--components/autofill/core/browser/autofill_download.cc4
-rw-r--r--components/autofill/core/browser/autofill_download.h2
-rw-r--r--components/autofill/core/browser/autofill_download_unittest.cc12
-rw-r--r--components/autofill/core/browser/autofill_external_delegate.cc6
-rw-r--r--components/autofill/core/browser/autofill_field.cc13
-rw-r--r--components/autofill/core/browser/autofill_field.h22
-rw-r--r--components/autofill/core/browser/autofill_field_unittest.cc11
-rw-r--r--components/autofill/core/browser/autofill_ie_toolbar_import_win.cc8
-rw-r--r--components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc8
-rw-r--r--components/autofill/core/browser/autofill_manager.cc23
-rw-r--r--components/autofill/core/browser/autofill_manager.h8
-rw-r--r--components/autofill/core/browser/autofill_manager_unittest.cc32
-rw-r--r--components/autofill/core/browser/autofill_merge_unittest.cc6
-rw-r--r--components/autofill/core/browser/autofill_metrics.cc10
-rw-r--r--components/autofill/core/browser/autofill_metrics.h6
-rw-r--r--components/autofill/core/browser/autofill_metrics_unittest.cc28
-rw-r--r--components/autofill/core/browser/autofill_profile.cc211
-rw-r--r--components/autofill/core/browser/autofill_profile.h45
-rw-r--r--components/autofill/core/browser/autofill_profile_unittest.cc21
-rw-r--r--components/autofill/core/browser/autofill_server_field_info.h2
-rw-r--r--components/autofill/core/browser/autofill_type.cc33
-rw-r--r--components/autofill/core/browser/autofill_type.h21
-rw-r--r--components/autofill/core/browser/autofill_type_unittest.cc20
-rw-r--r--components/autofill/core/browser/autofill_xml_parser.cc2
-rw-r--r--components/autofill/core/browser/contact_info.cc22
-rw-r--r--components/autofill/core/browser/contact_info.h22
-rw-r--r--components/autofill/core/browser/credit_card.cc61
-rw-r--r--components/autofill/core/browser/credit_card.h19
-rw-r--r--components/autofill/core/browser/credit_card_field.cc2
-rw-r--r--components/autofill/core/browser/credit_card_field.h2
-rw-r--r--components/autofill/core/browser/credit_card_field_unittest.cc2
-rw-r--r--components/autofill/core/browser/credit_card_unittest.cc34
-rw-r--r--components/autofill/core/browser/email_field.cc2
-rw-r--r--components/autofill/core/browser/email_field.h2
-rw-r--r--components/autofill/core/browser/field_types.h9
-rw-r--r--components/autofill/core/browser/form_field.cc9
-rw-r--r--components/autofill/core/browser/form_field.h12
-rw-r--r--components/autofill/core/browser/form_field_unittest.cc2
-rw-r--r--components/autofill/core/browser/form_group.cc31
-rw-r--r--components/autofill/core/browser/form_group.h20
-rw-r--r--components/autofill/core/browser/form_structure.cc67
-rw-r--r--components/autofill/core/browser/form_structure.h4
-rw-r--r--components/autofill/core/browser/form_structure_unittest.cc54
-rw-r--r--components/autofill/core/browser/name_field.cc12
-rw-r--r--components/autofill/core/browser/name_field.h2
-rw-r--r--components/autofill/core/browser/name_field_unittest.cc2
-rw-r--r--components/autofill/core/browser/personal_data_manager.cc60
-rw-r--r--components/autofill/core/browser/personal_data_manager.h8
-rw-r--r--components/autofill/core/browser/personal_data_manager_mac.mm3
-rw-r--r--components/autofill/core/browser/personal_data_manager_unittest.cc2
-rw-r--r--components/autofill/core/browser/phone_field.cc4
-rw-r--r--components/autofill/core/browser/phone_field.h2
-rw-r--r--components/autofill/core/browser/phone_field_unittest.cc2
-rw-r--r--components/autofill/core/browser/phone_number.cc45
-rw-r--r--components/autofill/core/browser/phone_number.h21
-rw-r--r--components/autofill/core/browser/phone_number_unittest.cc55
-rw-r--r--components/autofill/core/browser/webdata/autofill_table.cc7
-rw-r--r--components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/WebContentsDelegateAndroid.java9
-rw-r--r--components/web_contents_delegate_android/web_contents_delegate_android.cc2
-rw-r--r--components/webdata/common/web_database_migration_unittest.cc6
83 files changed, 757 insertions, 682 deletions
diff --git a/components/autofill/content/browser/autocheckout_manager.cc b/components/autofill/content/browser/autocheckout_manager.cc
index 01f656bd34..ee1c4576af 100644
--- a/components/autofill/content/browser/autocheckout_manager.cc
+++ b/components/autofill/content/browser/autocheckout_manager.cc
@@ -15,8 +15,8 @@
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/credit_card.h"
-#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/common/autofill_messages.h"
#include "components/autofill/core/common/form_data.h"
@@ -354,27 +354,27 @@ void AutocheckoutManager::ReturnAutocheckoutData(
billing_address_.reset(new AutofillProfile());
for (size_t i = 0; i < result->field_count(); ++i) {
- AutofillFieldType type = result->field(i)->type();
+ const AutofillType& type = result->field(i)->Type();
const base::string16& value = result->field(i)->value;
- if (type == CREDIT_CARD_VERIFICATION_CODE) {
+ if (type.server_type() == CREDIT_CARD_VERIFICATION_CODE) {
cvv_ = result->field(i)->value;
continue;
}
- FieldTypeGroup group = AutofillType(type).group();
+ FieldTypeGroup group = type.group();
if (group == CREDIT_CARD) {
- credit_card_->SetRawInfo(type, value);
+ credit_card_->SetRawInfo(type.server_type(), value);
// TODO(dgwallinga): Find a way of cleanly deprecating CREDIT_CARD_NAME.
// code.google.com/p/chromium/issues/detail?id=263498
- if (type == CREDIT_CARD_NAME)
+ if (type.server_type() == CREDIT_CARD_NAME)
billing_address_->SetRawInfo(NAME_BILLING_FULL, value);
- } else if (type == ADDRESS_HOME_COUNTRY) {
+ } else if (type.server_type() == ADDRESS_HOME_COUNTRY) {
profile_->SetInfo(type, value, autofill_manager_->app_locale());
- } else if (type == ADDRESS_BILLING_COUNTRY) {
+ } else if (type.server_type() == ADDRESS_BILLING_COUNTRY) {
billing_address_->SetInfo(type, value, autofill_manager_->app_locale());
} else if (IsBillingGroup(group)) {
- billing_address_->SetRawInfo(type, value);
+ billing_address_->SetRawInfo(type.server_type(), value);
} else {
- profile_->SetRawInfo(type, value);
+ profile_->SetRawInfo(type.server_type(), value);
}
}
@@ -452,9 +452,9 @@ void AutocheckoutManager::SetValue(const AutofillField& field,
if (field.server_type() == NO_SERVER_DATA)
return;
- AutofillFieldType type = field.type();
+ const AutofillType& type = field.Type();
- if (type == FIELD_WITH_DEFAULT_VALUE) {
+ if (type.server_type() == FIELD_WITH_DEFAULT_VALUE) {
// For a form with radio buttons, like:
// <form>
// <input type="radio" name="sex" value="male">Male<br>
@@ -488,15 +488,15 @@ void AutocheckoutManager::SetValue(const AutofillField& field,
}
// Handle verification code directly.
- if (type == CREDIT_CARD_VERIFICATION_CODE) {
+ if (type.server_type() == CREDIT_CARD_VERIFICATION_CODE) {
field_to_fill->value = cvv_;
return;
}
- if (AutofillType(type).group() == CREDIT_CARD) {
+ if (type.group() == CREDIT_CARD) {
credit_card_->FillFormField(
field, 0, autofill_manager_->app_locale(), field_to_fill);
- } else if (IsBillingGroup(AutofillType(type).group())) {
+ } else if (IsBillingGroup(type.group())) {
billing_address_->FillFormField(
field, 0, autofill_manager_->app_locale(), field_to_fill);
} else {
diff --git a/components/autofill/content/browser/autocheckout_manager_unittest.cc b/components/autofill/content/browser/autocheckout_manager_unittest.cc
index cfe1891ad2..3333384f9c 100644
--- a/components/autofill/content/browser/autocheckout_manager_unittest.cc
+++ b/components/autofill/content/browser/autocheckout_manager_unittest.cc
@@ -56,7 +56,7 @@ FormFieldData BuildField(const std::string& autocomplete_attribute) {
}
scoped_ptr<FormStructure> CreateTestFormStructure(
- const std::vector<AutofillFieldType>& autofill_types) {
+ const std::vector<ServerFieldType>& autofill_types) {
FormData form;
form.name = ASCIIToUTF16("MyForm");
form.method = ASCIIToUTF16("POST");
@@ -84,7 +84,7 @@ scoped_ptr<FormStructure> CreateTestFormStructure(
}
scoped_ptr<FormStructure> CreateTestAddressFormStructure() {
- std::vector<AutofillFieldType> autofill_types;
+ std::vector<ServerFieldType> autofill_types;
autofill_types.push_back(NAME_FULL);
autofill_types.push_back(PHONE_HOME_WHOLE_NUMBER);
autofill_types.push_back(EMAIL_ADDRESS);
@@ -98,7 +98,7 @@ scoped_ptr<FormStructure> CreateTestAddressFormStructure() {
}
scoped_ptr<FormStructure> CreateTestCreditCardFormStructure() {
- std::vector<AutofillFieldType> autofill_types;
+ std::vector<ServerFieldType> autofill_types;
autofill_types.push_back(CREDIT_CARD_NAME);
autofill_types.push_back(CREDIT_CARD_NUMBER);
autofill_types.push_back(CREDIT_CARD_EXP_MONTH);
@@ -229,7 +229,7 @@ scoped_ptr<AutocheckoutPageMetaData> CreateMultiClickMetaData() {
struct TestField {
const char* const field_type;
const char* const field_value;
- AutofillFieldType autofill_type;
+ ServerFieldType autofill_type;
};
const TestField kTestFields[] = {
diff --git a/components/autofill/content/browser/wallet/form_field_error.cc b/components/autofill/content/browser/wallet/form_field_error.cc
index da7ee31311..826ea37df2 100644
--- a/components/autofill/content/browser/wallet/form_field_error.cc
+++ b/components/autofill/content/browser/wallet/form_field_error.cc
@@ -56,7 +56,7 @@ FormFieldError::FormFieldError(ErrorType error_type, Location location)
FormFieldError::~FormFieldError() {}
-AutofillFieldType FormFieldError::GetAutofillType() const {
+ServerFieldType FormFieldError::GetAutofillType() const {
switch (error_type_) {
case INVALID_PHONE_NUMBER:
if (location_ == LEGAL_ADDRESS || location_ == PAYMENT_INSTRUMENT)
diff --git a/components/autofill/content/browser/wallet/form_field_error.h b/components/autofill/content/browser/wallet/form_field_error.h
index 91a67b4de1..60df6d9414 100644
--- a/components/autofill/content/browser/wallet/form_field_error.h
+++ b/components/autofill/content/browser/wallet/form_field_error.h
@@ -59,8 +59,8 @@ class FormFieldError {
ErrorType error_type() const { return error_type_; }
Location location() const { return location_; }
- // Gets the appropriate AutofillFieldType for |location| and |error_type|.
- AutofillFieldType GetAutofillType() const;
+ // Gets the appropriate field type for |location| and |error_type|.
+ ServerFieldType GetAutofillType() const;
// Gets a user facing error message appropriate for |location| and
// |error_type|.
diff --git a/components/autofill/content/browser/wallet/full_wallet.cc b/components/autofill/content/browser/wallet/full_wallet.cc
index 0a7fef67e6..eaadcc464a 100644
--- a/components/autofill/content/browser/wallet/full_wallet.cc
+++ b/components/autofill/content/browser/wallet/full_wallet.cc
@@ -8,6 +8,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/credit_card.h"
namespace {
@@ -126,8 +127,8 @@ scoped_ptr<FullWallet>
required_actions));
}
-base::string16 FullWallet::GetInfo(AutofillFieldType type) {
- switch (type) {
+base::string16 FullWallet::GetInfo(const AutofillType& type) {
+ switch (type.server_type()) {
case CREDIT_CARD_NUMBER:
return UTF8ToUTF16(GetPan());
@@ -188,7 +189,8 @@ bool FullWallet::HasRequiredAction(RequiredAction action) const {
base::string16 FullWallet::TypeAndLastFourDigits() {
CreditCard card;
- card.SetRawInfo(CREDIT_CARD_NUMBER, GetInfo(CREDIT_CARD_NUMBER));
+ card.SetRawInfo(CREDIT_CARD_NUMBER,
+ GetInfo(AutofillType(CREDIT_CARD_NUMBER)));
return card.TypeAndLastFourDigits();
}
diff --git a/components/autofill/content/browser/wallet/full_wallet.h b/components/autofill/content/browser/wallet/full_wallet.h
index b97d670936..61e846a2c0 100644
--- a/components/autofill/content/browser/wallet/full_wallet.h
+++ b/components/autofill/content/browser/wallet/full_wallet.h
@@ -20,6 +20,9 @@ class DictionaryValue;
}
namespace autofill {
+
+class AutofillType;
+
namespace wallet {
class FullWalletTest;
@@ -39,7 +42,7 @@ class FullWallet {
CreateFullWallet(const base::DictionaryValue& dictionary);
// Returns corresponding data for |type|.
- base::string16 GetInfo(AutofillFieldType type);
+ base::string16 GetInfo(const AutofillType& type);
// Whether or not |action| is in |required_actions_|.
bool HasRequiredAction(RequiredAction action) const;
diff --git a/components/autofill/content/browser/wallet/full_wallet_unittest.cc b/components/autofill/content/browser/wallet/full_wallet_unittest.cc
index bc4bbc8488..5225bc4795 100644
--- a/components/autofill/content/browser/wallet/full_wallet_unittest.cc
+++ b/components/autofill/content/browser/wallet/full_wallet_unittest.cc
@@ -11,6 +11,8 @@
#include "components/autofill/content/browser/wallet/full_wallet.h"
#include "components/autofill/content/browser/wallet/required_action.h"
#include "components/autofill/content/browser/wallet/wallet_test_util.h"
+#include "components/autofill/core/browser/autofill_type.h"
+#include "components/autofill/core/browser/field_types.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -452,9 +454,9 @@ TEST_F(FullWalletTest, RestLengthCorrectDecryptionTest) {
EXPECT_TRUE(base::HexStringToBytes("5F04A8704183", &one_time_pad));
full_wallet.set_one_time_pad(one_time_pad);
EXPECT_EQ(ASCIIToUTF16("5285121925598459"),
- full_wallet.GetInfo(CREDIT_CARD_NUMBER));
+ full_wallet.GetInfo(AutofillType(CREDIT_CARD_NUMBER)));
EXPECT_EQ(ASCIIToUTF16("989"),
- full_wallet.GetInfo(CREDIT_CARD_VERIFICATION_CODE));
+ full_wallet.GetInfo(AutofillType(CREDIT_CARD_VERIFICATION_CODE)));
}
TEST_F(FullWalletTest, RestLengthUnderDecryptionTest) {
@@ -470,9 +472,9 @@ TEST_F(FullWalletTest, RestLengthUnderDecryptionTest) {
EXPECT_TRUE(base::HexStringToBytes("063AD35324BF", &one_time_pad));
full_wallet.set_one_time_pad(one_time_pad);
EXPECT_EQ(ASCIIToUTF16("5285127106109719"),
- full_wallet.GetInfo(CREDIT_CARD_NUMBER));
+ full_wallet.GetInfo(AutofillType(CREDIT_CARD_NUMBER)));
EXPECT_EQ(ASCIIToUTF16("385"),
- full_wallet.GetInfo(CREDIT_CARD_VERIFICATION_CODE));
+ full_wallet.GetInfo(AutofillType(CREDIT_CARD_VERIFICATION_CODE)));
}
TEST_F(FullWalletTest, GetCreditCardInfo) {
@@ -486,19 +488,21 @@ TEST_F(FullWalletTest, GetCreditCardInfo) {
required_actions);
EXPECT_EQ(ASCIIToUTF16("15"),
- full_wallet.GetInfo(CREDIT_CARD_EXP_2_DIGIT_YEAR));
+ full_wallet.GetInfo(AutofillType(CREDIT_CARD_EXP_2_DIGIT_YEAR)));
EXPECT_EQ(ASCIIToUTF16("12/15"),
- full_wallet.GetInfo(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR));
+ full_wallet.GetInfo(
+ AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)));
EXPECT_EQ(ASCIIToUTF16("12/2015"),
- full_wallet.GetInfo(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR));
+ full_wallet.GetInfo(
+ AutofillType(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)));
std::vector<uint8> one_time_pad;
EXPECT_TRUE(base::HexStringToBytes("075DA779F98B", &one_time_pad));
full_wallet.set_one_time_pad(one_time_pad);
EXPECT_EQ(ASCIIToUTF16("MasterCard"),
- full_wallet.GetInfo(CREDIT_CARD_TYPE));
+ full_wallet.GetInfo(AutofillType(CREDIT_CARD_TYPE)));
}
} // namespace wallet
diff --git a/components/autofill/content/browser/wallet/wallet_address.cc b/components/autofill/content/browser/wallet/wallet_address.cc
index 8c9d084dfd..5b69ea35ea 100644
--- a/components/autofill/content/browser/wallet/wallet_address.cc
+++ b/components/autofill/content/browser/wallet/wallet_address.cc
@@ -10,6 +10,7 @@
#include "base/values.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/state_names.h"
namespace autofill {
@@ -261,9 +262,9 @@ string16 Address::DisplayNameDetail() const {
#endif
}
-string16 Address::GetInfo(AutofillFieldType type,
+string16 Address::GetInfo(const AutofillType& type,
const std::string& app_locale) const {
- switch (AutofillType::GetEquivalentFieldType(type)) {
+ switch (AutofillType::GetEquivalentFieldType(type.server_type())) {
case NAME_FULL:
return recipient_name();
diff --git a/components/autofill/content/browser/wallet/wallet_address.h b/components/autofill/content/browser/wallet/wallet_address.h
index fe9ef9a964..cead6cc5d4 100644
--- a/components/autofill/content/browser/wallet/wallet_address.h
+++ b/components/autofill/content/browser/wallet/wallet_address.h
@@ -10,7 +10,6 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
-#include "components/autofill/core/browser/field_types.h"
namespace base {
class DictionaryValue;
@@ -19,6 +18,7 @@ class DictionaryValue;
namespace autofill {
class AutofillProfile;
+class AutofillType;
namespace wallet {
@@ -91,8 +91,8 @@ class Address {
base::string16 DisplayNameDetail() const;
// Returns data appropriate for |type|.
- base::string16 GetInfo(AutofillFieldType type,
- const std::string& app_locale) const;
+ base::string16 GetInfo(const AutofillType& type,
+ const std::string& app_locale) const;
const std::string& country_name_code() const { return country_name_code_; }
const base::string16& recipient_name() const { return recipient_name_; }
diff --git a/components/autofill/content/browser/wallet/wallet_items.cc b/components/autofill/content/browser/wallet/wallet_items.cc
index 1608c3ecbd..6a861e2302 100644
--- a/components/autofill/content/browser/wallet/wallet_items.cc
+++ b/components/autofill/content/browser/wallet/wallet_items.cc
@@ -309,12 +309,12 @@ const gfx::Image& WalletItems::MaskedInstrument::CardIcon() const {
}
base::string16 WalletItems::MaskedInstrument::GetInfo(
- AutofillFieldType type,
+ const AutofillType& type,
const std::string& app_locale) const {
- if (AutofillType(type).group() != CREDIT_CARD)
+ if (type.group() != CREDIT_CARD)
return address().GetInfo(type, app_locale);
- switch (type) {
+ switch (type.server_type()) {
case CREDIT_CARD_NAME:
return address().recipient_name();
diff --git a/components/autofill/content/browser/wallet/wallet_items.h b/components/autofill/content/browser/wallet/wallet_items.h
index 33a7462d8c..53a49a17d0 100644
--- a/components/autofill/content/browser/wallet/wallet_items.h
+++ b/components/autofill/content/browser/wallet/wallet_items.h
@@ -28,6 +28,8 @@ class Image;
namespace autofill {
+class AutofillType;
+
FORWARD_DECLARE_TEST(WalletInstrumentWrapperTest, GetInfoCreditCardExpMonth);
FORWARD_DECLARE_TEST(WalletInstrumentWrapperTest,
GetDisplayTextEmptyWhenExpired);
@@ -88,8 +90,8 @@ class WalletItems {
base::string16 DisplayNameDetail() const;
// Gets info that corresponds with |type|.
- base::string16 GetInfo(AutofillFieldType type,
- const std::string& app_locale) const;
+ base::string16 GetInfo(const AutofillType& type,
+ const std::string& app_locale) const;
// Returns the display type of the and last four digits (e.g. Visa - 4444).
base::string16 TypeAndLastFourDigits() const;
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc
index 12959b910d..f2300e65a7 100644
--- a/components/autofill/content/renderer/autofill_agent.cc
+++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -418,8 +418,6 @@ void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) {
void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element,
const WebKeyboardEvent& event) {
- // TODO(csharp): Remove once Autofill test flakiness is fixed.
- LOG(INFO) << "AutofillAgent::textFieldDidReceiveKeyDown";
if (password_autofill_agent_->TextFieldHandlingKeyDown(element, event)) {
element_ = element;
return;
@@ -629,9 +627,6 @@ void AutofillAgent::ShowSuggestions(const WebInputElement& element,
bool autofill_on_empty_values,
bool requires_caret_at_end,
bool display_warning_if_disabled) {
- // TODO(csharp): Remove once Autofill test flakiness is fixed.
- LOG(INFO) << "AutofillAgent::ShowSuggestions";
-
if (!element.isEnabled() || element.isReadOnly() || !element.isTextField() ||
element.isPasswordField() || !element.suggestedValue().isEmpty())
return;
@@ -668,9 +663,6 @@ void AutofillAgent::ShowSuggestions(const WebInputElement& element,
void AutofillAgent::QueryAutofillSuggestions(const WebInputElement& element,
bool display_warning_if_disabled) {
- // TODO(csharp): Remove once Autofill test flakiness is fixed.
- LOG(INFO) << "AutofillAgent::QueryAutofillSuggestions";
-
if (!element.document().frame())
return;
diff --git a/components/autofill/core/browser/address.cc b/components/autofill/core/browser/address.cc
index 2f1694e1cd..339352f8d5 100644
--- a/components/autofill/core/browser/address.cc
+++ b/components/autofill/core/browser/address.cc
@@ -13,7 +13,6 @@
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_type.h"
-#include "components/autofill/core/browser/field_types.h"
namespace {
@@ -44,16 +43,7 @@ Address& Address::operator=(const Address& address) {
return *this;
}
-void Address::GetSupportedTypes(FieldTypeSet* supported_types) const {
- supported_types->insert(ADDRESS_HOME_LINE1);
- supported_types->insert(ADDRESS_HOME_LINE2);
- supported_types->insert(ADDRESS_HOME_CITY);
- supported_types->insert(ADDRESS_HOME_STATE);
- supported_types->insert(ADDRESS_HOME_ZIP);
- supported_types->insert(ADDRESS_HOME_COUNTRY);
-}
-
-base::string16 Address::GetRawInfo(AutofillFieldType type) const {
+base::string16 Address::GetRawInfo(ServerFieldType type) const {
type = AutofillType::GetEquivalentFieldType(type);
if (type == ADDRESS_HOME_LINE1)
return line1_;
@@ -76,7 +66,7 @@ base::string16 Address::GetRawInfo(AutofillFieldType type) const {
return base::string16();
}
-void Address::SetRawInfo(AutofillFieldType type, const base::string16& value) {
+void Address::SetRawInfo(ServerFieldType type, const base::string16& value) {
type = AutofillType::GetEquivalentFieldType(type);
if (type == ADDRESS_HOME_LINE1) {
line1_ = value;
@@ -96,32 +86,34 @@ void Address::SetRawInfo(AutofillFieldType type, const base::string16& value) {
}
}
-base::string16 Address::GetInfo(AutofillFieldType type,
+base::string16 Address::GetInfo(const AutofillType& type,
const std::string& app_locale) const {
- type = AutofillType::GetEquivalentFieldType(type);
- if (type == ADDRESS_HOME_COUNTRY && !country_code_.empty())
+ ServerFieldType server_type =
+ AutofillType::GetEquivalentFieldType(type.server_type());
+ if (server_type == ADDRESS_HOME_COUNTRY && !country_code_.empty())
return AutofillCountry(UTF16ToASCII(country_code_), app_locale).name();
- return GetRawInfo(type);
+ return GetRawInfo(server_type);
}
-bool Address::SetInfo(AutofillFieldType type,
+bool Address::SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) {
- type = AutofillType::GetEquivalentFieldType(type);
- if (type == ADDRESS_HOME_COUNTRY && !value.empty()) {
+ ServerFieldType server_type =
+ AutofillType::GetEquivalentFieldType(type.server_type());
+ if (server_type == ADDRESS_HOME_COUNTRY && !value.empty()) {
country_code_ =
ASCIIToUTF16(AutofillCountry::GetCountryCode(value, app_locale));
return !country_code_.empty();
}
- SetRawInfo(type, value);
+ SetRawInfo(server_type, value);
return true;
}
void Address::GetMatchingTypes(const base::string16& text,
const std::string& app_locale,
- FieldTypeSet* matching_types) const {
+ ServerFieldTypeSet* matching_types) const {
FormGroup::GetMatchingTypes(text, app_locale, matching_types);
// Check to see if the |text| canonicalized as a country name is a match.
@@ -130,4 +122,13 @@ void Address::GetMatchingTypes(const base::string16& text,
matching_types->insert(ADDRESS_HOME_COUNTRY);
}
+void Address::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
+ supported_types->insert(ADDRESS_HOME_LINE1);
+ supported_types->insert(ADDRESS_HOME_LINE2);
+ supported_types->insert(ADDRESS_HOME_CITY);
+ supported_types->insert(ADDRESS_HOME_STATE);
+ supported_types->insert(ADDRESS_HOME_ZIP);
+ supported_types->insert(ADDRESS_HOME_COUNTRY);
+}
+
} // namespace autofill
diff --git a/components/autofill/core/browser/address.h b/components/autofill/core/browser/address.h
index e55dc850a3..db1c731d14 100644
--- a/components/autofill/core/browser/address.h
+++ b/components/autofill/core/browser/address.h
@@ -10,8 +10,6 @@
#include "base/compiler_specific.h"
#include "base/strings/string16.h"
-#include "components/autofill/core/browser/autofill_type.h"
-#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_group.h"
namespace autofill {
@@ -26,21 +24,23 @@ class Address : public FormGroup {
Address& operator=(const Address& address);
// FormGroup:
- virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
- virtual void SetRawInfo(AutofillFieldType type,
+ virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
+ virtual void SetRawInfo(ServerFieldType type,
const base::string16& value) OVERRIDE;
- virtual base::string16 GetInfo(AutofillFieldType type,
+ virtual base::string16 GetInfo(const AutofillType& type,
const std::string& app_locale) const OVERRIDE;
- virtual bool SetInfo(AutofillFieldType type,
+ virtual bool SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) OVERRIDE;
- virtual void GetMatchingTypes(const base::string16& text,
- const std::string& app_locale,
- FieldTypeSet* matching_types) const OVERRIDE;
+ virtual void GetMatchingTypes(
+ const base::string16& text,
+ const std::string& app_locale,
+ ServerFieldTypeSet* matching_types) const OVERRIDE;
private:
// FormGroup:
- virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
+ virtual void GetSupportedTypes(
+ ServerFieldTypeSet* supported_types) const OVERRIDE;
// The address.
base::string16 line1_;
diff --git a/components/autofill/core/browser/address_field.cc b/components/autofill/core/browser/address_field.cc
index c219465ff0..ba7c09e23d 100644
--- a/components/autofill/core/browser/address_field.cc
+++ b/components/autofill/core/browser/address_field.cc
@@ -136,14 +136,14 @@ AddressField::AddressField()
type_(kGenericAddress) {
}
-bool AddressField::ClassifyField(FieldTypeMap* map) const {
- AutofillFieldType address_company;
- AutofillFieldType address_line1;
- AutofillFieldType address_line2;
- AutofillFieldType address_city;
- AutofillFieldType address_state;
- AutofillFieldType address_zip;
- AutofillFieldType address_country;
+bool AddressField::ClassifyField(ServerFieldTypeMap* map) const {
+ ServerFieldType address_company;
+ ServerFieldType address_line1;
+ ServerFieldType address_line2;
+ ServerFieldType address_city;
+ ServerFieldType address_state;
+ ServerFieldType address_zip;
+ ServerFieldType address_country;
switch (type_) {
case kShippingAddress:
diff --git a/components/autofill/core/browser/address_field.h b/components/autofill/core/browser/address_field.h
index ba90bb40e5..a12d598160 100644
--- a/components/autofill/core/browser/address_field.h
+++ b/components/autofill/core/browser/address_field.h
@@ -25,7 +25,7 @@ class AddressField : public FormField {
protected:
// FormField:
- virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
+ virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE;
private:
enum AddressType {
diff --git a/components/autofill/core/browser/address_field_unittest.cc b/components/autofill/core/browser/address_field_unittest.cc
index d92ee25b5e..6949ef7523 100644
--- a/components/autofill/core/browser/address_field_unittest.cc
+++ b/components/autofill/core/browser/address_field_unittest.cc
@@ -21,7 +21,7 @@ class AddressFieldTest : public testing::Test {
protected:
ScopedVector<const AutofillField> list_;
scoped_ptr<AddressField> field_;
- FieldTypeMap field_type_map_;
+ ServerFieldTypeMap field_type_map_;
// Downcast for tests.
static AddressField* Parse(AutofillScanner* scanner) {
diff --git a/components/autofill/core/browser/address_unittest.cc b/components/autofill/core/browser/address_unittest.cc
index 418fb1deff..8d2e920f99 100644
--- a/components/autofill/core/browser/address_unittest.cc
+++ b/components/autofill/core/browser/address_unittest.cc
@@ -35,15 +35,17 @@ TEST_F(AddressTest, GetCountry) {
EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
// Make sure that nothing breaks when the country code is missing.
- base::string16 country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
+ base::string16 country =
+ address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
EXPECT_EQ(base::string16(), country);
- address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US");
- country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
+ address.SetInfo(
+ AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("US"), "en-US");
+ country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
EXPECT_EQ(ASCIIToUTF16("United States"), country);
address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
- country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
+ country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
EXPECT_EQ(ASCIIToUTF16("Canada"), country);
}
@@ -53,32 +55,39 @@ TEST_F(AddressTest, SetCountry) {
EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
// Test basic conversion.
- address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States"), "en-US");
- base::string16 country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
+ address.SetInfo(
+ AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("United States"),
+ "en-US");
+ base::string16 country =
+ address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
EXPECT_EQ(ASCIIToUTF16("US"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(ASCIIToUTF16("United States"), country);
// Test basic synonym detection.
- address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("USA"), "en-US");
- country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
+ address.SetInfo(
+ AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("USA"), "en-US");
+ country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
EXPECT_EQ(ASCIIToUTF16("US"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(ASCIIToUTF16("United States"), country);
// Test case-insensitivity.
- address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("canADA"), "en-US");
- country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
+ address.SetInfo(
+ AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("canADA"), "en-US");
+ country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
EXPECT_EQ(ASCIIToUTF16("CA"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(ASCIIToUTF16("Canada"), country);
// Test country code detection.
- address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("JP"), "en-US");
- country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
+ address.SetInfo(
+ AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("JP"), "en-US");
+ country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
EXPECT_EQ(ASCIIToUTF16("JP"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(ASCIIToUTF16("Japan"), country);
// Test that we ignore unknown countries.
- address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Unknown"), "en-US");
- country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
+ address.SetInfo(
+ AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("Unknown"), "en-US");
+ country = address.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), "en-US");
EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(base::string16(), country);
}
@@ -97,7 +106,7 @@ TEST_F(AddressTest, IsCountry) {
};
for (size_t i = 0; i < arraysize(kValidMatches); ++i) {
SCOPED_TRACE(kValidMatches[i]);
- FieldTypeSet matching_types;
+ ServerFieldTypeSet matching_types;
address.GetMatchingTypes(ASCIIToUTF16(kValidMatches[i]), "US",
&matching_types);
ASSERT_EQ(1U, matching_types.size());
@@ -109,7 +118,7 @@ TEST_F(AddressTest, IsCountry) {
"Garbage"
};
for (size_t i = 0; i < arraysize(kInvalidMatches); ++i) {
- FieldTypeSet matching_types;
+ ServerFieldTypeSet matching_types;
address.GetMatchingTypes(ASCIIToUTF16(kInvalidMatches[i]), "US",
&matching_types);
EXPECT_EQ(0U, matching_types.size());
@@ -118,7 +127,7 @@ TEST_F(AddressTest, IsCountry) {
// Make sure that garbage values don't match when the country code is empty.
address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16());
EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
- FieldTypeSet matching_types;
+ ServerFieldTypeSet matching_types;
address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
}
diff --git a/components/autofill/core/browser/android/auxiliary_profiles_android.cc b/components/autofill/core/browser/android/auxiliary_profiles_android.cc
index 75565215ac..6d0b65b74d 100644
--- a/components/autofill/core/browser/android/auxiliary_profiles_android.cc
+++ b/components/autofill/core/browser/android/auxiliary_profiles_android.cc
@@ -16,6 +16,7 @@
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/android/auxiliary_profile_loader_android.h"
#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/phone_number.h"
// Generates the autofill profile by accessing the Android
@@ -93,7 +94,7 @@ void AuxiliaryProfilesAndroid::LoadAddress(AutofillProfile* profile) {
profile->SetRawInfo(ADDRESS_HOME_CITY, city);
profile->SetRawInfo(ADDRESS_HOME_STATE, region);
profile->SetRawInfo(ADDRESS_HOME_ZIP, postal_code);
- profile->SetInfo(ADDRESS_HOME_COUNTRY, country, app_locale_);
+ profile->SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), country, app_locale_);
}
void AuxiliaryProfilesAndroid::LoadName(AutofillProfile* profile) {
diff --git a/components/autofill/core/browser/autofill_common_test.cc b/components/autofill/core/browser/autofill_common_test.cc
index 42265cdb89..f477b25c2e 100644
--- a/components/autofill/core/browser/autofill_common_test.cc
+++ b/components/autofill/core/browser/autofill_common_test.cc
@@ -9,6 +9,7 @@
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/credit_card.h"
+#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
@@ -69,7 +70,7 @@ void CreateTestAddressFormData(FormData* form) {
}
inline void check_and_set(
- FormGroup* profile, AutofillFieldType type, const char* value) {
+ FormGroup* profile, ServerFieldType type, const char* value) {
if (value)
profile->SetRawInfo(type, UTF8ToUTF16(value));
}
diff --git a/components/autofill/core/browser/autofill_data_model.cc b/components/autofill/core/browser/autofill_data_model.cc
index 0aa0f30b4b..28a380e98b 100644
--- a/components/autofill/core/browser/autofill_data_model.cc
+++ b/components/autofill/core/browser/autofill_data_model.cc
@@ -11,6 +11,7 @@
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_field.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/state_names.h"
#include "components/autofill/core/browser/validation.h"
#include "components/autofill/core/common/form_field_data.h"
@@ -123,7 +124,7 @@ AutofillDataModel::AutofillDataModel(const std::string& guid,
origin_(origin) {}
AutofillDataModel::~AutofillDataModel() {}
-void AutofillDataModel::FillSelectControl(AutofillFieldType type,
+void AutofillDataModel::FillSelectControl(const AutofillType& type,
const std::string& app_locale,
FormFieldData* field) const {
DCHECK(field);
@@ -157,18 +158,22 @@ void AutofillDataModel::FillSelectControl(AutofillFieldType type,
return;
}
- if (type == ADDRESS_HOME_STATE || type == ADDRESS_BILLING_STATE) {
+ ServerFieldType server_type = type.server_type();
+ if (server_type == ADDRESS_HOME_STATE ||
+ server_type == ADDRESS_BILLING_STATE) {
FillStateSelectControl(field_text, field);
- } else if (type == ADDRESS_HOME_COUNTRY || type == ADDRESS_BILLING_COUNTRY) {
+ } else if (server_type == ADDRESS_HOME_COUNTRY ||
+ server_type == ADDRESS_BILLING_COUNTRY) {
FillCountrySelectControl(app_locale, field);
- } else if (type == CREDIT_CARD_EXP_MONTH) {
+ } else if (server_type == CREDIT_CARD_EXP_MONTH) {
FillExpirationMonthSelectControl(field_text, field);
- } else if (type == CREDIT_CARD_EXP_4_DIGIT_YEAR) {
+ } else if (server_type == CREDIT_CARD_EXP_4_DIGIT_YEAR) {
// Attempt to fill the year as a 2-digit year. This compensates for the
// fact that our heuristics do not always correctly detect when a website
// requests a 2-digit rather than a 4-digit year.
- FillSelectControl(CREDIT_CARD_EXP_2_DIGIT_YEAR, app_locale, field);
- } else if (type == CREDIT_CARD_TYPE) {
+ FillSelectControl(AutofillType(CREDIT_CARD_EXP_2_DIGIT_YEAR), app_locale,
+ field);
+ } else if (server_type == CREDIT_CARD_TYPE) {
FillCreditCardTypeSelectControl(field_text, field);
}
}
diff --git a/components/autofill/core/browser/autofill_data_model.h b/components/autofill/core/browser/autofill_data_model.h
index 24739dae7a..0f2cd33f0f 100644
--- a/components/autofill/core/browser/autofill_data_model.h
+++ b/components/autofill/core/browser/autofill_data_model.h
@@ -32,7 +32,7 @@ class AutofillDataModel : public FormGroup {
// Fills in select control with data matching |type| from |this|.
// Public for testing purposes.
- void FillSelectControl(AutofillFieldType type,
+ void FillSelectControl(const AutofillType& type,
const std::string& app_locale,
FormFieldData* field_data) const;
diff --git a/components/autofill/core/browser/autofill_data_model_unittest.cc b/components/autofill/core/browser/autofill_data_model_unittest.cc
index 05adaf9ab6..8004df4642 100644
--- a/components/autofill/core/browser/autofill_data_model_unittest.cc
+++ b/components/autofill/core/browser/autofill_data_model_unittest.cc
@@ -19,13 +19,13 @@ class TestAutofillDataModel : public AutofillDataModel {
virtual ~TestAutofillDataModel() {}
private:
- virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE {
+ virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE {
return base::string16();
}
- virtual void SetRawInfo(AutofillFieldType type,
+ virtual void SetRawInfo(ServerFieldType type,
const base::string16& value) OVERRIDE {}
virtual void GetSupportedTypes(
- FieldTypeSet* supported_types) const OVERRIDE {}
+ ServerFieldTypeSet* supported_types) const OVERRIDE {}
virtual void FillFormField(const AutofillField& field,
size_t variant,
const std::string& app_locale,
diff --git a/components/autofill/core/browser/autofill_download.cc b/components/autofill/core/browser/autofill_download.cc
index c189596abb..9bf81e2c72 100644
--- a/components/autofill/core/browser/autofill_download.cc
+++ b/components/autofill/core/browser/autofill_download.cc
@@ -39,7 +39,7 @@ const size_t kMaxFormCacheSize = 16;
// into the Autofill server as experiment data.
static void LogFieldAssignments(
const FormStructure& form,
- const FieldTypeSet& available_field_types) {
+ const ServerFieldTypeSet& available_field_types) {
std::string form_xml;
if (!form.EncodeFieldAssignments(available_field_types, &form_xml))
return;
@@ -124,7 +124,7 @@ bool AutofillDownloadManager::StartQueryRequest(
bool AutofillDownloadManager::StartUploadRequest(
const FormStructure& form,
bool form_was_autofilled,
- const FieldTypeSet& available_field_types) {
+ const ServerFieldTypeSet& available_field_types) {
std::string form_xml;
if (!form.EncodeUploadRequest(available_field_types, form_was_autofilled,
&form_xml))
diff --git a/components/autofill/core/browser/autofill_download.h b/components/autofill/core/browser/autofill_download.h
index 21949adcc9..bba1d71976 100644
--- a/components/autofill/core/browser/autofill_download.h
+++ b/components/autofill/core/browser/autofill_download.h
@@ -82,7 +82,7 @@ class AutofillDownloadManager : public net::URLFetcherDelegate {
// stored on the local client.
bool StartUploadRequest(const FormStructure& form,
bool form_was_autofilled,
- const FieldTypeSet& available_field_types);
+ const ServerFieldTypeSet& available_field_types);
private:
friend class AutofillDownloadTest;
diff --git a/components/autofill/core/browser/autofill_download_unittest.cc b/components/autofill/core/browser/autofill_download_unittest.cc
index ed2c705e73..9035c9cdaf 100644
--- a/components/autofill/core/browser/autofill_download_unittest.cc
+++ b/components/autofill/core/browser/autofill_download_unittest.cc
@@ -204,10 +204,10 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
download_manager_.SetNegativeUploadRate(1.0);
// Request with id 1.
EXPECT_TRUE(download_manager_.StartUploadRequest(
- *(form_structures[0]), true, FieldTypeSet()));
+ *(form_structures[0]), true, ServerFieldTypeSet()));
// Request with id 2.
EXPECT_TRUE(download_manager_.StartUploadRequest(
- *(form_structures[1]), false, FieldTypeSet()));
+ *(form_structures[1]), false, ServerFieldTypeSet()));
const char *responses[] = {
"<autofillqueryresponse>"
@@ -272,9 +272,9 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
download_manager_.SetNegativeUploadRate(0.0);
// No actual requests for the next two calls, as we set upload rate to 0%.
EXPECT_FALSE(download_manager_.StartUploadRequest(
- *(form_structures[0]), true, FieldTypeSet()));
+ *(form_structures[0]), true, ServerFieldTypeSet()));
EXPECT_FALSE(download_manager_.StartUploadRequest(
- *(form_structures[1]), false, FieldTypeSet()));
+ *(form_structures[1]), false, ServerFieldTypeSet()));
fetcher = factory.GetFetcherByID(3);
EXPECT_EQ(NULL, fetcher);
@@ -315,7 +315,7 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
form_structures[0]->upload_required_ = UPLOAD_REQUIRED;
// Request with id 4.
EXPECT_TRUE(download_manager_.StartUploadRequest(
- *(form_structures[0]), true, FieldTypeSet()));
+ *(form_structures[0]), true, ServerFieldTypeSet()));
fetcher = factory.GetFetcherByID(4);
ASSERT_TRUE(fetcher);
fetcher->set_backoff_delay(TestTimeouts::action_max_timeout());
@@ -327,7 +327,7 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) {
// Upload requests should be ignored for the next 10 seconds.
EXPECT_FALSE(download_manager_.StartUploadRequest(
- *(form_structures[0]), true, FieldTypeSet()));
+ *(form_structures[0]), true, ServerFieldTypeSet()));
fetcher = factory.GetFetcherByID(5);
EXPECT_EQ(NULL, fetcher);
}
diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc
index 1cf7c068b0..95119bfad9 100644
--- a/components/autofill/core/browser/autofill_external_delegate.cc
+++ b/components/autofill/core/browser/autofill_external_delegate.cc
@@ -48,9 +48,6 @@ void AutofillExternalDelegate::OnQuery(int query_id,
const FormFieldData& field,
const gfx::RectF& element_bounds,
bool display_warning_if_disabled) {
- // TODO(csharp): Remove once Autofill test flakiness is fixed.
- LOG(INFO) << "AutofillExternalDelegate::OnQuery";
-
autofill_query_form_ = form;
autofill_query_field_ = field;
display_warning_if_disabled_ = display_warning_if_disabled;
@@ -64,9 +61,6 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
const std::vector<base::string16>& autofill_labels,
const std::vector<base::string16>& autofill_icons,
const std::vector<int>& autofill_unique_ids) {
- // TODO(csharp): Remove once Autofill test flakiness is fixed.
- LOG(INFO) << "AutofillExternalDelegate::OnSuggestionsReturned";
-
if (query_id != autofill_query_id_)
return;
diff --git a/components/autofill/core/browser/autofill_field.cc b/components/autofill/core/browser/autofill_field.cc
index 9e72054792..5d19232400 100644
--- a/components/autofill/core/browser/autofill_field.cc
+++ b/components/autofill/core/browser/autofill_field.cc
@@ -8,6 +8,7 @@
#include "base/sha1.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "components/autofill/core/browser/autofill_type.h"
namespace {
@@ -44,7 +45,7 @@ AutofillField::AutofillField(const FormFieldData& field,
AutofillField::~AutofillField() {}
-void AutofillField::set_heuristic_type(AutofillFieldType type) {
+void AutofillField::set_heuristic_type(ServerFieldType type) {
if (type >= 0 && type < MAX_VALID_FIELD_TYPE &&
type != FIELD_WITH_DEFAULT_VALUE) {
heuristic_type_ = type;
@@ -56,7 +57,7 @@ void AutofillField::set_heuristic_type(AutofillFieldType type) {
}
}
-void AutofillField::set_server_type(AutofillFieldType type) {
+void AutofillField::set_server_type(ServerFieldType type) {
// Chrome no longer supports fax numbers, but the server still does.
if (type >= PHONE_FAX_NUMBER && type <= PHONE_FAX_WHOLE_NUMBER)
return;
@@ -64,11 +65,11 @@ void AutofillField::set_server_type(AutofillFieldType type) {
server_type_ = type;
}
-AutofillFieldType AutofillField::type() const {
+AutofillType AutofillField::Type() const {
if (server_type_ != NO_SERVER_DATA)
- return server_type_;
+ return AutofillType(server_type_);
- return heuristic_type_;
+ return AutofillType(heuristic_type_);
}
bool AutofillField::IsEmpty() const {
@@ -82,7 +83,7 @@ std::string AutofillField::FieldSignature() const {
}
bool AutofillField::IsFieldFillable() const {
- return type() != UNKNOWN_TYPE;
+ return Type().server_type() != UNKNOWN_TYPE;
}
} // namespace autofill
diff --git a/components/autofill/core/browser/autofill_field.h b/components/autofill/core/browser/autofill_field.h
index e4e8217bbe..53826cd2ec 100644
--- a/components/autofill/core/browser/autofill_field.h
+++ b/components/autofill/core/browser/autofill_field.h
@@ -14,6 +14,8 @@
namespace autofill {
+class AutofillType;
+
class AutofillField : public FormFieldData {
public:
enum PhonePart {
@@ -29,23 +31,23 @@ class AutofillField : public FormFieldData {
const base::string16& unique_name() const { return unique_name_; }
const std::string& section() const { return section_; }
- AutofillFieldType heuristic_type() const { return heuristic_type_; }
- AutofillFieldType server_type() const { return server_type_; }
- const FieldTypeSet& possible_types() const { return possible_types_; }
+ ServerFieldType heuristic_type() const { return heuristic_type_; }
+ ServerFieldType server_type() const { return server_type_; }
+ const ServerFieldTypeSet& possible_types() const { return possible_types_; }
PhonePart phone_part() const { return phone_part_; }
// Sets the heuristic type of this field, validating the input.
void set_section(const std::string& section) { section_ = section; }
- void set_heuristic_type(AutofillFieldType type);
- void set_server_type(AutofillFieldType type);
- void set_possible_types(const FieldTypeSet& possible_types) {
+ void set_heuristic_type(ServerFieldType type);
+ void set_server_type(ServerFieldType type);
+ void set_possible_types(const ServerFieldTypeSet& possible_types) {
possible_types_ = possible_types;
}
void set_phone_part(PhonePart part) { phone_part_ = part; }
// This function automatically chooses between server and heuristic autofill
// type, depending on the data available.
- AutofillFieldType type() const;
+ AutofillType Type() const;
// Returns true if the value of this field is empty.
bool IsEmpty() const;
@@ -70,13 +72,13 @@ class AutofillField : public FormFieldData {
std::string section_;
// The type of the field, as determined by the Autofill server.
- AutofillFieldType server_type_;
+ ServerFieldType server_type_;
// The type of the field, as determined by the local heuristics.
- AutofillFieldType heuristic_type_;
+ ServerFieldType heuristic_type_;
// The set of possible types for this field.
- FieldTypeSet possible_types_;
+ ServerFieldTypeSet possible_types_;
// Used to track whether this field is a phone prefix or suffix.
PhonePart phone_part_;
diff --git a/components/autofill/core/browser/autofill_field_unittest.cc b/components/autofill/core/browser/autofill_field_unittest.cc
index 53de47bbc0..c47f314861 100644
--- a/components/autofill/core/browser/autofill_field_unittest.cc
+++ b/components/autofill/core/browser/autofill_field_unittest.cc
@@ -5,6 +5,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_field.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/field_types.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -17,19 +18,19 @@ TEST(AutofillFieldTest, Type) {
ASSERT_EQ(UNKNOWN_TYPE, field.heuristic_type());
// |server_type_| is NO_SERVER_DATA, so |heuristic_type_| is returned.
- EXPECT_EQ(UNKNOWN_TYPE, field.type());
+ EXPECT_EQ(UNKNOWN_TYPE, field.Type().server_type());
// Set the heuristic type and check it.
field.set_heuristic_type(NAME_FIRST);
- EXPECT_EQ(NAME_FIRST, field.type());
+ EXPECT_EQ(NAME_FIRST, field.Type().server_type());
// Set the server type and check it.
field.set_server_type(ADDRESS_BILLING_LINE1);
- EXPECT_EQ(ADDRESS_BILLING_LINE1, field.type());
+ EXPECT_EQ(ADDRESS_BILLING_LINE1, field.Type().server_type());
// Remove the server type to make sure the heuristic type is preserved.
field.set_server_type(NO_SERVER_DATA);
- EXPECT_EQ(NAME_FIRST, field.type());
+ EXPECT_EQ(NAME_FIRST, field.Type().server_type());
}
TEST(AutofillFieldTest, IsEmpty) {
@@ -71,7 +72,7 @@ TEST(AutofillFieldTest, FieldSignature) {
TEST(AutofillFieldTest, IsFieldFillable) {
AutofillField field;
- ASSERT_EQ(UNKNOWN_TYPE, field.type());
+ ASSERT_EQ(UNKNOWN_TYPE, field.Type().server_type());
// Type is unknown.
EXPECT_FALSE(field.IsFieldFillable());
diff --git a/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc b/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc
index 4ac4edcbad..388e079f3e 100644
--- a/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc
+++ b/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc
@@ -99,7 +99,7 @@ base::string16 ReadAndDecryptValue(const RegKey& key,
}
struct {
- AutofillFieldType field_type;
+ ServerFieldType field_type;
const wchar_t *reg_value_name;
} profile_reg_values[] = {
{ NAME_FIRST, L"name_first" },
@@ -131,7 +131,7 @@ struct {
// We do not import verification code.
};
-typedef std::map<std::wstring, AutofillFieldType> RegToFieldMap;
+typedef std::map<std::wstring, ServerFieldType> RegToFieldMap;
// Imports address or credit card data from the given registry |key| into the
// given |form_group|, with the help of |reg_to_field|. When importing address
@@ -163,9 +163,9 @@ bool ImportSingleFormGroup(const RegKey& key,
// Phone numbers are stored piece-by-piece, and then reconstructed from
// the pieces. The rest of the fields are set "as is".
- if (!phone || !phone->SetInfo(it->second, field_value)) {
+ if (!phone || !phone->SetInfo(AutofillType(it->second), field_value)) {
has_non_empty_fields = true;
- form_group->SetInfo(it->second, field_value, app_locale);
+ form_group->SetInfo(AutofillType(it->second), field_value, app_locale);
}
}
}
diff --git a/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc b/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc
index dd343d1f7e..61917bcaf3 100644
--- a/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc
+++ b/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc
@@ -170,9 +170,11 @@ TEST_F(AutofillIeToolbarImportTest, TestAutofillImport) {
EXPECT_EQ(profile1[3].value, profiles[1].GetRawInfo(EMAIL_ADDRESS));
EXPECT_EQ(profile1[4].value, profiles[1].GetRawInfo(COMPANY_NAME));
EXPECT_EQ(profile1[7].value,
- profiles[1].GetInfo(PHONE_HOME_COUNTRY_CODE, "US"));
- EXPECT_EQ(profile1[6].value, profiles[1].GetInfo(PHONE_HOME_CITY_CODE, "US"));
- EXPECT_EQ(L"5555555", profiles[1].GetInfo(PHONE_HOME_NUMBER, "US"));
+ profiles[1].GetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE), "US"));
+ EXPECT_EQ(profile1[6].value,
+ profiles[1].GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
+ EXPECT_EQ(L"5555555",
+ profiles[1].GetInfo(AutofillType(PHONE_HOME_NUMBER), "US"));
EXPECT_EQ(L"+1 650-555-5555",
profiles[1].GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index 76437dfad0..dded980b5e 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -150,7 +150,7 @@ void DeterminePossibleFieldTypesForUpload(
AutofillField* field = submitted_form->field(i);
base::string16 value = CollapseWhitespace(field->value, false);
- FieldTypeSet matching_types;
+ ServerFieldTypeSet matching_types;
for (std::vector<AutofillProfile>::const_iterator it = profiles.begin();
it != profiles.end(); ++it) {
it->GetMatchingTypes(value, app_locale, &matching_types);
@@ -424,9 +424,8 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id,
GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
// Don't send suggestions for forms that aren't auto-fillable.
form_structure->IsAutofillable(false)) {
- AutofillFieldType type = autofill_field->type();
- bool is_filling_credit_card =
- (AutofillType(type).group() == CREDIT_CARD);
+ AutofillType type = autofill_field->Type();
+ bool is_filling_credit_card = (type.group() == CREDIT_CARD);
if (is_filling_credit_card) {
GetCreditCardSuggestions(
field, type, &values, &labels, &icons, &unique_ids);
@@ -534,8 +533,7 @@ void AutofillManager::OnFillAutofillFormData(int query_id,
}
// Cache the field type for the field from which the user initiated autofill.
- FieldTypeGroup initiating_group_type =
- AutofillType(autofill_field->type()).group();
+ FieldTypeGroup initiating_group_type = autofill_field->Type().group();
DCHECK_EQ(form_structure->field_count(), form.fields.size());
for (size_t i = 0; i < form_structure->field_count(); ++i) {
if (form_structure->field(i)->section() != autofill_field->section())
@@ -544,8 +542,7 @@ void AutofillManager::OnFillAutofillFormData(int query_id,
DCHECK_EQ(*form_structure->field(i), result.fields[i]);
const AutofillField* cached_field = form_structure->field(i);
- FieldTypeGroup field_group_type =
- AutofillType(cached_field->type()).group();
+ FieldTypeGroup field_group_type = cached_field->Type().group();
if (field_group_type != NO_GROUP) {
// If the field being filled is either
// (a) the field that the user initiated the fill from, or
@@ -857,7 +854,7 @@ void AutofillManager::UploadFormData(const FormStructure& submitted_form) {
was_autofilled = true;
}
- FieldTypeSet non_empty_types;
+ ServerFieldTypeSet non_empty_types;
personal_data_->GetNonEmptyTypes(&non_empty_types);
download_manager_->StartUploadRequest(submitted_form, was_autofilled,
@@ -1071,14 +1068,14 @@ bool AutofillManager::UpdateCachedForm(const FormData& live_form,
void AutofillManager::GetProfileSuggestions(
FormStructure* form,
const FormFieldData& field,
- AutofillFieldType type,
+ const AutofillType& type,
std::vector<base::string16>* values,
std::vector<base::string16>* labels,
std::vector<base::string16>* icons,
std::vector<int>* unique_ids) const {
- std::vector<AutofillFieldType> field_types(form->field_count());
+ std::vector<ServerFieldType> field_types(form->field_count());
for (size_t i = 0; i < form->field_count(); ++i) {
- field_types[i] = form->field(i)->type();
+ field_types.push_back(form->field(i)->Type().server_type());
}
std::vector<GUIDPair> guid_pairs;
@@ -1094,7 +1091,7 @@ void AutofillManager::GetProfileSuggestions(
void AutofillManager::GetCreditCardSuggestions(
const FormFieldData& field,
- AutofillFieldType type,
+ const AutofillType& type,
std::vector<base::string16>* values,
std::vector<base::string16>* labels,
std::vector<base::string16>* icons,
diff --git a/components/autofill/core/browser/autofill_manager.h b/components/autofill/core/browser/autofill_manager.h
index c0fa3dbbde..b9e4d31152 100644
--- a/components/autofill/core/browser/autofill_manager.h
+++ b/components/autofill/core/browser/autofill_manager.h
@@ -23,7 +23,6 @@
#include "components/autofill/core/browser/autocomplete_history_manager.h"
#include "components/autofill/core/browser/autofill_download.h"
#include "components/autofill/core/browser/autofill_manager_delegate.h"
-#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/common/autocheckout_status.h"
@@ -54,10 +53,11 @@ class AutofillDataModel;
class AutofillDownloadManager;
class AutofillExternalDelegate;
class AutofillField;
-class AutofillProfile;
class AutofillManagerDelegate;
class AutofillManagerTestDelegate;
class AutofillMetrics;
+class AutofillProfile;
+class AutofillType;
class CreditCard;
class FormStructureBrowserTest;
@@ -283,7 +283,7 @@ class AutofillManager : public AutofillDownloadManager::Observer {
// is filled with the Profile label.
void GetProfileSuggestions(FormStructure* form,
const FormFieldData& field,
- AutofillFieldType type,
+ const AutofillType& type,
std::vector<base::string16>* values,
std::vector<base::string16>* labels,
std::vector<base::string16>* icons,
@@ -292,7 +292,7 @@ class AutofillManager : public AutofillDownloadManager::Observer {
// Returns a list of values from the stored credit cards that match |type| and
// the value of |field| and returns the labels of the matching credit cards.
void GetCreditCardSuggestions(const FormFieldData& field,
- AutofillFieldType type,
+ const AutofillType& type,
std::vector<base::string16>* values,
std::vector<base::string16>* labels,
std::vector<base::string16>* icons,
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index 639d733edf..8c2a8efb06 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -494,7 +494,7 @@ class TestAutofillManager : public AutofillManager {
void set_expected_submitted_field_types(
- const std::vector<FieldTypeSet>& expected_types) {
+ const std::vector<ServerFieldTypeSet>& expected_types) {
expected_submitted_field_types_ = expected_types;
}
@@ -514,11 +514,11 @@ class TestAutofillManager : public AutofillManager {
base::StringPrintf(
"Field %d with value %s", static_cast<int>(i),
UTF16ToUTF8(submitted_form->field(i)->value).c_str()));
- const FieldTypeSet& possible_types =
+ const ServerFieldTypeSet& possible_types =
submitted_form->field(i)->possible_types();
EXPECT_EQ(expected_submitted_field_types_[i].size(),
possible_types.size());
- for (FieldTypeSet::const_iterator it =
+ for (ServerFieldTypeSet::const_iterator it =
expected_submitted_field_types_[i].begin();
it != expected_submitted_field_types_[i].end(); ++it) {
EXPECT_TRUE(possible_types.count(*it))
@@ -638,7 +638,7 @@ class TestAutofillManager : public AutofillManager {
std::string autocheckout_url_prefix_;
std::string submitted_form_signature_;
- std::vector<FieldTypeSet> expected_submitted_field_types_;
+ std::vector<ServerFieldTypeSet> expected_submitted_field_types_;
DISALLOW_COPY_AND_ASSIGN(TestAutofillManager);
};
@@ -864,8 +864,8 @@ class TestFormStructure : public FormStructure {
: FormStructure(form, std::string()) {}
virtual ~TestFormStructure() {}
- void SetFieldTypes(const std::vector<AutofillFieldType>& heuristic_types,
- const std::vector<AutofillFieldType>& server_types) {
+ void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types,
+ const std::vector<ServerFieldType>& server_types) {
ASSERT_EQ(field_count(), heuristic_types.size());
ASSERT_EQ(field_count(), server_types.size());
@@ -2649,10 +2649,10 @@ TEST_F(AutofillManagerTest, FormSubmittedServerTypes) {
form_structure->DetermineHeuristicTypes(metrics_logger);
// Clear the heuristic types, and instead set the appropriate server types.
- std::vector<AutofillFieldType> heuristic_types, server_types;
+ std::vector<ServerFieldType> heuristic_types, server_types;
for (size_t i = 0; i < form.fields.size(); ++i) {
heuristic_types.push_back(UNKNOWN_TYPE);
- server_types.push_back(form_structure->field(i)->type());
+ server_types.push_back(form_structure->field(i)->Type().server_type());
}
form_structure->SetFieldTypes(heuristic_types, server_types);
autofill_manager_->AddSeenForm(form_structure);
@@ -2770,11 +2770,11 @@ TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) {
form.action = GURL("http://myform.com/submit.html");
form.user_submitted = true;
- std::vector<FieldTypeSet> expected_types;
+ std::vector<ServerFieldTypeSet> expected_types;
// These fields should all match.
FormFieldData field;
- FieldTypeSet types;
+ ServerFieldTypeSet types;
test::CreateTestFormField("", "1", "Elvis", "text", &field);
types.clear();
types.insert(NAME_FIRST);
@@ -3163,10 +3163,10 @@ TEST_F(AutofillManagerTest, TestBubbleShown) {
form_structure->DetermineHeuristicTypes(metrics_logger);
// Build and add form structure with server data.
- std::vector<AutofillFieldType> heuristic_types, server_types;
+ std::vector<ServerFieldType> heuristic_types, server_types;
for (size_t i = 0; i < form.fields.size(); ++i) {
heuristic_types.push_back(UNKNOWN_TYPE);
- server_types.push_back(form_structure->field(i)->type());
+ server_types.push_back(form_structure->field(i)->Type().server_type());
}
form_structure->SetFieldTypes(heuristic_types, server_types);
autofill_manager_->AddSeenForm(form_structure);
@@ -3193,9 +3193,9 @@ TEST_F(AutofillManagerTest, TestAutocheckoutBubbleNotShown) {
form_structure->DetermineHeuristicTypes(metrics_logger);
// Build form structure without server data.
- std::vector<AutofillFieldType> heuristic_types, server_types;
+ std::vector<ServerFieldType> heuristic_types, server_types;
for (size_t i = 0; i < form.fields.size(); ++i) {
- heuristic_types.push_back(form_structure->field(i)->type());
+ heuristic_types.push_back(form_structure->field(i)->Type().server_type());
server_types.push_back(NO_SERVER_DATA);
}
form_structure->SetFieldTypes(heuristic_types, server_types);
@@ -3237,10 +3237,10 @@ TEST_F(AutofillManagerTest, DynamicFormsSeenAndIgnored) {
// Build and add form structure with server data.
scoped_ptr<TestFormStructure> form_structure(new TestFormStructure(address));
- std::vector<AutofillFieldType> heuristic_types, server_types;
+ std::vector<ServerFieldType> heuristic_types, server_types;
for (size_t i = 0; i < address.fields.size(); ++i) {
heuristic_types.push_back(UNKNOWN_TYPE);
- server_types.push_back(form_structure->field(i)->type());
+ server_types.push_back(form_structure->field(i)->Type().server_type());
}
form_structure->SetFieldTypes(heuristic_types, server_types);
autofill_manager_->AddSeenForm(form_structure.release());
diff --git a/components/autofill/core/browser/autofill_merge_unittest.cc b/components/autofill/core/browser/autofill_merge_unittest.cc
index 39951ab280..e13f494b3e 100644
--- a/components/autofill/core/browser/autofill_merge_unittest.cc
+++ b/components/autofill/core/browser/autofill_merge_unittest.cc
@@ -30,7 +30,7 @@ const char kFieldSeparator[] = ": ";
const char kProfileSeparator[] = "---";
const size_t kFieldOffset = arraysize(kFieldSeparator) - 1;
-const AutofillFieldType kProfileFieldTypes[] = {
+const ServerFieldType kProfileFieldTypes[] = {
NAME_FIRST,
NAME_MIDDLE,
NAME_LAST,
@@ -63,7 +63,7 @@ std::string SerializeProfiles(const std::vector<AutofillProfile*>& profiles) {
result += kProfileSeparator;
result += "\n";
for (size_t j = 0; j < arraysize(kProfileFieldTypes); ++j) {
- AutofillFieldType type = kProfileFieldTypes[j];
+ ServerFieldType type = kProfileFieldTypes[j];
std::vector<base::string16> values;
profiles[i]->GetRawMultiInfo(type, &values);
for (size_t k = 0; k < values.size(); ++k) {
@@ -209,7 +209,7 @@ void AutofillMergeTest::MergeProfiles(const std::string& profiles,
// into the field's name.
AutofillField* field =
const_cast<AutofillField*>(form_structure.field(i));
- AutofillFieldType type =
+ ServerFieldType type =
AutofillType::StringToFieldType(UTF16ToUTF8(field->name));
field->set_heuristic_type(type);
}
diff --git a/components/autofill/core/browser/autofill_metrics.cc b/components/autofill/core/browser/autofill_metrics.cc
index 54582cc6c1..57743c3b7f 100644
--- a/components/autofill/core/browser/autofill_metrics.cc
+++ b/components/autofill/core/browser/autofill_metrics.cc
@@ -79,7 +79,7 @@ enum FieldTypeGroupForMetrics {
//
// Clients must ensure that |field_type| is one of the types Chrome supports
// natively, e.g. |field_type| must not be a billng address.
-int GetFieldTypeGroupMetric(const AutofillFieldType field_type,
+int GetFieldTypeGroupMetric(const ServerFieldType field_type,
const int metric,
const int num_possible_metrics) {
DCHECK_LT(metric, num_possible_metrics);
@@ -250,7 +250,7 @@ void LogUMAHistogramLongTimes(const std::string& name,
void LogTypeQualityMetric(const std::string& base_name,
const int metric,
const int num_possible_metrics,
- const AutofillFieldType field_type,
+ const ServerFieldType field_type,
const std::string& experiment_id) {
DCHECK_LT(metric, num_possible_metrics);
@@ -481,7 +481,7 @@ void AutofillMetrics::LogDeveloperEngagementMetric(
void AutofillMetrics::LogHeuristicTypePrediction(
FieldTypeQualityMetric metric,
- AutofillFieldType field_type,
+ ServerFieldType field_type,
const std::string& experiment_id) const {
LogTypeQualityMetric("Autofill.Quality.HeuristicType",
metric, NUM_FIELD_TYPE_QUALITY_METRICS,
@@ -490,7 +490,7 @@ void AutofillMetrics::LogHeuristicTypePrediction(
void AutofillMetrics::LogOverallTypePrediction(
FieldTypeQualityMetric metric,
- AutofillFieldType field_type,
+ ServerFieldType field_type,
const std::string& experiment_id) const {
LogTypeQualityMetric("Autofill.Quality.PredictedType",
metric, NUM_FIELD_TYPE_QUALITY_METRICS,
@@ -499,7 +499,7 @@ void AutofillMetrics::LogOverallTypePrediction(
void AutofillMetrics::LogServerTypePrediction(
FieldTypeQualityMetric metric,
- AutofillFieldType field_type,
+ ServerFieldType field_type,
const std::string& experiment_id) const {
LogTypeQualityMetric("Autofill.Quality.ServerType",
metric, NUM_FIELD_TYPE_QUALITY_METRICS,
diff --git a/components/autofill/core/browser/autofill_metrics.h b/components/autofill/core/browser/autofill_metrics.h
index bd0dfc9016..05d3a8ddd5 100644
--- a/components/autofill/core/browser/autofill_metrics.h
+++ b/components/autofill/core/browser/autofill_metrics.h
@@ -378,14 +378,14 @@ class AutofillMetrics {
virtual void LogHeuristicTypePrediction(
FieldTypeQualityMetric metric,
- AutofillFieldType field_type,
+ ServerFieldType field_type,
const std::string& experiment_id) const;
virtual void LogOverallTypePrediction(
FieldTypeQualityMetric metric,
- AutofillFieldType field_type,
+ ServerFieldType field_type,
const std::string& experiment_id) const;
virtual void LogServerTypePrediction(FieldTypeQualityMetric metric,
- AutofillFieldType field_type,
+ ServerFieldType field_type,
const std::string& experiment_id) const;
virtual void LogQualityMetric(QualityMetric metric,
diff --git a/components/autofill/core/browser/autofill_metrics_unittest.cc b/components/autofill/core/browser/autofill_metrics_unittest.cc
index ce125fa6c2..ece18d8dfd 100644
--- a/components/autofill/core/browser/autofill_metrics_unittest.cc
+++ b/components/autofill/core/browser/autofill_metrics_unittest.cc
@@ -51,15 +51,15 @@ class MockAutofillMetrics : public AutofillMetrics {
void(DeveloperEngagementMetric metric));
MOCK_CONST_METHOD3(LogHeuristicTypePrediction,
void(FieldTypeQualityMetric metric,
- AutofillFieldType field_type,
+ ServerFieldType field_type,
const std::string& experiment_id));
MOCK_CONST_METHOD3(LogOverallTypePrediction,
void(FieldTypeQualityMetric metric,
- AutofillFieldType field_type,
+ ServerFieldType field_type,
const std::string& experiment_id));
MOCK_CONST_METHOD3(LogServerTypePrediction,
void(FieldTypeQualityMetric metric,
- AutofillFieldType field_type,
+ ServerFieldType field_type,
const std::string& experiment_id));
MOCK_CONST_METHOD2(LogQualityMetric, void(QualityMetric metric,
const std::string& experiment_id));
@@ -158,8 +158,8 @@ class TestFormStructure : public FormStructure {
: FormStructure(form, std::string()) {}
virtual ~TestFormStructure() {}
- void SetFieldTypes(const std::vector<AutofillFieldType>& heuristic_types,
- const std::vector<AutofillFieldType>& server_types) {
+ void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types,
+ const std::vector<ServerFieldType>& server_types) {
ASSERT_EQ(field_count(), heuristic_types.size());
ASSERT_EQ(field_count(), server_types.size());
@@ -212,8 +212,8 @@ class TestAutofillManager : public AutofillManager {
}
void AddSeenForm(const FormData& form,
- const std::vector<AutofillFieldType>& heuristic_types,
- const std::vector<AutofillFieldType>& server_types,
+ const std::vector<ServerFieldType>& heuristic_types,
+ const std::vector<ServerFieldType>& server_types,
const std::string& experiment_id) {
FormData empty_form = form;
for (size_t i = 0; i < empty_form.fields.size(); ++i) {
@@ -339,7 +339,7 @@ TEST_F(AutofillMetricsTest, QualityMetrics) {
form.action = GURL("http://example.com/submit.html");
form.user_submitted = true;
- std::vector<AutofillFieldType> heuristic_types, server_types;
+ std::vector<ServerFieldType> heuristic_types, server_types;
FormFieldData field;
test::CreateTestFormField(
@@ -488,8 +488,8 @@ TEST_F(AutofillMetricsTest, QualityMetricsForFailure) {
const char* label;
const char* name;
const char* value;
- AutofillFieldType heuristic_type;
- AutofillFieldType server_type;
+ ServerFieldType heuristic_type;
+ ServerFieldType server_type;
AutofillMetrics::QualityMetric heuristic_metric;
AutofillMetrics::QualityMetric server_metric;
} failure_cases[] = {
@@ -549,7 +549,7 @@ TEST_F(AutofillMetricsTest, QualityMetricsForFailure) {
}
};
- std::vector<AutofillFieldType> heuristic_types, server_types;
+ std::vector<ServerFieldType> heuristic_types, server_types;
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(failure_cases); ++i) {
FormFieldData field;
test::CreateTestFormField(failure_cases[i].label,
@@ -602,7 +602,7 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) {
form.action = GURL("http://example.com/submit.html");
form.user_submitted = true;
- std::vector<AutofillFieldType> heuristic_types, server_types;
+ std::vector<ServerFieldType> heuristic_types, server_types;
FormFieldData field;
test::CreateTestFormField(
@@ -878,7 +878,7 @@ TEST_F(AutofillMetricsTest, QualityMetricsWithExperimentId) {
form.action = GURL("http://example.com/submit.html");
form.user_submitted = true;
- std::vector<AutofillFieldType> heuristic_types, server_types;
+ std::vector<ServerFieldType> heuristic_types, server_types;
FormFieldData field;
test::CreateTestFormField(
@@ -1031,7 +1031,7 @@ TEST_F(AutofillMetricsTest, AddressSuggestionsCount) {
form.user_submitted = true;
FormFieldData field;
- std::vector<AutofillFieldType> field_types;
+ std::vector<ServerFieldType> field_types;
test::CreateTestFormField("Name", "name", "", "text", &field);
form.fields.push_back(field);
field_types.push_back(NAME_FULL);
diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc
index 653060ac7c..f1577ed84e 100644
--- a/components/autofill/core/browser/autofill_profile.cc
+++ b/components/autofill/core/browser/autofill_profile.cc
@@ -32,13 +32,12 @@ namespace {
// Like |AutofillType::GetEquivalentFieldType()|, but also returns |NAME_FULL|
// for first, middle, and last name field types.
-AutofillFieldType GetEquivalentFieldTypeCollapsingNames(
- AutofillFieldType field_type) {
- if (field_type == NAME_FIRST || field_type == NAME_MIDDLE ||
- field_type == NAME_LAST || field_type == NAME_MIDDLE_INITIAL)
+ServerFieldType GetEquivalentFieldTypeCollapsingNames(ServerFieldType type) {
+ if (type == NAME_FIRST || type == NAME_MIDDLE || type == NAME_LAST ||
+ type == NAME_MIDDLE_INITIAL)
return NAME_FULL;
- return AutofillType::GetEquivalentFieldType(field_type);
+ return AutofillType::GetEquivalentFieldType(type);
}
// Fills |distinguishing_fields| with a list of fields to use when creating
@@ -49,10 +48,10 @@ AutofillFieldType GetEquivalentFieldTypeCollapsingNames(
// |UNKNOWN_TYPE| by convention. The resulting list of fields is sorted in
// decreasing order of importance.
void GetFieldsForDistinguishingProfiles(
- const std::vector<AutofillFieldType>* suggested_fields,
- AutofillFieldType excluded_field,
- std::vector<AutofillFieldType>* distinguishing_fields) {
- static const AutofillFieldType kDefaultDistinguishingFields[] = {
+ const std::vector<ServerFieldType>* suggested_fields,
+ ServerFieldType excluded_field,
+ std::vector<ServerFieldType>* distinguishing_fields) {
+ static const ServerFieldType kDefaultDistinguishingFields[] = {
NAME_FULL,
ADDRESS_HOME_LINE1,
ADDRESS_HOME_LINE2,
@@ -75,16 +74,15 @@ void GetFieldsForDistinguishingProfiles(
// Keep track of which fields we've seen so that we avoid duplicate entries.
// Always ignore fields of unknown type and the excluded field.
- std::set<AutofillFieldType> seen_fields;
+ std::set<ServerFieldType> seen_fields;
seen_fields.insert(UNKNOWN_TYPE);
seen_fields.insert(GetEquivalentFieldTypeCollapsingNames(excluded_field));
distinguishing_fields->clear();
- for (std::vector<AutofillFieldType>::const_iterator it =
+ for (std::vector<ServerFieldType>::const_iterator it =
suggested_fields->begin();
it != suggested_fields->end(); ++it) {
- AutofillFieldType suggested_type =
- GetEquivalentFieldTypeCollapsingNames(*it);
+ ServerFieldType suggested_type = GetEquivalentFieldTypeCollapsingNames(*it);
if (seen_fields.insert(suggested_type).second)
distinguishing_fields->push_back(suggested_type);
}
@@ -95,7 +93,7 @@ void GetFieldsForDistinguishingProfiles(
// distinguish between profiles that are identical except for the name.
if (excluded_field != NAME_FULL &&
GetEquivalentFieldTypeCollapsingNames(excluded_field) == NAME_FULL) {
- for (std::vector<AutofillFieldType>::const_iterator it =
+ for (std::vector<ServerFieldType>::const_iterator it =
suggested_fields->begin();
it != suggested_fields->end(); ++it) {
if (*it != excluded_field &&
@@ -110,7 +108,7 @@ void GetFieldsForDistinguishingProfiles(
// A helper function for string streaming. Concatenates multi-valued entries
// stored for a given |type| into a single string. This string is returned.
const base::string16 MultiString(const AutofillProfile& p,
- AutofillFieldType type) {
+ ServerFieldType type) {
std::vector<base::string16> values;
p.GetRawMultiInfo(type, &values);
base::string16 accumulate;
@@ -123,15 +121,15 @@ const base::string16 MultiString(const AutofillProfile& p,
}
base::string16 GetFormGroupInfo(const FormGroup& form_group,
- AutofillFieldType type,
+ const AutofillType& type,
const std::string& app_locale) {
return app_locale.empty() ?
- form_group.GetRawInfo(type) :
+ form_group.GetRawInfo(type.server_type()) :
form_group.GetInfo(type, app_locale);
}
template <class T>
-void CopyValuesToItems(AutofillFieldType type,
+void CopyValuesToItems(ServerFieldType type,
const std::vector<base::string16>& values,
std::vector<T>* form_group_items,
const T& prototype) {
@@ -146,7 +144,7 @@ void CopyValuesToItems(AutofillFieldType type,
}
template <class T>
-void CopyItemsToValues(AutofillFieldType type,
+void CopyItemsToValues(const AutofillType& type,
const std::vector<T>& form_group_items,
const std::string& app_locale,
std::vector<base::string16>* values) {
@@ -158,11 +156,11 @@ void CopyItemsToValues(AutofillFieldType type,
// Collapse compound field types to their "full" type. I.e. First name
// collapses to full name, area code collapses to full phone, etc.
-void CollapseCompoundFieldTypes(FieldTypeSet* type_set) {
- FieldTypeSet collapsed_set;
- for (FieldTypeSet::iterator iter = type_set->begin(); iter != type_set->end();
- ++iter) {
- switch (*iter) {
+void CollapseCompoundFieldTypes(ServerFieldTypeSet* type_set) {
+ ServerFieldTypeSet collapsed_set;
+ for (ServerFieldTypeSet::iterator it = type_set->begin();
+ it != type_set->end(); ++it) {
+ switch (*it) {
case NAME_FIRST:
case NAME_MIDDLE:
case NAME_LAST:
@@ -181,7 +179,7 @@ void CollapseCompoundFieldTypes(FieldTypeSet* type_set) {
break;
default:
- collapsed_set.insert(*iter);
+ collapsed_set.insert(*it);
}
}
std::swap(*type_set, collapsed_set);
@@ -267,41 +265,43 @@ AutofillProfile& AutofillProfile::operator=(const AutofillProfile& profile) {
return *this;
}
-void AutofillProfile::GetMatchingTypes(const base::string16& text,
- const std::string& app_locale,
- FieldTypeSet* matching_types) const {
+void AutofillProfile::GetMatchingTypes(
+ const base::string16& text,
+ const std::string& app_locale,
+ ServerFieldTypeSet* matching_types) const {
FormGroupList info = FormGroups();
for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it)
(*it)->GetMatchingTypes(text, app_locale, matching_types);
}
-base::string16 AutofillProfile::GetRawInfo(AutofillFieldType type) const {
- AutofillFieldType return_type = AutofillType::GetEquivalentFieldType(type);
- const FormGroup* form_group = FormGroupForType(return_type);
+base::string16 AutofillProfile::GetRawInfo(ServerFieldType type) const {
+ ServerFieldType return_type = AutofillType::GetEquivalentFieldType(type);
+ const FormGroup* form_group = FormGroupForType(AutofillType(return_type));
if (!form_group)
return base::string16();
return form_group->GetRawInfo(return_type);
}
-void AutofillProfile::SetRawInfo(AutofillFieldType type,
+void AutofillProfile::SetRawInfo(ServerFieldType type,
const base::string16& value) {
- FormGroup* form_group = MutableFormGroupForType(type);
+ FormGroup* form_group = MutableFormGroupForType(AutofillType(type));
if (form_group)
form_group->SetRawInfo(type, CollapseWhitespace(value, false));
}
-base::string16 AutofillProfile::GetInfo(AutofillFieldType type,
- const std::string& app_locale) const {
- AutofillFieldType return_type = AutofillType::GetEquivalentFieldType(type);
- const FormGroup* form_group = FormGroupForType(return_type);
+base::string16 AutofillProfile::GetInfo(const AutofillType& type,
+ const std::string& app_locale) const {
+ ServerFieldType return_type =
+ AutofillType::GetEquivalentFieldType(type.server_type());
+ const FormGroup* form_group = FormGroupForType(AutofillType(return_type));
if (!form_group)
return base::string16();
- return form_group->GetInfo(return_type, app_locale);
+ return form_group->GetInfo(AutofillType(return_type), app_locale);
}
-bool AutofillProfile::SetInfo(AutofillFieldType type,
+bool AutofillProfile::SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) {
FormGroup* form_group = MutableFormGroupForType(type);
@@ -313,7 +313,7 @@ bool AutofillProfile::SetInfo(AutofillFieldType type,
}
void AutofillProfile::SetRawMultiInfo(
- AutofillFieldType type,
+ ServerFieldType type,
const std::vector<base::string16>& values) {
switch (AutofillType(type).group()) {
case NAME:
@@ -344,12 +344,12 @@ void AutofillProfile::SetRawMultiInfo(
}
void AutofillProfile::GetRawMultiInfo(
- AutofillFieldType type,
+ ServerFieldType type,
std::vector<base::string16>* values) const {
- GetMultiInfoImpl(type, std::string(), values);
+ GetMultiInfoImpl(AutofillType(type), std::string(), values);
}
-void AutofillProfile::GetMultiInfo(AutofillFieldType type,
+void AutofillProfile::GetMultiInfo(const AutofillType& type,
const std::string& app_locale,
std::vector<base::string16>* values) const {
GetMultiInfoImpl(type, app_locale, values);
@@ -359,11 +359,12 @@ void AutofillProfile::FillFormField(const AutofillField& field,
size_t variant,
const std::string& app_locale,
FormFieldData* field_data) const {
- AutofillFieldType type = field.type();
- DCHECK_NE(CREDIT_CARD, AutofillType(type).group());
+ AutofillType type = field.Type();
+ DCHECK_NE(CREDIT_CARD, type.group());
DCHECK(field_data);
- if (type == PHONE_HOME_NUMBER || type == PHONE_BILLING_NUMBER) {
+ if (type.server_type() == PHONE_HOME_NUMBER ||
+ type.server_type() == PHONE_BILLING_NUMBER) {
FillPhoneNumberField(field, variant, app_locale, field_data);
} else if (field_data->form_control_type == "select-one") {
FillSelectControl(type, app_locale, field_data);
@@ -385,7 +386,7 @@ void AutofillProfile::FillPhoneNumberField(const AutofillField& field,
const std::string& app_locale,
FormFieldData* field_data) const {
std::vector<base::string16> values;
- GetMultiInfo(field.type(), app_locale, &values);
+ GetMultiInfo(field.Type(), app_locale, &values);
DCHECK(variant < values.size());
// If we are filling a phone number, check to see if the size field
@@ -412,12 +413,12 @@ const base::string16 AutofillProfile::Label() const {
}
bool AutofillProfile::IsEmpty(const std::string& app_locale) const {
- FieldTypeSet types;
+ ServerFieldTypeSet types;
GetNonEmptyTypes(app_locale, &types);
return types.empty();
}
-bool AutofillProfile::IsPresentButInvalid(AutofillFieldType type) const {
+bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const {
std::string country = UTF16ToUTF8(GetRawInfo(ADDRESS_HOME_COUNTRY));
base::string16 data = GetRawInfo(type);
switch (type) {
@@ -447,13 +448,13 @@ bool AutofillProfile::IsPresentButInvalid(AutofillFieldType type) const {
int AutofillProfile::Compare(const AutofillProfile& profile) const {
- const AutofillFieldType single_value_types[] = { COMPANY_NAME,
- ADDRESS_HOME_LINE1,
- ADDRESS_HOME_LINE2,
- ADDRESS_HOME_CITY,
- ADDRESS_HOME_STATE,
- ADDRESS_HOME_ZIP,
- ADDRESS_HOME_COUNTRY };
+ const ServerFieldType single_value_types[] = { COMPANY_NAME,
+ ADDRESS_HOME_LINE1,
+ ADDRESS_HOME_LINE2,
+ ADDRESS_HOME_CITY,
+ ADDRESS_HOME_STATE,
+ ADDRESS_HOME_ZIP,
+ ADDRESS_HOME_COUNTRY };
for (size_t i = 0; i < arraysize(single_value_types); ++i) {
int comparison = GetRawInfo(single_value_types[i]).compare(
@@ -462,11 +463,11 @@ int AutofillProfile::Compare(const AutofillProfile& profile) const {
return comparison;
}
- const AutofillFieldType multi_value_types[] = { NAME_FIRST,
- NAME_MIDDLE,
- NAME_LAST,
- EMAIL_ADDRESS,
- PHONE_HOME_WHOLE_NUMBER };
+ const ServerFieldType multi_value_types[] = { NAME_FIRST,
+ NAME_MIDDLE,
+ NAME_LAST,
+ EMAIL_ADDRESS,
+ PHONE_HOME_WHOLE_NUMBER };
for (size_t i = 0; i < arraysize(multi_value_types); ++i) {
std::vector<base::string16> values_a;
@@ -503,30 +504,30 @@ const base::string16 AutofillProfile::PrimaryValue() const {
bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile,
const std::string& app_locale) const {
- FieldTypeSet types;
+ ServerFieldTypeSet types;
GetNonEmptyTypes(app_locale, &types);
- for (FieldTypeSet::const_iterator iter = types.begin(); iter != types.end();
- ++iter) {
- if (*iter == NAME_FULL) {
+ for (ServerFieldTypeSet::const_iterator it = types.begin(); it != types.end();
+ ++it) {
+ if (*it == NAME_FULL) {
// Ignore the compound "full name" field type. We are only interested in
// comparing the constituent parts. For example, if |this| has a middle
// name saved, but |profile| lacks one, |profile| could still be a subset
// of |this|.
continue;
- } else if (AutofillType(*iter).group() == PHONE_HOME) {
+ } else if (AutofillType(*it).group() == PHONE_HOME) {
// Phone numbers should be canonicalized prior to being compared.
- if (*iter != PHONE_HOME_WHOLE_NUMBER) {
+ if (*it != PHONE_HOME_WHOLE_NUMBER) {
continue;
} else if (!i18n::PhoneNumbersMatch(
- GetRawInfo(*iter),
- profile.GetRawInfo(*iter),
+ GetRawInfo(*it),
+ profile.GetRawInfo(*it),
UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)),
app_locale)) {
return false;
}
- } else if (StringToLowerASCII(GetRawInfo(*iter)) !=
- StringToLowerASCII(profile.GetRawInfo(*iter))) {
+ } else if (StringToLowerASCII(GetRawInfo(*it)) !=
+ StringToLowerASCII(profile.GetRawInfo(*it))) {
return false;
}
}
@@ -540,14 +541,14 @@ void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile,
DCHECK(!IsVerified() || profile.IsVerified());
set_origin(profile.origin());
- FieldTypeSet field_types;
+ ServerFieldTypeSet field_types;
profile.GetNonEmptyTypes(app_locale, &field_types);
// Only transfer "full" types (e.g. full name) and not fragments (e.g.
// first name, last name).
CollapseCompoundFieldTypes(&field_types);
- for (FieldTypeSet::const_iterator iter = field_types.begin();
+ for (ServerFieldTypeSet::const_iterator iter = field_types.begin();
iter != field_types.end(); ++iter) {
if (AutofillProfile::SupportsMultiValue(*iter)) {
std::vector<base::string16> new_values;
@@ -588,7 +589,7 @@ void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile,
}
// static
-bool AutofillProfile::SupportsMultiValue(AutofillFieldType type) {
+bool AutofillProfile::SupportsMultiValue(ServerFieldType type) {
FieldTypeGroup group = AutofillType(type).group();
return group == NAME ||
group == NAME_BILLING ||
@@ -620,14 +621,14 @@ bool AutofillProfile::AdjustInferredLabels(
// static
void AutofillProfile::CreateInferredLabels(
const std::vector<AutofillProfile*>* profiles,
- const std::vector<AutofillFieldType>* suggested_fields,
- AutofillFieldType excluded_field,
+ const std::vector<ServerFieldType>* suggested_fields,
+ ServerFieldType excluded_field,
size_t minimal_fields_shown,
std::vector<base::string16>* created_labels) {
DCHECK(profiles);
DCHECK(created_labels);
- std::vector<AutofillFieldType> fields_to_use;
+ std::vector<ServerFieldType> fields_to_use;
GetFieldsForDistinguishingProfiles(suggested_fields, excluded_field,
&fields_to_use);
@@ -660,7 +661,8 @@ void AutofillProfile::CreateInferredLabels(
}
}
-void AutofillProfile::GetSupportedTypes(FieldTypeSet* supported_types) const {
+void AutofillProfile::GetSupportedTypes(
+ ServerFieldTypeSet* supported_types) const {
FormGroupList info = FormGroups();
for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it)
(*it)->GetSupportedTypes(supported_types);
@@ -689,10 +691,10 @@ bool AutofillProfile::FillCountrySelectControl(
}
void AutofillProfile::GetMultiInfoImpl(
- AutofillFieldType type,
+ const AutofillType& type,
const std::string& app_locale,
std::vector<base::string16>* values) const {
- switch (AutofillType(type).group()) {
+ switch (type.group()) {
case NAME:
case NAME_BILLING:
CopyItemsToValues(type, name_, app_locale, values);
@@ -726,14 +728,14 @@ void AutofillProfile::AddPhoneIfUnique(
}
base::string16 AutofillProfile::ConstructInferredLabel(
- const std::vector<AutofillFieldType>& included_fields,
+ const std::vector<ServerFieldType>& included_fields,
size_t num_fields_to_use) const {
const base::string16 separator =
l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR);
base::string16 label;
size_t num_fields_used = 0;
- for (std::vector<AutofillFieldType>::const_iterator it =
+ for (std::vector<ServerFieldType>::const_iterator it =
included_fields.begin();
it != included_fields.end() && num_fields_used < num_fields_to_use;
++it) {
@@ -754,14 +756,14 @@ base::string16 AutofillProfile::ConstructInferredLabel(
void AutofillProfile::CreateDifferentiatingLabels(
const std::vector<AutofillProfile*>& profiles,
const std::list<size_t>& indices,
- const std::vector<AutofillFieldType>& fields,
+ const std::vector<ServerFieldType>& fields,
size_t num_fields_to_include,
std::vector<base::string16>* created_labels) {
// For efficiency, we first construct a map of fields to their text values and
// each value's frequency.
- std::map<AutofillFieldType,
+ std::map<ServerFieldType,
std::map<base::string16, size_t> > field_text_frequencies_by_field;
- for (std::vector<AutofillFieldType>::const_iterator field = fields.begin();
+ for (std::vector<ServerFieldType>::const_iterator field = fields.begin();
field != fields.end(); ++field) {
std::map<base::string16, size_t>& field_text_frequencies =
field_text_frequencies_by_field[*field];
@@ -791,9 +793,9 @@ void AutofillProfile::CreateDifferentiatingLabels(
it != indices.end(); ++it) {
const AutofillProfile* profile = profiles[*it];
- std::vector<AutofillFieldType> label_fields;
+ std::vector<ServerFieldType> label_fields;
bool found_differentiating_field = false;
- for (std::vector<AutofillFieldType>::const_iterator field = fields.begin();
+ for (std::vector<ServerFieldType>::const_iterator field = fields.begin();
field != fields.end(); ++field) {
// Skip over empty fields.
base::string16 field_text = profile->GetRawInfo(*field);
@@ -838,36 +840,37 @@ AutofillProfile::FormGroupList AutofillProfile::FormGroups() const {
}
const FormGroup* AutofillProfile::FormGroupForType(
- AutofillFieldType type) const {
+ const AutofillType& type) const {
return const_cast<AutofillProfile*>(this)->MutableFormGroupForType(type);
}
-FormGroup* AutofillProfile::MutableFormGroupForType(AutofillFieldType type) {
- FormGroup* form_group = NULL;
- switch (AutofillType(type).group()) {
+FormGroup* AutofillProfile::MutableFormGroupForType(const AutofillType& type) {
+ switch (type.group()) {
case NAME:
case NAME_BILLING:
- form_group = &name_[0];
- break;
+ return &name_[0];
+
case EMAIL:
- form_group = &email_[0];
- break;
+ return &email_[0];
+
case COMPANY:
- form_group = &company_;
- break;
+ return &company_;
+
case PHONE_HOME:
case PHONE_BILLING:
- form_group = &phone_number_[0];
- break;
+ return &phone_number_[0];
+
case ADDRESS_HOME:
case ADDRESS_BILLING:
- form_group = &address_;
- break;
- default:
- break;
+ return &address_;
+
+ case NO_GROUP:
+ case CREDIT_CARD:
+ return NULL;
}
- return form_group;
+ NOTREACHED();
+ return NULL;
}
// So we can compare AutofillProfiles with EXPECT_EQ().
diff --git a/components/autofill/core/browser/autofill_profile.h b/components/autofill/core/browser/autofill_profile.h
index 49a488f794..5a3f65c756 100644
--- a/components/autofill/core/browser/autofill_profile.h
+++ b/components/autofill/core/browser/autofill_profile.h
@@ -18,7 +18,6 @@
#include "components/autofill/core/browser/autofill_data_model.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/contact_info.h"
-#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/phone_number.h"
namespace autofill {
@@ -41,15 +40,16 @@ class AutofillProfile : public AutofillDataModel {
AutofillProfile& operator=(const AutofillProfile& profile);
// FormGroup:
- virtual void GetMatchingTypes(const base::string16& text,
- const std::string& app_locale,
- FieldTypeSet* matching_types) const OVERRIDE;
- virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
- virtual void SetRawInfo(AutofillFieldType type,
+ virtual void GetMatchingTypes(
+ const base::string16& text,
+ const std::string& app_locale,
+ ServerFieldTypeSet* matching_types) const OVERRIDE;
+ virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
+ virtual void SetRawInfo(ServerFieldType type,
const base::string16& value) OVERRIDE;
- virtual base::string16 GetInfo(AutofillFieldType type,
- const std::string& app_locale) const OVERRIDE;
- virtual bool SetInfo(AutofillFieldType type,
+ virtual base::string16 GetInfo(const AutofillType& type,
+ const std::string& app_locale) const OVERRIDE;
+ virtual bool SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) OVERRIDE;
@@ -60,11 +60,11 @@ class AutofillProfile : public AutofillDataModel {
FormFieldData* field_data) const OVERRIDE;
// Multi-value equivalents to |GetInfo| and |SetInfo|.
- void SetRawMultiInfo(AutofillFieldType type,
+ void SetRawMultiInfo(ServerFieldType type,
const std::vector<base::string16>& values);
- void GetRawMultiInfo(AutofillFieldType type,
+ void GetRawMultiInfo(ServerFieldType type,
std::vector<base::string16>* values) const;
- void GetMultiInfo(AutofillFieldType type,
+ void GetMultiInfo(const AutofillType& type,
const std::string& app_locale,
std::vector<base::string16>* values) const;
@@ -87,7 +87,7 @@ class AutofillProfile : public AutofillDataModel {
// Returns true if the |type| of data in this profile is present, but invalid.
// Otherwise returns false.
- bool IsPresentButInvalid(AutofillFieldType type) const;
+ bool IsPresentButInvalid(ServerFieldType type) const;
// Comparison for Sync. Returns 0 if the profile is the same as |this|,
// or < 0, or > 0 if it is different. The implied ordering can be used for
@@ -119,7 +119,7 @@ class AutofillProfile : public AutofillDataModel {
const std::string& app_locale);
// Returns |true| if |type| accepts multi-values.
- static bool SupportsMultiValue(AutofillFieldType type);
+ static bool SupportsMultiValue(ServerFieldType type);
// Adjusts the labels according to profile data.
// Labels contain minimal different combination of:
@@ -144,8 +144,8 @@ class AutofillProfile : public AutofillDataModel {
// least |minimal_fields_shown| fields, if possible.
static void CreateInferredLabels(
const std::vector<AutofillProfile*>* profiles,
- const std::vector<AutofillFieldType>* suggested_fields,
- AutofillFieldType excluded_field,
+ const std::vector<ServerFieldType>* suggested_fields,
+ ServerFieldType excluded_field,
size_t minimal_fields_shown,
std::vector<base::string16>* created_labels);
@@ -155,12 +155,13 @@ class AutofillProfile : public AutofillDataModel {
// FormGroup:
virtual bool FillCountrySelectControl(const std::string& app_locale,
FormFieldData* field) const OVERRIDE;
- virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
+ virtual void GetSupportedTypes(
+ ServerFieldTypeSet* supported_types) const OVERRIDE;
// Shared implementation for GetRawMultiInfo() and GetMultiInfo(). Pass an
// empty |app_locale| to get the raw info; otherwise, the returned info is
// canonicalized according to the given |app_locale|, if appropriate.
- void GetMultiInfoImpl(AutofillFieldType type,
+ void GetMultiInfoImpl(const AutofillType& type,
const std::string& app_locale,
std::vector<base::string16>* values) const;
@@ -176,7 +177,7 @@ class AutofillProfile : public AutofillDataModel {
// fields in |label_fields|. Uses as many fields as possible if there are not
// enough non-empty fields.
base::string16 ConstructInferredLabel(
- const std::vector<AutofillFieldType>& label_fields,
+ const std::vector<ServerFieldType>& label_fields,
size_t num_fields_to_include) const;
// Creates inferred labels for |profiles| at indices corresponding to
@@ -187,15 +188,15 @@ class AutofillProfile : public AutofillDataModel {
static void CreateDifferentiatingLabels(
const std::vector<AutofillProfile*>& profiles,
const std::list<size_t>& indices,
- const std::vector<AutofillFieldType>& fields,
+ const std::vector<ServerFieldType>& fields,
size_t num_fields_to_include,
std::vector<base::string16>* created_labels);
// Utilities for listing and lookup of the data members that constitute
// user-visible profile information.
FormGroupList FormGroups() const;
- const FormGroup* FormGroupForType(AutofillFieldType type) const;
- FormGroup* MutableFormGroupForType(AutofillFieldType type);
+ const FormGroup* FormGroupForType(const AutofillType& type) const;
+ FormGroup* MutableFormGroupForType(const AutofillType& type);
// The label presented to the user when selecting a profile.
base::string16 label_;
diff --git a/components/autofill/core/browser/autofill_profile_unittest.cc b/components/autofill/core/browser/autofill_profile_unittest.cc
index 1b7cfc7d57..f67c536324 100644
--- a/components/autofill/core/browser/autofill_profile_unittest.cc
+++ b/components/autofill/core/browser/autofill_profile_unittest.cc
@@ -12,6 +12,7 @@
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_common_test.h"
#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/common/form_field_data.h"
#include "grit/component_strings.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -344,7 +345,7 @@ TEST(AutofillProfileTest, CreateInferredLabels) {
EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore., Dis"),
labels[1]);
- std::vector<AutofillFieldType> suggested_fields;
+ std::vector<ServerFieldType> suggested_fields;
suggested_fields.push_back(ADDRESS_HOME_CITY);
suggested_fields.push_back(ADDRESS_HOME_STATE);
suggested_fields.push_back(ADDRESS_HOME_ZIP);
@@ -422,7 +423,7 @@ TEST(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) {
// If the only name field in the suggested fields is the excluded field, we
// should not fall back to the full name as a distinguishing field.
- std::vector<AutofillFieldType> suggested_fields;
+ std::vector<ServerFieldType> suggested_fields;
suggested_fields.push_back(NAME_LAST);
suggested_fields.push_back(ADDRESS_HOME_LINE1);
suggested_fields.push_back(EMAIL_ADDRESS);
@@ -458,7 +459,7 @@ TEST(AutofillProfileTest, CreateInferredLabelsNoDuplicatedFields) {
// If the only name field in the suggested fields is the excluded field, we
// should not fall back to the full name as a distinguishing field.
- std::vector<AutofillFieldType> suggested_fields;
+ std::vector<ServerFieldType> suggested_fields;
suggested_fields.push_back(ADDRESS_HOME_LINE1);
suggested_fields.push_back(ADDRESS_BILLING_LINE1);
suggested_fields.push_back(EMAIL_ADDRESS);
@@ -787,7 +788,8 @@ TEST(AutofillProfileTest, AddressCountryFull) {
AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
- profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field);
+ profile.FillSelectControl(
+ AutofillType(ADDRESS_HOME_COUNTRY), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("Canada"), field.value);
}
@@ -807,7 +809,8 @@ TEST(AutofillProfileTest, AddressCountryAbbrev) {
AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
- profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field);
+ profile.FillSelectControl(
+ AutofillType(ADDRESS_HOME_COUNTRY), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
}
@@ -827,7 +830,7 @@ TEST(AutofillProfileTest, AddressStateFull) {
AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
- profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
+ profile.FillSelectControl(AutofillType(ADDRESS_HOME_STATE), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("California"), field.value);
}
@@ -847,7 +850,7 @@ TEST(AutofillProfileTest, AddressStateAbbrev) {
AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
- profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
+ profile.FillSelectControl(AutofillType(ADDRESS_HOME_STATE), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
}
@@ -869,7 +872,7 @@ TEST(AutofillProfileTest, FillByValue) {
AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
- profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
+ profile.FillSelectControl(AutofillType(ADDRESS_HOME_STATE), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("California"), field.value);
}
@@ -891,7 +894,7 @@ TEST(AutofillProfileTest, FillByContents) {
AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
- profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
+ profile.FillSelectControl(AutofillType(ADDRESS_HOME_STATE), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("2"), field.value);
}
diff --git a/components/autofill/core/browser/autofill_server_field_info.h b/components/autofill/core/browser/autofill_server_field_info.h
index a748af1cc0..e62cba7d09 100644
--- a/components/autofill/core/browser/autofill_server_field_info.h
+++ b/components/autofill/core/browser/autofill_server_field_info.h
@@ -13,7 +13,7 @@ namespace autofill {
struct AutofillServerFieldInfo {
// The predicted type returned by the Autofill server for this field.
- AutofillFieldType field_type;
+ ServerFieldType field_type;
// Default value to be used for the field (only applies to
// FIELD_WITH_DEFAULT_TYPE field type)
std::string default_value;
diff --git a/components/autofill/core/browser/autofill_type.cc b/components/autofill/core/browser/autofill_type.cc
index 10acc9e0e7..14eeee0ee4 100644
--- a/components/autofill/core/browser/autofill_type.cc
+++ b/components/autofill/core/browser/autofill_type.cc
@@ -10,14 +10,15 @@
namespace autofill {
-AutofillType::AutofillType(AutofillFieldType field_type) {
+AutofillType::AutofillType(ServerFieldType field_type) {
if ((field_type < NO_SERVER_DATA || field_type >= MAX_VALID_FIELD_TYPE) ||
(field_type >= 15 && field_type <= 19) ||
(field_type >= 25 && field_type <= 29) ||
- (field_type >= 44 && field_type <= 50))
- field_type_ = UNKNOWN_TYPE;
- else
- field_type_ = field_type;
+ (field_type >= 44 && field_type <= 50)) {
+ server_type_ = UNKNOWN_TYPE;
+ } else {
+ server_type_ = field_type;
+ }
}
AutofillType::AutofillType(const AutofillType& autofill_type) {
@@ -26,16 +27,12 @@ AutofillType::AutofillType(const AutofillType& autofill_type) {
AutofillType& AutofillType::operator=(const AutofillType& autofill_type) {
if (this != &autofill_type)
- this->field_type_ = autofill_type.field_type_;
+ this->server_type_ = autofill_type.server_type_;
return *this;
}
-AutofillFieldType AutofillType::field_type() const {
- return field_type_;
-}
-
FieldTypeGroup AutofillType::group() const {
- switch (field_type_) {
+ switch (server_type_) {
case NAME_FIRST:
case NAME_MIDDLE:
case NAME_LAST:
@@ -107,8 +104,8 @@ FieldTypeGroup AutofillType::group() const {
}
// static
-AutofillFieldType AutofillType::GetEquivalentFieldType(
- AutofillFieldType field_type) {
+ServerFieldType AutofillType::GetEquivalentFieldType(
+ ServerFieldType field_type) {
// When billing information is requested from the profile we map to the
// home address equivalents.
switch (field_type) {
@@ -172,8 +169,8 @@ AutofillFieldType AutofillType::GetEquivalentFieldType(
}
// static
-AutofillFieldType AutofillType::GetEquivalentBillingFieldType(
- AutofillFieldType field_type) {
+ServerFieldType AutofillType::GetEquivalentBillingFieldType(
+ ServerFieldType field_type) {
switch (field_type) {
case ADDRESS_HOME_LINE1:
return ADDRESS_BILLING_LINE1;
@@ -235,7 +232,7 @@ AutofillFieldType AutofillType::GetEquivalentBillingFieldType(
}
// static
-std::string AutofillType::FieldTypeToString(AutofillFieldType type) {
+std::string AutofillType::FieldTypeToString(ServerFieldType type) {
switch (type) {
case NO_SERVER_DATA:
return "NO_SERVER_DATA";
@@ -356,7 +353,7 @@ std::string AutofillType::FieldTypeToString(AutofillFieldType type) {
}
// static
-AutofillFieldType AutofillType::StringToFieldType(const std::string& str) {
+ServerFieldType AutofillType::StringToFieldType(const std::string& str) {
if (str == "NO_SERVER_DATA")
return NO_SERVER_DATA;
if (str == "UNKNOWN_TYPE")
@@ -448,7 +445,7 @@ AutofillFieldType AutofillType::StringToFieldType(const std::string& str) {
if (str == "COMPANY_NAME")
return COMPANY_NAME;
- NOTREACHED() << "Unknown AutofillFieldType " << str;
+ NOTREACHED() << "Unknown ServerFieldType " << str;
return UNKNOWN_TYPE;
}
diff --git a/components/autofill/core/browser/autofill_type.h b/components/autofill/core/browser/autofill_type.h
index c85bea1589..a7d243c4f3 100644
--- a/components/autofill/core/browser/autofill_type.h
+++ b/components/autofill/core/browser/autofill_type.h
@@ -15,29 +15,32 @@ namespace autofill {
// and for associating form fields with form values in the Web Database.
class AutofillType {
public:
- explicit AutofillType(AutofillFieldType field_type);
+ explicit AutofillType(ServerFieldType field_type);
AutofillType(const AutofillType& autofill_type);
AutofillType& operator=(const AutofillType& autofill_type);
- AutofillFieldType field_type() const;
+ // TODO(isherman): Audit all uses of this method.
+ ServerFieldType server_type() const { return server_type_; }
FieldTypeGroup group() const;
// Maps |field_type| to a field type that can be directly stored in a profile
// (in the sense that it makes sense to call |AutofillProfile::SetInfo()| with
// the returned field type as the first parameter).
- static AutofillFieldType GetEquivalentFieldType(AutofillFieldType field_type);
+ static ServerFieldType GetEquivalentFieldType(ServerFieldType field_type);
// Maps |field_type| to a field type from ADDRESS_BILLING FieldTypeGroup if
// field type is an Address type.
- static AutofillFieldType GetEquivalentBillingFieldType(
- AutofillFieldType field_type);
+ static ServerFieldType GetEquivalentBillingFieldType(
+ ServerFieldType field_type);
- // Utilities for serializing and deserializing an |AutofillFieldType|.
- static std::string FieldTypeToString(AutofillFieldType field_type);
- static AutofillFieldType StringToFieldType(const std::string& str);
+ // Utilities for serializing and deserializing a |ServerFieldType|.
+ // TODO(isherman): This should probably serialize an HTML type as well.
+ // Audit all uses of these functions.
+ static std::string FieldTypeToString(ServerFieldType field_type);
+ static ServerFieldType StringToFieldType(const std::string& str);
private:
- AutofillFieldType field_type_;
+ ServerFieldType server_type_;
};
} // namespace autofill
diff --git a/components/autofill/core/browser/autofill_type_unittest.cc b/components/autofill/core/browser/autofill_type_unittest.cc
index 8bff67162b..d9e8f9e6f0 100644
--- a/components/autofill/core/browser/autofill_type_unittest.cc
+++ b/components/autofill/core/browser/autofill_type_unittest.cc
@@ -11,42 +11,42 @@ namespace {
TEST(AutofillTypeTest, AutofillTypes) {
// No server data.
AutofillType none(NO_SERVER_DATA);
- EXPECT_EQ(NO_SERVER_DATA, none.field_type());
+ EXPECT_EQ(NO_SERVER_DATA, none.server_type());
EXPECT_EQ(NO_GROUP, none.group());
// Unknown type.
AutofillType unknown(UNKNOWN_TYPE);
- EXPECT_EQ(UNKNOWN_TYPE, unknown.field_type());
+ EXPECT_EQ(UNKNOWN_TYPE, unknown.server_type());
EXPECT_EQ(NO_GROUP, unknown.group());
// Type with group but no subgroup.
AutofillType first(NAME_FIRST);
- EXPECT_EQ(NAME_FIRST, first.field_type());
+ EXPECT_EQ(NAME_FIRST, first.server_type());
EXPECT_EQ(NAME, first.group());
// Type with group and subgroup.
AutofillType phone(PHONE_HOME_NUMBER);
- EXPECT_EQ(PHONE_HOME_NUMBER, phone.field_type());
+ EXPECT_EQ(PHONE_HOME_NUMBER, phone.server_type());
EXPECT_EQ(PHONE_HOME, phone.group());
// Last value, to check any offset errors.
AutofillType last(COMPANY_NAME);
- EXPECT_EQ(COMPANY_NAME, last.field_type());
+ EXPECT_EQ(COMPANY_NAME, last.server_type());
EXPECT_EQ(COMPANY, last.group());
// Boundary (error) condition.
AutofillType boundary(MAX_VALID_FIELD_TYPE);
- EXPECT_EQ(UNKNOWN_TYPE, boundary.field_type());
+ EXPECT_EQ(UNKNOWN_TYPE, boundary.server_type());
EXPECT_EQ(NO_GROUP, boundary.group());
// Beyond the boundary (error) condition.
- AutofillType beyond(static_cast<AutofillFieldType>(MAX_VALID_FIELD_TYPE+10));
- EXPECT_EQ(UNKNOWN_TYPE, beyond.field_type());
+ AutofillType beyond(static_cast<ServerFieldType>(MAX_VALID_FIELD_TYPE+10));
+ EXPECT_EQ(UNKNOWN_TYPE, beyond.server_type());
EXPECT_EQ(NO_GROUP, beyond.group());
// In-between value. Missing from enum but within range. Error condition.
- AutofillType between(static_cast<AutofillFieldType>(16));
- EXPECT_EQ(UNKNOWN_TYPE, between.field_type());
+ AutofillType between(static_cast<ServerFieldType>(16));
+ EXPECT_EQ(UNKNOWN_TYPE, between.server_type());
EXPECT_EQ(NO_GROUP, between.group());
}
diff --git a/components/autofill/core/browser/autofill_xml_parser.cc b/components/autofill/core/browser/autofill_xml_parser.cc
index 972e42e60d..c1acbe90f7 100644
--- a/components/autofill/core/browser/autofill_xml_parser.cc
+++ b/components/autofill/core/browser/autofill_xml_parser.cc
@@ -100,7 +100,7 @@ void AutofillQueryXmlParser::StartElement(buzz::XmlParseContext* context,
if (attribute_name.compare("autofilltype") == 0) {
int value = GetIntValue(context, *attrs);
if (value >= 0 && value < MAX_VALID_FIELD_TYPE)
- field_info.field_type = static_cast<AutofillFieldType>(value);
+ field_info.field_type = static_cast<ServerFieldType>(value);
else
field_info.field_type = NO_SERVER_DATA;
} else if (field_info.field_type == FIELD_WITH_DEFAULT_VALUE &&
diff --git a/components/autofill/core/browser/contact_info.cc b/components/autofill/core/browser/contact_info.cc
index 11d6b2bde8..7ecf44d5aa 100644
--- a/components/autofill/core/browser/contact_info.cc
+++ b/components/autofill/core/browser/contact_info.cc
@@ -13,11 +13,10 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_type.h"
-#include "components/autofill/core/browser/field_types.h"
namespace autofill {
-static const AutofillFieldType kAutofillNameInfoTypes[] = {
+static const ServerFieldType kAutofillNameInfoTypes[] = {
NAME_FIRST,
NAME_MIDDLE,
NAME_LAST
@@ -44,7 +43,7 @@ NameInfo& NameInfo::operator=(const NameInfo& info) {
return *this;
}
-void NameInfo::GetSupportedTypes(FieldTypeSet* supported_types) const {
+void NameInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(NAME_FIRST);
supported_types->insert(NAME_MIDDLE);
supported_types->insert(NAME_LAST);
@@ -52,7 +51,7 @@ void NameInfo::GetSupportedTypes(FieldTypeSet* supported_types) const {
supported_types->insert(NAME_FULL);
}
-base::string16 NameInfo::GetRawInfo(AutofillFieldType type) const {
+base::string16 NameInfo::GetRawInfo(ServerFieldType type) const {
type = AutofillType::GetEquivalentFieldType(type);
if (type == NAME_FIRST)
return first();
@@ -72,7 +71,7 @@ base::string16 NameInfo::GetRawInfo(AutofillFieldType type) const {
return base::string16();
}
-void NameInfo::SetRawInfo(AutofillFieldType type, const base::string16& value) {
+void NameInfo::SetRawInfo(ServerFieldType type, const base::string16& value) {
type = AutofillType::GetEquivalentFieldType(type);
DCHECK_EQ(NAME, AutofillType(type).group());
if (type == NAME_FIRST)
@@ -151,19 +150,18 @@ EmailInfo& EmailInfo::operator=(const EmailInfo& info) {
return *this;
}
-void EmailInfo::GetSupportedTypes(FieldTypeSet* supported_types) const {
+void EmailInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(EMAIL_ADDRESS);
}
-base::string16 EmailInfo::GetRawInfo(AutofillFieldType type) const {
+base::string16 EmailInfo::GetRawInfo(ServerFieldType type) const {
if (type == EMAIL_ADDRESS)
return email_;
return base::string16();
}
-void EmailInfo::SetRawInfo(AutofillFieldType type,
- const base::string16& value) {
+void EmailInfo::SetRawInfo(ServerFieldType type, const base::string16& value) {
DCHECK_EQ(EMAIL_ADDRESS, type);
email_ = value;
}
@@ -184,18 +182,18 @@ CompanyInfo& CompanyInfo::operator=(const CompanyInfo& info) {
return *this;
}
-void CompanyInfo::GetSupportedTypes(FieldTypeSet* supported_types) const {
+void CompanyInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(COMPANY_NAME);
}
-base::string16 CompanyInfo::GetRawInfo(AutofillFieldType type) const {
+base::string16 CompanyInfo::GetRawInfo(ServerFieldType type) const {
if (type == COMPANY_NAME)
return company_name_;
return base::string16();
}
-void CompanyInfo::SetRawInfo(AutofillFieldType type,
+void CompanyInfo::SetRawInfo(ServerFieldType type,
const base::string16& value) {
DCHECK_EQ(COMPANY_NAME, type);
company_name_ = value;
diff --git a/components/autofill/core/browser/contact_info.h b/components/autofill/core/browser/contact_info.h
index dc57bc2fbe..007be1be81 100644
--- a/components/autofill/core/browser/contact_info.h
+++ b/components/autofill/core/browser/contact_info.h
@@ -10,7 +10,6 @@
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/strings/string16.h"
-#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_group.h"
namespace autofill {
@@ -25,13 +24,14 @@ class NameInfo : public FormGroup {
NameInfo& operator=(const NameInfo& info);
// FormGroup:
- virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
- virtual void SetRawInfo(AutofillFieldType type,
+ virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
+ virtual void SetRawInfo(ServerFieldType type,
const base::string16& value) OVERRIDE;
private:
// FormGroup:
- virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
+ virtual void GetSupportedTypes(
+ ServerFieldTypeSet* supported_types) const OVERRIDE;
// Returns the full name, which can include up to the first, middle, and last
// name.
@@ -63,13 +63,14 @@ class EmailInfo : public FormGroup {
EmailInfo& operator=(const EmailInfo& info);
// FormGroup:
- virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
- virtual void SetRawInfo(AutofillFieldType type,
+ virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
+ virtual void SetRawInfo(ServerFieldType type,
const base::string16& value) OVERRIDE;
private:
// FormGroup:
- virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
+ virtual void GetSupportedTypes(
+ ServerFieldTypeSet* supported_types) const OVERRIDE;
base::string16 email_;
};
@@ -83,13 +84,14 @@ class CompanyInfo : public FormGroup {
CompanyInfo& operator=(const CompanyInfo& info);
// FormGroup:
- virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
- virtual void SetRawInfo(AutofillFieldType type,
+ virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
+ virtual void SetRawInfo(ServerFieldType type,
const base::string16& value) OVERRIDE;
private:
// FormGroup:
- virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
+ virtual void GetSupportedTypes(
+ ServerFieldTypeSet* supported_types) const OVERRIDE;
base::string16 company_name_;
};
diff --git a/components/autofill/core/browser/credit_card.cc b/components/autofill/core/browser/credit_card.cc
index 8fc67ee3b5..e627207388 100644
--- a/components/autofill/core/browser/credit_card.cc
+++ b/components/autofill/core/browser/credit_card.cc
@@ -21,7 +21,6 @@
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_regexes.h"
#include "components/autofill/core/browser/autofill_type.h"
-#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/validation.h"
#include "components/autofill/core/common/form_field_data.h"
#include "grit/component_strings.h"
@@ -276,7 +275,7 @@ std::string CreditCard::GetCreditCardType(const base::string16& number) {
return kGenericCard;
}
-base::string16 CreditCard::GetRawInfo(AutofillFieldType type) const {
+base::string16 CreditCard::GetRawInfo(ServerFieldType type) const {
switch (type) {
case CREDIT_CARD_NAME:
return name_on_card_;
@@ -322,7 +321,7 @@ base::string16 CreditCard::GetRawInfo(AutofillFieldType type) const {
}
}
-void CreditCard::SetRawInfo(AutofillFieldType type,
+void CreditCard::SetRawInfo(ServerFieldType type,
const base::string16& value) {
switch (type) {
case CREDIT_CARD_NAME:
@@ -370,33 +369,35 @@ void CreditCard::SetRawInfo(AutofillFieldType type,
}
}
-base::string16 CreditCard::GetInfo(AutofillFieldType type,
+base::string16 CreditCard::GetInfo(const AutofillType& type,
const std::string& app_locale) const {
- if (type == CREDIT_CARD_NUMBER)
+ if (type.server_type() == CREDIT_CARD_NUMBER)
return StripSeparators(number_);
- return GetRawInfo(type);
+ return GetRawInfo(type.server_type());
}
-bool CreditCard::SetInfo(AutofillFieldType type,
+bool CreditCard::SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) {
- if (type == CREDIT_CARD_NUMBER)
- SetRawInfo(type, StripSeparators(value));
- else if (type == CREDIT_CARD_EXP_MONTH)
+ ServerFieldType server_type = type.server_type();
+ if (server_type == CREDIT_CARD_NUMBER)
+ SetRawInfo(server_type, StripSeparators(value));
+ else if (server_type == CREDIT_CARD_EXP_MONTH)
SetExpirationMonthFromString(value, app_locale);
else
- SetRawInfo(type, value);
+ SetRawInfo(server_type, value);
return true;
}
void CreditCard::GetMatchingTypes(const base::string16& text,
const std::string& app_locale,
- FieldTypeSet* matching_types) const {
+ ServerFieldTypeSet* matching_types) const {
FormGroup::GetMatchingTypes(text, app_locale, matching_types);
- base::string16 card_number = GetInfo(CREDIT_CARD_NUMBER, app_locale);
+ base::string16 card_number =
+ GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale);
if (!card_number.empty() && StripSeparators(text) == card_number)
matching_types->insert(CREDIT_CARD_NUMBER);
@@ -501,8 +502,8 @@ void CreditCard::operator=(const CreditCard& credit_card) {
bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card,
const std::string& app_locale) {
- if (this->GetInfo(CREDIT_CARD_NUMBER, app_locale) !=
- imported_card.GetInfo(CREDIT_CARD_NUMBER, app_locale)) {
+ if (this->GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale) !=
+ imported_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale)) {
return false;
}
@@ -533,22 +534,24 @@ void CreditCard::FillFormField(const AutofillField& field,
size_t /*variant*/,
const std::string& app_locale,
FormFieldData* field_data) const {
- DCHECK_EQ(CREDIT_CARD, AutofillType(field.type()).group());
+ DCHECK_EQ(CREDIT_CARD, field.Type().group());
DCHECK(field_data);
if (field_data->form_control_type == "select-one") {
- FillSelectControl(field.type(), app_locale, field_data);
+ FillSelectControl(field.Type(), app_locale, field_data);
} else if (field_data->form_control_type == "month") {
// HTML5 input="month" consists of year-month.
- base::string16 year = GetInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, app_locale);
- base::string16 month = GetInfo(CREDIT_CARD_EXP_MONTH, app_locale);
+ base::string16 year =
+ GetInfo(AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), app_locale);
+ base::string16 month =
+ GetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), app_locale);
if (!year.empty() && !month.empty()) {
// Fill the value only if |this| includes both year and month
// information.
field_data->value = year + ASCIIToUTF16("-") + month;
}
} else {
- field_data->value = GetInfo(field.type(), app_locale);
+ field_data->value = GetInfo(field.Type(), app_locale);
}
}
@@ -556,13 +559,13 @@ int CreditCard::Compare(const CreditCard& credit_card) const {
// The following CreditCard field types are the only types we store in the
// WebDB so far, so we're only concerned with matching these types in the
// credit card.
- const AutofillFieldType types[] = { CREDIT_CARD_NAME,
- CREDIT_CARD_NUMBER,
- CREDIT_CARD_EXP_MONTH,
- CREDIT_CARD_EXP_4_DIGIT_YEAR };
- for (size_t index = 0; index < arraysize(types); ++index) {
- int comparison = GetRawInfo(types[index]).compare(
- credit_card.GetRawInfo(types[index]));
+ const ServerFieldType types[] = { CREDIT_CARD_NAME,
+ CREDIT_CARD_NUMBER,
+ CREDIT_CARD_EXP_MONTH,
+ CREDIT_CARD_EXP_4_DIGIT_YEAR };
+ for (size_t i = 0; i < arraysize(types); ++i) {
+ int comparison =
+ GetRawInfo(types[i]).compare(credit_card.GetRawInfo(types[i]));
if (comparison != 0)
return comparison;
}
@@ -581,7 +584,7 @@ bool CreditCard::operator!=(const CreditCard& credit_card) const {
}
bool CreditCard::IsEmpty(const std::string& app_locale) const {
- FieldTypeSet types;
+ ServerFieldTypeSet types;
GetNonEmptyTypes(app_locale, &types);
return types.empty();
}
@@ -599,7 +602,7 @@ bool CreditCard::IsValid() const {
expiration_year_, expiration_month_, base::Time::Now());
}
-void CreditCard::GetSupportedTypes(FieldTypeSet* supported_types) const {
+void CreditCard::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(CREDIT_CARD_NAME);
supported_types->insert(CREDIT_CARD_NUMBER);
supported_types->insert(CREDIT_CARD_TYPE);
diff --git a/components/autofill/core/browser/credit_card.h b/components/autofill/core/browser/credit_card.h
index cf6384eba2..d5bf1a0f7d 100644
--- a/components/autofill/core/browser/credit_card.h
+++ b/components/autofill/core/browser/credit_card.h
@@ -12,7 +12,6 @@
#include "base/compiler_specific.h"
#include "base/strings/string16.h"
#include "components/autofill/core/browser/autofill_data_model.h"
-#include "components/autofill/core/browser/field_types.h"
namespace autofill {
@@ -47,15 +46,16 @@ class CreditCard : public AutofillDataModel {
static std::string GetCreditCardType(const base::string16& number);
// FormGroup:
- virtual void GetMatchingTypes(const base::string16& text,
- const std::string& app_locale,
- FieldTypeSet* matching_types) const OVERRIDE;
- virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
- virtual void SetRawInfo(AutofillFieldType type,
+ virtual void GetMatchingTypes(
+ const base::string16& text,
+ const std::string& app_locale,
+ ServerFieldTypeSet* matching_types) const OVERRIDE;
+ virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
+ virtual void SetRawInfo(ServerFieldType type,
const base::string16& value) OVERRIDE;
- virtual base::string16 GetInfo(AutofillFieldType type,
+ virtual base::string16 GetInfo(const AutofillType& type,
const std::string& app_locale) const OVERRIDE;
- virtual bool SetInfo(AutofillFieldType type,
+ virtual bool SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) OVERRIDE;
@@ -122,7 +122,8 @@ class CreditCard : public AutofillDataModel {
private:
// FormGroup:
- virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
+ virtual void GetSupportedTypes(
+ ServerFieldTypeSet* supported_types) const OVERRIDE;
// The month and year are zero if not present.
int Expiration4DigitYear() const { return expiration_year_; }
diff --git a/components/autofill/core/browser/credit_card_field.cc b/components/autofill/core/browser/credit_card_field.cc
index 267f7d949a..bba804c958 100644
--- a/components/autofill/core/browser/credit_card_field.cc
+++ b/components/autofill/core/browser/credit_card_field.cc
@@ -193,7 +193,7 @@ CreditCardField::CreditCardField()
is_two_digit_year_(false) {
}
-bool CreditCardField::ClassifyField(FieldTypeMap* map) const {
+bool CreditCardField::ClassifyField(ServerFieldTypeMap* map) const {
bool ok = AddClassification(number_, CREDIT_CARD_NUMBER, map);
ok = ok && AddClassification(type_, CREDIT_CARD_TYPE, map);
ok = ok && AddClassification(verification_, CREDIT_CARD_VERIFICATION_CODE,
diff --git a/components/autofill/core/browser/credit_card_field.h b/components/autofill/core/browser/credit_card_field.h
index 2b5cda3867..119e1ab79d 100644
--- a/components/autofill/core/browser/credit_card_field.h
+++ b/components/autofill/core/browser/credit_card_field.h
@@ -24,7 +24,7 @@ class CreditCardField : public FormField {
protected:
// FormField:
- virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
+ virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE;
private:
FRIEND_TEST_ALL_PREFIXES(CreditCardFieldTest, ParseMiniumCreditCard);
diff --git a/components/autofill/core/browser/credit_card_field_unittest.cc b/components/autofill/core/browser/credit_card_field_unittest.cc
index 46875f2360..9f60a1d6bd 100644
--- a/components/autofill/core/browser/credit_card_field_unittest.cc
+++ b/components/autofill/core/browser/credit_card_field_unittest.cc
@@ -20,7 +20,7 @@ class CreditCardFieldTest : public testing::Test {
protected:
ScopedVector<const AutofillField> list_;
scoped_ptr<CreditCardField> field_;
- FieldTypeMap field_type_map_;
+ ServerFieldTypeMap field_type_map_;
// Downcast for tests.
static CreditCardField* Parse(AutofillScanner* scanner) {
diff --git a/components/autofill/core/browser/credit_card_unittest.cc b/components/autofill/core/browser/credit_card_unittest.cc
index c8b77bf50b..837d729f97 100644
--- a/components/autofill/core/browser/credit_card_unittest.cc
+++ b/components/autofill/core/browser/credit_card_unittest.cc
@@ -6,6 +6,7 @@
#include "base/guid.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_common_test.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/validation.h"
#include "components/autofill/core/common/form_field_data.h"
@@ -327,11 +328,13 @@ TEST(CreditCardTest, SetExpirationMonth) {
EXPECT_EQ(ASCIIToUTF16("07"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(7, card.expiration_month());
- card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("January"), "en-US");
+ card.SetInfo(
+ AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("January"), "en-US");
EXPECT_EQ(ASCIIToUTF16("01"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(1, card.expiration_month());
- card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("Apr"), "en-US");
+ card.SetInfo(
+ AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("Apr"), "en-US");
EXPECT_EQ(ASCIIToUTF16("04"), card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
EXPECT_EQ(4, card.expiration_month());
}
@@ -373,7 +376,8 @@ TEST(CreditCardTest, CreditCardMonthExact) {
CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/");
credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
- credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, "en-US", &field);
+ credit_card.FillSelectControl(
+ AutofillType(CREDIT_CARD_EXP_MONTH), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("01"), field.value);
}
@@ -394,7 +398,8 @@ TEST(CreditCardTest, CreditCardMonthAbbreviated) {
CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/");
credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
- credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, "en-US", &field);
+ credit_card.FillSelectControl(
+ AutofillType(CREDIT_CARD_EXP_MONTH), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("Jan"), field.value);
}
@@ -415,7 +420,8 @@ TEST(CreditCardTest, CreditCardMonthFull) {
CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/");
credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
- credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, "en-US", &field);
+ credit_card.FillSelectControl(
+ AutofillType(CREDIT_CARD_EXP_MONTH), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("January"), field.value);
}
@@ -435,7 +441,8 @@ TEST(CreditCardTest, CreditCardMonthNumeric) {
CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/");
credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
- credit_card.FillSelectControl(CREDIT_CARD_EXP_MONTH, "en-US", &field);
+ credit_card.FillSelectControl(
+ AutofillType(CREDIT_CARD_EXP_MONTH), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("1"), field.value);
}
@@ -455,7 +462,8 @@ TEST(CreditCardTest, CreditCardTwoDigitYear) {
CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/");
credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2017"));
- credit_card.FillSelectControl(CREDIT_CARD_EXP_4_DIGIT_YEAR, "en-US", &field);
+ credit_card.FillSelectControl(
+ AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("17"), field.value);
EXPECT_EQ(2017, credit_card.expiration_year());
}
@@ -483,7 +491,8 @@ TEST(CreditCardTest, CreditCardTypeSelectControl) {
CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/");
credit_card.SetRawInfo(CREDIT_CARD_NUMBER,
ASCIIToUTF16("4111111111111111"));
- credit_card.FillSelectControl(CREDIT_CARD_TYPE, "en-US", &field);
+ credit_card.FillSelectControl(
+ AutofillType(CREDIT_CARD_TYPE), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("Visa"), field.value);
}
@@ -492,7 +501,8 @@ TEST(CreditCardTest, CreditCardTypeSelectControl) {
CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/");
credit_card.SetRawInfo(CREDIT_CARD_NUMBER,
ASCIIToUTF16("5105105105105100"));
- credit_card.FillSelectControl(CREDIT_CARD_TYPE, "en-US", &field);
+ credit_card.FillSelectControl(
+ AutofillType(CREDIT_CARD_TYPE), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("Master Card"), field.value);
}
@@ -500,7 +510,8 @@ TEST(CreditCardTest, CreditCardTypeSelectControl) {
// American Express is sometimes abbreviated as AmEx:
CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/");
credit_card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("371449635398431"));
- credit_card.FillSelectControl(CREDIT_CARD_TYPE, "en-US", &field);
+ credit_card.FillSelectControl(
+ AutofillType(CREDIT_CARD_TYPE), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("AmEx"), field.value);
}
@@ -509,7 +520,8 @@ TEST(CreditCardTest, CreditCardTypeSelectControl) {
CreditCard credit_card(base::GenerateGUID(), "https://www.example.com/");
credit_card.SetRawInfo(CREDIT_CARD_NUMBER,
ASCIIToUTF16("6011111111111117"));
- credit_card.FillSelectControl(CREDIT_CARD_TYPE, "en-US", &field);
+ credit_card.FillSelectControl(
+ AutofillType(CREDIT_CARD_TYPE), "en-US", &field);
EXPECT_EQ(ASCIIToUTF16("discover"), field.value);
}
}
diff --git a/components/autofill/core/browser/email_field.cc b/components/autofill/core/browser/email_field.cc
index 7162c901a5..053ecec3c8 100644
--- a/components/autofill/core/browser/email_field.cc
+++ b/components/autofill/core/browser/email_field.cc
@@ -25,7 +25,7 @@ FormField* EmailField::Parse(AutofillScanner* scanner) {
EmailField::EmailField(const AutofillField* field) : field_(field) {
}
-bool EmailField::ClassifyField(FieldTypeMap* map) const {
+bool EmailField::ClassifyField(ServerFieldTypeMap* map) const {
return AddClassification(field_, EMAIL_ADDRESS, map);
}
diff --git a/components/autofill/core/browser/email_field.h b/components/autofill/core/browser/email_field.h
index b6a08eaabd..4e270a18bc 100644
--- a/components/autofill/core/browser/email_field.h
+++ b/components/autofill/core/browser/email_field.h
@@ -17,7 +17,7 @@ class EmailField : public FormField {
protected:
// FormField:
- virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
+ virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE;
private:
explicit EmailField(const AutofillField* field);
diff --git a/components/autofill/core/browser/field_types.h b/components/autofill/core/browser/field_types.h
index 1e784d566f..c083b39b9c 100644
--- a/components/autofill/core/browser/field_types.h
+++ b/components/autofill/core/browser/field_types.h
@@ -17,8 +17,9 @@ namespace autofill {
// Autofill server, which is itself backward-compatible. The list must be kept
// up to date with the Autofill server list.
//
-// This is the list of all valid field types.
-enum AutofillFieldType {
+// The list of all field types natively understood by the Autofill server. A
+// subset of these types is used to store Autofill data in the user's profile.
+enum ServerFieldType {
// Server indication that it has no data for the requested field.
NO_SERVER_DATA = 0,
// Client indication that the text entered did not match anything in the
@@ -117,8 +118,8 @@ enum FieldTypeGroup {
CREDIT_CARD,
};
-typedef std::set<AutofillFieldType> FieldTypeSet;
-typedef std::map<base::string16, AutofillFieldType> FieldTypeMap;
+typedef std::set<ServerFieldType> ServerFieldTypeSet;
+typedef std::map<base::string16, ServerFieldType> ServerFieldTypeMap;
} // namespace autofill
diff --git a/components/autofill/core/browser/form_field.cc b/components/autofill/core/browser/form_field.cc
index 0bffc05383..2e001127ad 100644
--- a/components/autofill/core/browser/form_field.cc
+++ b/components/autofill/core/browser/form_field.cc
@@ -19,7 +19,6 @@
#include "components/autofill/core/browser/autofill_scanner.h"
#include "components/autofill/core/browser/credit_card_field.h"
#include "components/autofill/core/browser/email_field.h"
-#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/name_field.h"
#include "components/autofill/core/browser/phone_field.h"
@@ -52,7 +51,7 @@ bool IsCheckable(const AutofillField* field) {
// static
void FormField::ParseFormFields(const std::vector<AutofillField*>& fields,
- FieldTypeMap* map) {
+ ServerFieldTypeMap* map) {
// Set up a working copy of the fields to be processed.
std::vector<const AutofillField*> remaining_fields(fields.size());
std::copy(fields.begin(), fields.end(), remaining_fields.begin());
@@ -126,8 +125,8 @@ bool FormField::ParseEmptyLabel(AutofillScanner* scanner,
// static
bool FormField::AddClassification(const AutofillField* field,
- AutofillFieldType type,
- FieldTypeMap* map) {
+ ServerFieldType type,
+ ServerFieldTypeMap* map) {
// Several fields are optional.
if (!field)
return true;
@@ -176,7 +175,7 @@ bool FormField::Match(const AutofillField* field,
// static
void FormField::ParseFormFieldsPass(ParseFunction parse,
std::vector<const AutofillField*>* fields,
- FieldTypeMap* map) {
+ ServerFieldTypeMap* map) {
// Store unmatched fields for further processing by the caller.
std::vector<const AutofillField*> remaining_fields;
diff --git a/components/autofill/core/browser/form_field.h b/components/autofill/core/browser/form_field.h
index 67099b21ed..dbb937f7b6 100644
--- a/components/autofill/core/browser/form_field.h
+++ b/components/autofill/core/browser/form_field.h
@@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/strings/string16.h"
-#include "components/autofill/core/browser/autofill_type.h"
+#include "components/autofill/core/browser/field_types.h"
namespace autofill {
@@ -28,7 +28,7 @@ class FormField {
// The association is stored into |map|. Each field has a derived unique name
// that is used as the key into the |map|.
static void ParseFormFields(const std::vector<AutofillField*>& fields,
- FieldTypeMap* map);
+ ServerFieldTypeMap* map);
protected:
// A bit-field used for matching specific parts of a field in question.
@@ -76,14 +76,14 @@ class FormField {
// Adds an association between a field and a type to |map|.
static bool AddClassification(const AutofillField* field,
- AutofillFieldType type,
- FieldTypeMap* map);
+ ServerFieldType type,
+ ServerFieldTypeMap* map);
// Derived classes must implement this interface to supply field type
// information. |ParseFormFields| coordinates the parsing and extraction
// of types from an input vector of |AutofillField| objects and delegates
// the type extraction via this method.
- virtual bool ClassifyField(FieldTypeMap* map) const = 0;
+ virtual bool ClassifyField(ServerFieldTypeMap* map) const = 0;
private:
FRIEND_TEST_ALL_PREFIXES(FormFieldTest, Match);
@@ -114,7 +114,7 @@ class FormField {
// Classification results of the processed fields are stored in |map|.
static void ParseFormFieldsPass(ParseFunction parse,
std::vector<const AutofillField*>* fields,
- FieldTypeMap* map);
+ ServerFieldTypeMap* map);
DISALLOW_COPY_AND_ASSIGN(FormField);
};
diff --git a/components/autofill/core/browser/form_field_unittest.cc b/components/autofill/core/browser/form_field_unittest.cc
index 9a535bb2a4..5014b71364 100644
--- a/components/autofill/core/browser/form_field_unittest.cc
+++ b/components/autofill/core/browser/form_field_unittest.cc
@@ -138,7 +138,7 @@ TEST(FormFieldTest, ParseFormFields) {
field_data.label = ASCIIToUTF16("Address line2");
fields.push_back(new AutofillField(field_data, field_data.label));
- FieldTypeMap field_type_map;
+ ServerFieldTypeMap field_type_map;
FormField::ParseFormFields(fields.get(), &field_type_map);
// Checkable element shouldn't interfere with inference of Address line2.
EXPECT_EQ(2U, field_type_map.size());
diff --git a/components/autofill/core/browser/form_group.cc b/components/autofill/core/browser/form_group.cc
index 052d2b7cfa..7114ee2980 100644
--- a/components/autofill/core/browser/form_group.cc
+++ b/components/autofill/core/browser/form_group.cc
@@ -4,48 +4,47 @@
#include "components/autofill/core/browser/form_group.h"
+#include "components/autofill/core/browser/autofill_type.h"
+
namespace autofill {
void FormGroup::GetMatchingTypes(const base::string16& text,
const std::string& app_locale,
- FieldTypeSet* matching_types) const {
+ ServerFieldTypeSet* matching_types) const {
if (text.empty()) {
matching_types->insert(EMPTY_TYPE);
return;
}
- FieldTypeSet types;
+ ServerFieldTypeSet types;
GetSupportedTypes(&types);
- for (FieldTypeSet::const_iterator type = types.begin();
+ for (ServerFieldTypeSet::const_iterator type = types.begin();
type != types.end(); ++type) {
- // TODO(isherman): Matches are case-sensitive for now. Let's keep an eye on
- // this and decide whether there are compelling reasons to add case-
- // insensitivity.
- if (GetInfo(*type, app_locale) == text)
+ if (GetInfo(AutofillType(*type), app_locale) == text)
matching_types->insert(*type);
}
}
void FormGroup::GetNonEmptyTypes(const std::string& app_locale,
- FieldTypeSet* non_empty_types) const {
- FieldTypeSet types;
+ ServerFieldTypeSet* non_empty_types) const {
+ ServerFieldTypeSet types;
GetSupportedTypes(&types);
- for (FieldTypeSet::const_iterator type = types.begin();
+ for (ServerFieldTypeSet::const_iterator type = types.begin();
type != types.end(); ++type) {
- if (!GetInfo(*type, app_locale).empty())
+ if (!GetInfo(AutofillType(*type), app_locale).empty())
non_empty_types->insert(*type);
}
}
-base::string16 FormGroup::GetInfo(AutofillFieldType type,
- const std::string& app_locale) const {
- return GetRawInfo(type);
+base::string16 FormGroup::GetInfo(const AutofillType& type,
+ const std::string& app_locale) const {
+ return GetRawInfo(type.server_type());
}
-bool FormGroup::SetInfo(AutofillFieldType type,
+bool FormGroup::SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) {
- SetRawInfo(type, value);
+ SetRawInfo(type.server_type(), value);
return true;
}
diff --git a/components/autofill/core/browser/form_group.h b/components/autofill/core/browser/form_group.h
index 714112cb22..86bd4531bb 100644
--- a/components/autofill/core/browser/form_group.h
+++ b/components/autofill/core/browser/form_group.h
@@ -12,6 +12,8 @@
namespace autofill {
+class AutofillType;
+
// This class is an interface for collections of form fields, grouped by type.
class FormGroup {
public:
@@ -23,31 +25,31 @@ class FormGroup {
// additive on |matching_types|.
virtual void GetMatchingTypes(const base::string16& text,
const std::string& app_locale,
- FieldTypeSet* matching_types) const;
+ ServerFieldTypeSet* matching_types) const;
- // Returns a set of AutofillFieldTypes for which this FormGroup has non-empty
+ // Returns a set of server field types for which this FormGroup has non-empty
// data. This method is additive on |non_empty_types|.
virtual void GetNonEmptyTypes(const std::string& app_locale,
- FieldTypeSet* non_empty_types) const;
+ ServerFieldTypeSet* non_empty_types) const;
// Returns the string associated with |type|, without canonicalizing the
// returned value. For user-visible strings, use GetInfo() instead.
- virtual base::string16 GetRawInfo(AutofillFieldType type) const = 0;
+ virtual base::string16 GetRawInfo(ServerFieldType type) const = 0;
// Sets this FormGroup object's data for |type| to |value|, without
// canonicalizing the |value|. For data that has not already been
// canonicalized, use SetInfo() instead.
- virtual void SetRawInfo(AutofillFieldType type,
+ virtual void SetRawInfo(ServerFieldType type,
const base::string16& value) = 0;
// Returns the string that should be auto-filled into a text field given the
// type of that field, localized to the given |app_locale| if appropriate.
- virtual base::string16 GetInfo(AutofillFieldType type,
+ virtual base::string16 GetInfo(const AutofillType& type,
const std::string& app_locale) const;
// Used to populate this FormGroup object with data. Canonicalizes the data
// according to the specified |app_locale| prior to storing, if appropriate.
- virtual bool SetInfo(AutofillFieldType type,
+ virtual bool SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale);
@@ -56,9 +58,9 @@ class FormGroup {
// non-AutofillProfile type, for which mere inheritance is insufficient.
friend class AutofillProfile;
- // Returns a set of AutofillFieldTypes for which this FormGroup can store
+ // Returns a set of server field types for which this FormGroup can store
// data. This method is additive on |supported_types|.
- virtual void GetSupportedTypes(FieldTypeSet* supported_types) const = 0;
+ virtual void GetSupportedTypes(ServerFieldTypeSet* supported_types) const = 0;
};
} // namespace autofill
diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc
index 3c49b4509a..d502a0dee7 100644
--- a/components/autofill/core/browser/form_structure.cc
+++ b/components/autofill/core/browser/form_structure.cc
@@ -65,14 +65,15 @@ const char kIgnorePatternInFieldName[] = "\\d{5,}+";
// Helper for |EncodeUploadRequest()| that creates a bit field corresponding to
// |available_field_types| and returns the hex representation as a string.
-std::string EncodeFieldTypes(const FieldTypeSet& available_field_types) {
+std::string EncodeFieldTypes(const ServerFieldTypeSet& available_field_types) {
// There are |MAX_VALID_FIELD_TYPE| different field types and 8 bits per byte,
// so we need ceil(MAX_VALID_FIELD_TYPE / 8) bytes to encode the bit field.
const size_t kNumBytes = (MAX_VALID_FIELD_TYPE + 0x7) / 8;
// Pack the types in |available_field_types| into |bit_field|.
std::vector<uint8> bit_field(kNumBytes, 0);
- for (FieldTypeSet::const_iterator field_type = available_field_types.begin();
+ for (ServerFieldTypeSet::const_iterator field_type =
+ available_field_types.begin();
field_type != available_field_types.end();
++field_type) {
// Set the appropriate bit in the field. The bit we set is the one
@@ -107,9 +108,9 @@ void EncodeFieldForUpload(const AutofillField& field,
if (field.is_checkable)
return;
- FieldTypeSet types = field.possible_types();
+ ServerFieldTypeSet types = field.possible_types();
// |types| could be empty in unit-tests only.
- for (FieldTypeSet::iterator field_type = types.begin();
+ for (ServerFieldTypeSet::iterator field_type = types.begin();
field_type != types.end(); ++field_type) {
buzz::XmlElement *field_element = new buzz::XmlElement(
buzz::QName(kXMLElementField));
@@ -137,8 +138,8 @@ void EncodeFieldForQuery(const AutofillField& field,
// in field assignments xml, and also add them to the parent XmlElement.
void EncodeFieldForFieldAssignments(const AutofillField& field,
buzz::XmlElement* parent) {
- FieldTypeSet types = field.possible_types();
- for (FieldTypeSet::iterator field_type = types.begin();
+ ServerFieldTypeSet types = field.possible_types();
+ for (ServerFieldTypeSet::iterator field_type = types.begin();
field_type != types.end(); ++field_type) {
buzz::XmlElement *field_element = new buzz::XmlElement(
buzz::QName(kXMLElementFields));
@@ -164,8 +165,9 @@ bool IsContactTypeHint(const std::string& token) {
// Returns |true| iff the |token| is a type hint appropriate for a field of the
// given |field_type|, as specified in the implementation section of
// http://is.gd/whatwg_autocomplete
+// TODO(isherman): This should use HTML field types, not native ones.
bool ContactTypeHintMatchesFieldType(const std::string& token,
- AutofillFieldType field_type) {
+ ServerFieldType field_type) {
// The "home" and "work" type hints are only appropriate for email and phone
// number field types.
if (token == "home" || token == "work") {
@@ -189,7 +191,8 @@ bool ContactTypeHintMatchesFieldType(const std::string& token,
// |autocomplete_type|, if there is one, in the context of the given |field|.
// Chrome Autofill supports a subset of the field types listed at
// http://is.gd/whatwg_autocomplete
-AutofillFieldType FieldTypeFromAutocompleteType(
+// TODO(isherman): This should use HTML field types, not native ones.
+ServerFieldType FieldTypeFromAutocompleteType(
const std::string& autocomplete_type,
const AutofillField& field) {
if (autocomplete_type == "name")
@@ -379,11 +382,12 @@ void FormStructure::DetermineHeuristicTypes(
&has_author_specified_sections);
if (!has_author_specified_types_) {
- FieldTypeMap field_type_map;
+ ServerFieldTypeMap field_type_map;
FormField::ParseFormFields(fields_.get(), &field_type_map);
- for (size_t index = 0; index < field_count(); index++) {
- AutofillField* field = fields_[index];
- FieldTypeMap::iterator iter = field_type_map.find(field->unique_name());
+ for (size_t i = 0; i < field_count(); ++i) {
+ AutofillField* field = fields_[i];
+ ServerFieldTypeMap::iterator iter =
+ field_type_map.find(field->unique_name());
if (iter != field_type_map.end())
field->set_heuristic_type(iter->second);
}
@@ -403,7 +407,7 @@ void FormStructure::DetermineHeuristicTypes(
}
bool FormStructure::EncodeUploadRequest(
- const FieldTypeSet& available_field_types,
+ const ServerFieldTypeSet& available_field_types,
bool form_was_autofilled,
std::string* encoded_xml) const {
DCHECK(ShouldBeCrowdsourced());
@@ -413,7 +417,8 @@ bool FormStructure::EncodeUploadRequest(
for (std::vector<AutofillField*>::const_iterator field = begin();
field != end();
++field) {
- for (FieldTypeSet::const_iterator type = (*field)->possible_types().begin();
+ for (ServerFieldTypeSet::const_iterator type =
+ (*field)->possible_types().begin();
type != (*field)->possible_types().end();
++type) {
DCHECK(*type == UNKNOWN_TYPE ||
@@ -448,7 +453,7 @@ bool FormStructure::EncodeUploadRequest(
}
bool FormStructure::EncodeFieldAssignments(
- const FieldTypeSet& available_field_types,
+ const ServerFieldTypeSet& available_field_types,
std::string* encoded_xml) const {
DCHECK(ShouldBeCrowdsourced());
@@ -597,12 +602,12 @@ void FormStructure::ParseQueryResponse(
// UNKNOWN_TYPE is reserved for use by the client.
DCHECK_NE(current_info->field_type, UNKNOWN_TYPE);
- AutofillFieldType heuristic_type = (*field)->type();
+ ServerFieldType heuristic_type = (*field)->heuristic_type();
if (heuristic_type != UNKNOWN_TYPE)
heuristics_detected_fillable_field = true;
(*field)->set_server_type(current_info->field_type);
- if (heuristic_type != (*field)->type())
+ if (heuristic_type != (*field)->Type().server_type())
query_response_overrode_heuristics = true;
// Copy default value into the field if available.
@@ -658,7 +663,7 @@ void FormStructure::GetFieldTypePredictions(
annotated_field.server_type =
AutofillType::FieldTypeToString((*field)->server_type());
annotated_field.overall_type =
- AutofillType::FieldTypeToString((*field)->type());
+ AutofillType::FieldTypeToString((*field)->Type().server_type());
form.fields.push_back(annotated_field);
}
@@ -806,7 +811,7 @@ void FormStructure::LogQualityMetrics(
// No further logging for empty fields nor for fields where the entered data
// does not appear to already exist in the user's stored Autofill data.
- const FieldTypeSet& field_types = field->possible_types();
+ const ServerFieldTypeSet& field_types = field->possible_types();
DCHECK(!field_types.empty());
if (field_types.count(EMPTY_TYPE) || field_types.count(UNKNOWN_TYPE))
continue;
@@ -819,8 +824,8 @@ void FormStructure::LogQualityMetrics(
// Collapse field types that Chrome treats as identical, e.g. home and
// billing address fields.
- FieldTypeSet collapsed_field_types;
- for (FieldTypeSet::const_iterator it = field_types.begin();
+ ServerFieldTypeSet collapsed_field_types;
+ for (ServerFieldTypeSet::const_iterator it = field_types.begin();
it != field_types.end();
++it) {
// Since we currently only support US phone numbers, the (city code + main
@@ -834,13 +839,13 @@ void FormStructure::LogQualityMetrics(
}
// Capture the field's type, if it is unambiguous.
- AutofillFieldType field_type = UNKNOWN_TYPE;
+ ServerFieldType field_type = UNKNOWN_TYPE;
if (collapsed_field_types.size() == 1)
field_type = *collapsed_field_types.begin();
- AutofillFieldType heuristic_type = field->heuristic_type();
- AutofillFieldType server_type = field->server_type();
- AutofillFieldType predicted_type = field->type();
+ ServerFieldType heuristic_type = field->heuristic_type();
+ ServerFieldType server_type = field->server_type();
+ ServerFieldType predicted_type = field->Type().server_type();
// Log heuristic, server, and overall type quality metrics, independently of
// whether the field was autofilled.
@@ -1127,7 +1132,7 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes(
DCHECK(!tokens.empty());
std::string field_type_token = tokens.back();
tokens.pop_back();
- AutofillFieldType field_type =
+ ServerFieldType field_type =
FieldTypeFromAutocompleteType(field_type_token, *field);
if (field_type == UNKNOWN_TYPE)
continue;
@@ -1205,13 +1210,13 @@ void FormStructure::IdentifySections(bool has_author_specified_sections) {
base::string16 current_section = fields_.front()->unique_name();
// Keep track of the types we've seen in this section.
- std::set<AutofillFieldType> seen_types;
- AutofillFieldType previous_type = UNKNOWN_TYPE;
+ std::set<ServerFieldType> seen_types;
+ ServerFieldType previous_type = UNKNOWN_TYPE;
for (std::vector<AutofillField*>::iterator field = fields_.begin();
field != fields_.end(); ++field) {
- const AutofillFieldType current_type =
- AutofillType::GetEquivalentFieldType((*field)->type());
+ const ServerFieldType current_type =
+ AutofillType::GetEquivalentFieldType((*field)->Type().server_type());
bool already_saw_current_type = seen_types.count(current_type) > 0;
@@ -1250,7 +1255,7 @@ void FormStructure::IdentifySections(bool has_author_specified_sections) {
// This simplifies the section-aware logic in autofill_manager.cc.
for (std::vector<AutofillField*>::iterator field = fields_.begin();
field != fields_.end(); ++field) {
- FieldTypeGroup field_type_group = AutofillType((*field)->type()).group();
+ FieldTypeGroup field_type_group = (*field)->Type().group();
if (field_type_group == CREDIT_CARD)
(*field)->set_section((*field)->section() + "-cc");
else
diff --git a/components/autofill/core/browser/form_structure.h b/components/autofill/core/browser/form_structure.h
index bfb2c5bb2b..8b914b1654 100644
--- a/components/autofill/core/browser/form_structure.h
+++ b/components/autofill/core/browser/form_structure.h
@@ -64,7 +64,7 @@ class FormStructure {
void DetermineHeuristicTypes(const AutofillMetrics& metric_logger);
// Encodes the XML upload request from this FormStructure.
- bool EncodeUploadRequest(const FieldTypeSet& available_field_types,
+ bool EncodeUploadRequest(const ServerFieldTypeSet& available_field_types,
bool form_was_autofilled,
std::string* encoded_xml) const;
@@ -72,7 +72,7 @@ class FormStructure {
// This XML will be written VLOG only, never be sent to server. It will
// help make FieldAssignments and feed back to autofill server as
// experiment data.
- bool EncodeFieldAssignments(const FieldTypeSet& available_field_types,
+ bool EncodeFieldAssignments(const ServerFieldTypeSet& available_field_types,
std::string* encoded_xml) const;
// Encodes the XML query request for the set of forms.
diff --git a/components/autofill/core/browser/form_structure_unittest.cc b/components/autofill/core/browser/form_structure_unittest.cc
index d494fbe173..73343f822f 100644
--- a/components/autofill/core/browser/form_structure_unittest.cc
+++ b/components/autofill/core/browser/form_structure_unittest.cc
@@ -1667,7 +1667,7 @@ TEST(FormStructureTest, EncodeQueryRequest) {
TEST(FormStructureTest, EncodeUploadRequest) {
scoped_ptr<FormStructure> form_structure;
- std::vector<FieldTypeSet> possible_field_types;
+ std::vector<ServerFieldTypeSet> possible_field_types;
FormData form;
form.method = ASCIIToUTF16("post");
form_structure.reset(new FormStructure(form, std::string()));
@@ -1679,34 +1679,34 @@ TEST(FormStructureTest, EncodeUploadRequest) {
field.label = ASCIIToUTF16("First Name");
field.name = ASCIIToUTF16("firstname");
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(NAME_FIRST);
field.label = ASCIIToUTF16("Last Name");
field.name = ASCIIToUTF16("lastname");
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(NAME_LAST);
field.label = ASCIIToUTF16("Email");
field.name = ASCIIToUTF16("email");
field.form_control_type = "email";
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(EMAIL_ADDRESS);
field.label = ASCIIToUTF16("Phone");
field.name = ASCIIToUTF16("phone");
field.form_control_type = "number";
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(PHONE_HOME_WHOLE_NUMBER);
field.label = ASCIIToUTF16("Country");
field.name = ASCIIToUTF16("country");
field.form_control_type = "select-one";
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_COUNTRY);
// Add checkable field.
@@ -1715,7 +1715,7 @@ TEST(FormStructureTest, EncodeUploadRequest) {
checkable_field.label = ASCIIToUTF16("Checkable1");
checkable_field.name = ASCIIToUTF16("Checkable1");
form.fields.push_back(checkable_field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_COUNTRY);
form_structure.reset(new FormStructure(form, std::string()));
@@ -1724,7 +1724,7 @@ TEST(FormStructureTest, EncodeUploadRequest) {
for (size_t i = 0; i < form_structure->field_count(); ++i)
form_structure->field(i)->set_possible_types(possible_field_types[i]);
- FieldTypeSet available_field_types;
+ ServerFieldTypeSet available_field_types;
available_field_types.insert(NAME_FIRST);
available_field_types.insert(NAME_LAST);
available_field_types.insert(ADDRESS_HOME_LINE1);
@@ -1769,7 +1769,7 @@ TEST(FormStructureTest, EncodeUploadRequest) {
field.name = ASCIIToUTF16("address");
field.form_control_type = "text";
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_LINE1);
possible_field_types.back().insert(ADDRESS_HOME_LINE2);
possible_field_types.back().insert(ADDRESS_BILLING_LINE1);
@@ -1809,7 +1809,7 @@ TEST(FormStructureTest, EncodeUploadRequest) {
field.name = ASCIIToUTF16("address");
field.form_control_type = "text";
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_LINE1);
possible_field_types.back().insert(ADDRESS_HOME_LINE2);
possible_field_types.back().insert(ADDRESS_BILLING_LINE1);
@@ -1825,7 +1825,7 @@ TEST(FormStructureTest, EncodeUploadRequest) {
TEST(FormStructureTest, EncodeFieldAssignments) {
scoped_ptr<FormStructure> form_structure;
- std::vector<FieldTypeSet> possible_field_types;
+ std::vector<ServerFieldTypeSet> possible_field_types;
FormData form;
form.method = ASCIIToUTF16("post");
form_structure.reset(new FormStructure(form, std::string()));
@@ -1837,34 +1837,34 @@ TEST(FormStructureTest, EncodeFieldAssignments) {
field.label = ASCIIToUTF16("First Name");
field.name = ASCIIToUTF16("firstname");
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(NAME_FIRST);
field.label = ASCIIToUTF16("Last Name");
field.name = ASCIIToUTF16("lastname");
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(NAME_LAST);
field.label = ASCIIToUTF16("Email");
field.name = ASCIIToUTF16("email");
field.form_control_type = "email";
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(EMAIL_ADDRESS);
field.label = ASCIIToUTF16("Phone");
field.name = ASCIIToUTF16("phone");
field.form_control_type = "number";
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(PHONE_HOME_WHOLE_NUMBER);
field.label = ASCIIToUTF16("Country");
field.name = ASCIIToUTF16("country");
field.form_control_type = "select-one";
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_COUNTRY);
// Add checkable field.
@@ -1873,7 +1873,7 @@ TEST(FormStructureTest, EncodeFieldAssignments) {
checkable_field.label = ASCIIToUTF16("Checkable1");
checkable_field.name = ASCIIToUTF16("Checkable1");
form.fields.push_back(checkable_field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_COUNTRY);
form_structure.reset(new FormStructure(form, std::string()));
@@ -1882,7 +1882,7 @@ TEST(FormStructureTest, EncodeFieldAssignments) {
for (size_t i = 0; i < form_structure->field_count(); ++i)
form_structure->field(i)->set_possible_types(possible_field_types[i]);
- FieldTypeSet available_field_types;
+ ServerFieldTypeSet available_field_types;
available_field_types.insert(NAME_FIRST);
available_field_types.insert(NAME_LAST);
available_field_types.insert(ADDRESS_HOME_LINE1);
@@ -1914,7 +1914,7 @@ TEST(FormStructureTest, EncodeFieldAssignments) {
field.name = ASCIIToUTF16("address");
field.form_control_type = "text";
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_LINE1);
possible_field_types.back().insert(ADDRESS_HOME_LINE2);
possible_field_types.back().insert(ADDRESS_BILLING_LINE1);
@@ -1972,7 +1972,7 @@ TEST(FormStructureTest, CheckDataPresence) {
FormStructure form_structure(form, std::string());
- FieldTypeSet unknown_type;
+ ServerFieldTypeSet unknown_type;
unknown_type.insert(UNKNOWN_TYPE);
for (size_t i = 0; i < form_structure.field_count(); ++i)
form_structure.field(i)->set_possible_types(unknown_type);
@@ -1980,7 +1980,7 @@ TEST(FormStructureTest, CheckDataPresence) {
// No available types.
// datapresent should be "" == trimmmed(0x0000000000000000) ==
// 0b0000000000000000000000000000000000000000000000000000000000000000
- FieldTypeSet available_field_types;
+ ServerFieldTypeSet available_field_types;
std::string encoded_xml;
EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false,
@@ -2193,7 +2193,7 @@ TEST(FormStructureTest, CheckMultipleTypes) {
// 33 == ADDRESS_HOME_CITY
// 34 == ADDRESS_HOME_STATE
// 60 == COMPANY_NAME
- FieldTypeSet available_field_types;
+ ServerFieldTypeSet available_field_types;
available_field_types.insert(NAME_FIRST);
available_field_types.insert(NAME_LAST);
available_field_types.insert(EMAIL_ADDRESS);
@@ -2205,7 +2205,7 @@ TEST(FormStructureTest, CheckMultipleTypes) {
// Check that multiple types for the field are processed correctly.
scoped_ptr<FormStructure> form_structure;
- std::vector<FieldTypeSet> possible_field_types;
+ std::vector<ServerFieldTypeSet> possible_field_types;
FormData form;
form.method = ASCIIToUTF16("post");
@@ -2215,25 +2215,25 @@ TEST(FormStructureTest, CheckMultipleTypes) {
field.label = ASCIIToUTF16("email");
field.name = ASCIIToUTF16("email");
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(EMAIL_ADDRESS);
field.label = ASCIIToUTF16("First Name");
field.name = ASCIIToUTF16("first");
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(NAME_FIRST);
field.label = ASCIIToUTF16("Last Name");
field.name = ASCIIToUTF16("last");
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(NAME_LAST);
field.label = ASCIIToUTF16("Address");
field.name = ASCIIToUTF16("address");
form.fields.push_back(field);
- possible_field_types.push_back(FieldTypeSet());
+ possible_field_types.push_back(ServerFieldTypeSet());
possible_field_types.back().insert(ADDRESS_HOME_LINE1);
form_structure.reset(new FormStructure(form, std::string()));
diff --git a/components/autofill/core/browser/name_field.cc b/components/autofill/core/browser/name_field.cc
index 435537ea37..de74ba1a2d 100644
--- a/components/autofill/core/browser/name_field.cc
+++ b/components/autofill/core/browser/name_field.cc
@@ -23,7 +23,7 @@ class FullNameField : public NameField {
protected:
// FormField:
- virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
+ virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE;
private:
explicit FullNameField(const AutofillField* field);
@@ -42,7 +42,7 @@ class FirstLastNameField : public NameField {
protected:
// FormField:
- virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
+ virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE;
private:
FirstLastNameField();
@@ -69,7 +69,7 @@ FormField* NameField::Parse(AutofillScanner* scanner) {
}
// This is overriden in concrete subclasses.
-bool NameField::ClassifyField(FieldTypeMap* map) const {
+bool NameField::ClassifyField(ServerFieldTypeMap* map) const {
return false;
}
@@ -92,7 +92,7 @@ FullNameField* FullNameField::Parse(AutofillScanner* scanner) {
return NULL;
}
-bool FullNameField::ClassifyField(FieldTypeMap* map) const {
+bool FullNameField::ClassifyField(ServerFieldTypeMap* map) const {
return AddClassification(field_, NAME_FULL, map);
}
@@ -206,10 +206,10 @@ FirstLastNameField::FirstLastNameField()
middle_initial_(false) {
}
-bool FirstLastNameField::ClassifyField(FieldTypeMap* map) const {
+bool FirstLastNameField::ClassifyField(ServerFieldTypeMap* map) const {
bool ok = AddClassification(first_name_, NAME_FIRST, map);
ok = ok && AddClassification(last_name_, NAME_LAST, map);
- AutofillFieldType type = middle_initial_ ? NAME_MIDDLE_INITIAL : NAME_MIDDLE;
+ ServerFieldType type = middle_initial_ ? NAME_MIDDLE_INITIAL : NAME_MIDDLE;
ok = ok && AddClassification(middle_name_, type, map);
return ok;
}
diff --git a/components/autofill/core/browser/name_field.h b/components/autofill/core/browser/name_field.h
index ada8a30185..e15e7e3d5f 100644
--- a/components/autofill/core/browser/name_field.h
+++ b/components/autofill/core/browser/name_field.h
@@ -25,7 +25,7 @@ class NameField : public FormField {
NameField() {}
// FormField:
- virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
+ virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE;
private:
FRIEND_TEST_ALL_PREFIXES(NameFieldTest, FirstMiddleLast);
diff --git a/components/autofill/core/browser/name_field_unittest.cc b/components/autofill/core/browser/name_field_unittest.cc
index 0abe6317f9..df6a29bf70 100644
--- a/components/autofill/core/browser/name_field_unittest.cc
+++ b/components/autofill/core/browser/name_field_unittest.cc
@@ -20,7 +20,7 @@ class NameFieldTest : public testing::Test {
protected:
ScopedVector<const AutofillField> list_;
scoped_ptr<NameField> field_;
- FieldTypeMap field_type_map_;
+ ServerFieldTypeMap field_type_map_;
// Downcast for tests.
static NameField* Parse(AutofillScanner* scanner) {
diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc
index d7fb2919b5..c14723d714 100644
--- a/components/autofill/core/browser/personal_data_manager.cc
+++ b/components/autofill/core/browser/personal_data_manager.cc
@@ -109,21 +109,22 @@ bool IsMinimumAddress(const AutofillProfile& profile,
// Return true if the |field_type| and |value| are valid within the context
// of importing a form.
-bool IsValidFieldTypeAndValue(const std::set<AutofillFieldType>& types_seen,
- AutofillFieldType field_type,
+bool IsValidFieldTypeAndValue(const std::set<ServerFieldType>& types_seen,
+ ServerFieldType field_type,
const base::string16& value) {
// Abandon the import if two fields of the same type are encountered.
// This indicates ambiguous data or miscategorization of types.
// Make an exception for PHONE_HOME_NUMBER however as both prefix and
// suffix are stored against this type, and for EMAIL_ADDRESS because it is
// common to see second 'confirm email address' fields on forms.
- if (types_seen.count(field_type) && field_type != PHONE_HOME_NUMBER &&
+ if (types_seen.count(field_type) &&
+ field_type != PHONE_HOME_NUMBER &&
field_type != EMAIL_ADDRESS)
return false;
// Abandon the import if an email address value shows up in a field that is
// not an email address.
- if (field_type != EMAIL_ADDRESS && autofill::IsValidEmailAddress(value))
+ if (field_type != EMAIL_ADDRESS && IsValidEmailAddress(value))
return false;
return true;
@@ -240,7 +241,9 @@ bool PersonalDataManager::ImportFormData(
int importable_credit_card_fields = 0;
// Detect and discard forms with multiple fields of the same type.
- std::set<AutofillFieldType> types_seen;
+ // TODO(isherman): Some types are overlapping but not equal, e.g. phone number
+ // parts, address parts.
+ std::set<ServerFieldType> types_seen;
// We only set complete phone, so aggregate phone parts in these vars and set
// complete at the end.
@@ -255,15 +258,16 @@ bool PersonalDataManager::ImportFormData(
if (!field->IsFieldFillable() || value.empty())
continue;
- AutofillFieldType field_type = field->type();
- FieldTypeGroup group(AutofillType(field_type).group());
+ AutofillType field_type = field->Type();
+ ServerFieldType server_field_type = field_type.server_type();
+ FieldTypeGroup group(field_type.group());
// There can be multiple email fields (e.g. in the case of 'confirm email'
// fields) but they must all contain the same value, else the profile is
// invalid.
- if (field_type == EMAIL_ADDRESS) {
- if (types_seen.count(field_type) &&
- imported_profile->GetRawInfo(field_type) != value) {
+ if (server_field_type == EMAIL_ADDRESS) {
+ if (types_seen.count(server_field_type) &&
+ imported_profile->GetRawInfo(EMAIL_ADDRESS) != value) {
imported_profile.reset();
break;
}
@@ -271,17 +275,17 @@ bool PersonalDataManager::ImportFormData(
// If the |field_type| and |value| don't pass basic validity checks then
// abandon the import.
- if (!IsValidFieldTypeAndValue(types_seen, field_type, value)) {
+ if (!IsValidFieldTypeAndValue(types_seen, server_field_type, value)) {
imported_profile.reset();
local_imported_credit_card.reset();
break;
}
- types_seen.insert(field_type);
+ types_seen.insert(server_field_type);
if (group == CREDIT_CARD) {
if (LowerCaseEqualsASCII(field->form_control_type, "month")) {
- DCHECK_EQ(CREDIT_CARD_EXP_MONTH, field_type);
+ DCHECK_EQ(CREDIT_CARD_EXP_MONTH, server_field_type);
local_imported_credit_card->SetInfoForMonthInputType(value);
} else {
local_imported_credit_card->SetInfo(field_type, value, app_locale_);
@@ -296,7 +300,7 @@ bool PersonalDataManager::ImportFormData(
imported_profile->SetInfo(field_type, value, app_locale_);
// Reject profiles with invalid country information.
- if (field_type == ADDRESS_HOME_COUNTRY &&
+ if (server_field_type == ADDRESS_HOME_COUNTRY &&
!value.empty() &&
imported_profile->GetRawInfo(ADDRESS_HOME_COUNTRY).empty()) {
imported_profile.reset();
@@ -310,7 +314,8 @@ bool PersonalDataManager::ImportFormData(
base::string16 constructed_number;
if (!home.ParseNumber(*imported_profile, app_locale_,
&constructed_number) ||
- !imported_profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, constructed_number,
+ !imported_profile->SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
+ constructed_number,
app_locale_)) {
imported_profile.reset();
}
@@ -521,7 +526,7 @@ CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) {
}
void PersonalDataManager::GetNonEmptyTypes(
- FieldTypeSet* non_empty_types) {
+ ServerFieldTypeSet* non_empty_types) {
const std::vector<AutofillProfile*>& profiles = GetProfiles();
for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin();
iter != profiles.end(); ++iter) {
@@ -569,10 +574,10 @@ void PersonalDataManager::Refresh() {
}
void PersonalDataManager::GetProfileSuggestions(
- AutofillFieldType type,
+ const AutofillType& type,
const base::string16& field_contents,
bool field_is_autofilled,
- std::vector<AutofillFieldType> other_field_types,
+ std::vector<ServerFieldType> other_field_types,
std::vector<base::string16>* values,
std::vector<base::string16>* labels,
std::vector<base::string16>* icons,
@@ -612,9 +617,11 @@ void PersonalDataManager::GetProfileSuggestions(
// Phone numbers could be split in US forms, so field value could be
// either prefix or suffix of the phone.
bool matched_phones = false;
- if (type == PHONE_HOME_NUMBER && !field_value_lower_case.empty() &&
- (profile_value_lower_case.find(field_value_lower_case) !=
- base::string16::npos)) {
+ if ((type.server_type() == PHONE_HOME_NUMBER ||
+ type.server_type() == PHONE_BILLING_NUMBER) &&
+ !field_value_lower_case.empty() &&
+ profile_value_lower_case.find(field_value_lower_case) !=
+ base::string16::npos) {
matched_phones = true;
}
@@ -639,7 +646,7 @@ void PersonalDataManager::GetProfileSuggestions(
if (!field_is_autofilled) {
AutofillProfile::CreateInferredLabels(
&matched_profiles, &other_field_types,
- type, 1, labels);
+ type.server_type(), 1, labels);
} else {
// No sub-labels for previously filled fields.
labels->resize(values->size());
@@ -650,7 +657,7 @@ void PersonalDataManager::GetProfileSuggestions(
}
void PersonalDataManager::GetCreditCardSuggestions(
- AutofillFieldType type,
+ const AutofillType& type,
const base::string16& field_contents,
std::vector<base::string16>* values,
std::vector<base::string16>* labels,
@@ -671,13 +678,14 @@ void PersonalDataManager::GetCreditCardSuggestions(
credit_card->GetInfo(type, app_locale_);
if (!creditcard_field_value.empty() &&
StartsWith(creditcard_field_value, field_contents, false)) {
- if (type == CREDIT_CARD_NUMBER)
+ if (type.server_type() == CREDIT_CARD_NUMBER)
creditcard_field_value = credit_card->ObfuscatedNumber();
base::string16 label;
if (credit_card->number().empty()) {
// If there is no CC number, return name to show something.
- label = credit_card->GetInfo(CREDIT_CARD_NAME, app_locale_);
+ label =
+ credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_);
} else {
label = kCreditCardPrefix;
label.append(credit_card->LastFourDigits());
@@ -704,7 +712,7 @@ bool PersonalDataManager::IsValidLearnableProfile(
return false;
base::string16 email = profile.GetRawInfo(EMAIL_ADDRESS);
- if (!email.empty() && !autofill::IsValidEmailAddress(email))
+ if (!email.empty() && !IsValidEmailAddress(email))
return false;
// Reject profiles with invalid US state information.
diff --git a/components/autofill/core/browser/personal_data_manager.h b/components/autofill/core/browser/personal_data_manager.h
index 36e578f7cc..b9ab979fdf 100644
--- a/components/autofill/core/browser/personal_data_manager.h
+++ b/components/autofill/core/browser/personal_data_manager.h
@@ -109,7 +109,7 @@ class PersonalDataManager : public WebDataServiceConsumer,
CreditCard* GetCreditCardByGUID(const std::string& guid);
// Gets the field types availabe in the stored address and credit card data.
- void GetNonEmptyTypes(FieldTypeSet* non_empty_types);
+ void GetNonEmptyTypes(ServerFieldTypeSet* non_empty_types);
// Returns true if the credit card information is stored with a password.
bool HasPassword();
@@ -130,10 +130,10 @@ class PersonalDataManager : public WebDataServiceConsumer,
// has already been autofilled. |other_field_types| represents the rest of
// form. Identifying info is loaded into the last four outparams.
void GetProfileSuggestions(
- AutofillFieldType type,
+ const AutofillType& type,
const base::string16& field_contents,
bool field_is_autofilled,
- std::vector<AutofillFieldType> other_field_types,
+ std::vector<ServerFieldType> other_field_types,
std::vector<base::string16>* values,
std::vector<base::string16>* labels,
std::vector<base::string16>* icons,
@@ -143,7 +143,7 @@ class PersonalDataManager : public WebDataServiceConsumer,
// GetProfileSuggestions for argument descriptions. The variant in each
// GUID pair should be ignored.
void GetCreditCardSuggestions(
- AutofillFieldType type,
+ const AutofillType& type,
const base::string16& field_contents,
std::vector<base::string16>* values,
std::vector<base::string16>* labels,
diff --git a/components/autofill/core/browser/personal_data_manager_mac.mm b/components/autofill/core/browser/personal_data_manager_mac.mm
index d63283f3af..409fdc11da 100644
--- a/components/autofill/core/browser/personal_data_manager_mac.mm
+++ b/components/autofill/core/browser/personal_data_manager_mac.mm
@@ -18,6 +18,7 @@
#include "base/strings/sys_string_conversions.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/phone_number.h"
#include "grit/component_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -203,7 +204,7 @@ void AuxiliaryProfilesImpl::GetAddressBookAddress(const std::string& app_locale,
profile->SetRawInfo(ADDRESS_HOME_ZIP, base::SysNSStringToUTF16(zip));
if (NSString* country = [address objectForKey:kABAddressCountryKey]) {
- profile->SetInfo(ADDRESS_HOME_COUNTRY,
+ profile->SetInfo(AutofillType(ADDRESS_HOME_COUNTRY),
base::SysNSStringToUTF16(country),
app_locale);
}
diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc
index 2e22324513..7c08e5f898 100644
--- a/components/autofill/core/browser/personal_data_manager_unittest.cc
+++ b/components/autofill/core/browser/personal_data_manager_unittest.cc
@@ -2132,7 +2132,7 @@ TEST_F(PersonalDataManagerTest, SaveImportedCreditCardWithVerifiedData) {
TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) {
// Check that there are no available types with no profiles stored.
- FieldTypeSet non_empty_types;
+ ServerFieldTypeSet non_empty_types;
personal_data_->GetNonEmptyTypes(&non_empty_types);
EXPECT_EQ(0U, non_empty_types.size());
diff --git a/components/autofill/core/browser/phone_field.cc b/components/autofill/core/browser/phone_field.cc
index ee1e4e6c0d..6d156e909c 100644
--- a/components/autofill/core/browser/phone_field.cc
+++ b/components/autofill/core/browser/phone_field.cc
@@ -196,7 +196,7 @@ FormField* PhoneField::Parse(AutofillScanner* scanner) {
return phone_field.release();
}
-bool PhoneField::ClassifyField(FieldTypeMap* map) const {
+bool PhoneField::ClassifyField(ServerFieldTypeMap* map) const {
bool ok = true;
DCHECK(parsed_phone_fields_[FIELD_PHONE]); // Phone was correctly parsed.
@@ -210,7 +210,7 @@ bool PhoneField::ClassifyField(FieldTypeMap* map) const {
map);
}
- AutofillFieldType field_number_type = PHONE_HOME_NUMBER;
+ ServerFieldType field_number_type = PHONE_HOME_NUMBER;
if (parsed_phone_fields_[FIELD_AREA_CODE] != NULL) {
ok = ok && AddClassification(parsed_phone_fields_[FIELD_AREA_CODE],
PHONE_HOME_CITY_CODE,
diff --git a/components/autofill/core/browser/phone_field.h b/components/autofill/core/browser/phone_field.h
index cb5b73257f..f163b9c89a 100644
--- a/components/autofill/core/browser/phone_field.h
+++ b/components/autofill/core/browser/phone_field.h
@@ -29,7 +29,7 @@ class PhoneField : public FormField {
protected:
// FormField:
- virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
+ virtual bool ClassifyField(ServerFieldTypeMap* map) const OVERRIDE;
private:
FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone);
diff --git a/components/autofill/core/browser/phone_field_unittest.cc b/components/autofill/core/browser/phone_field_unittest.cc
index 46a5e0dc75..44c3df66b8 100644
--- a/components/autofill/core/browser/phone_field_unittest.cc
+++ b/components/autofill/core/browser/phone_field_unittest.cc
@@ -20,7 +20,7 @@ class PhoneFieldTest : public testing::Test {
protected:
ScopedVector<const AutofillField> list_;
scoped_ptr<PhoneField> field_;
- FieldTypeMap field_type_map_;
+ ServerFieldTypeMap field_type_map_;
// Downcast for tests.
static PhoneField* Parse(AutofillScanner* scanner) {
diff --git a/components/autofill/core/browser/phone_number.cc b/components/autofill/core/browser/phone_number.cc
index 9dc1b345df..e452f9823c 100644
--- a/components/autofill/core/browser/phone_number.cc
+++ b/components/autofill/core/browser/phone_number.cc
@@ -65,7 +65,7 @@ PhoneNumber& PhoneNumber::operator=(const PhoneNumber& number) {
return *this;
}
-void PhoneNumber::GetSupportedTypes(FieldTypeSet* supported_types) const {
+void PhoneNumber::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(PHONE_HOME_WHOLE_NUMBER);
supported_types->insert(PHONE_HOME_NUMBER);
supported_types->insert(PHONE_HOME_CITY_CODE);
@@ -73,7 +73,7 @@ void PhoneNumber::GetSupportedTypes(FieldTypeSet* supported_types) const {
supported_types->insert(PHONE_HOME_COUNTRY_CODE);
}
-base::string16 PhoneNumber::GetRawInfo(AutofillFieldType type) const {
+base::string16 PhoneNumber::GetRawInfo(ServerFieldType type) const {
type = AutofillType::GetEquivalentFieldType(type);
if (type == PHONE_HOME_WHOLE_NUMBER)
return number_;
@@ -84,7 +84,7 @@ base::string16 PhoneNumber::GetRawInfo(AutofillFieldType type) const {
return base::string16();
}
-void PhoneNumber::SetRawInfo(AutofillFieldType type,
+void PhoneNumber::SetRawInfo(ServerFieldType type,
const base::string16& value) {
type = AutofillType::GetEquivalentFieldType(type);
if (type != PHONE_HOME_CITY_AND_NUMBER &&
@@ -104,18 +104,20 @@ void PhoneNumber::SetRawInfo(AutofillFieldType type,
// (650)2345678 -> 6502345678
// 1-800-FLOWERS -> 18003569377
// If the phone cannot be normalized, returns the stored value verbatim.
-base::string16 PhoneNumber::GetInfo(AutofillFieldType type,
+base::string16 PhoneNumber::GetInfo(const AutofillType& type,
const std::string& app_locale) const {
- type = AutofillType::GetEquivalentFieldType(type);
+ ServerFieldType server_type =
+ AutofillType::GetEquivalentFieldType(type.server_type());
UpdateCacheIfNeeded(app_locale);
// Queries for whole numbers will return the non-normalized number if
// normalization for the number fails. All other field types require
// normalization.
- if (type != PHONE_HOME_WHOLE_NUMBER && !cached_parsed_phone_.IsValidNumber())
+ if (server_type != PHONE_HOME_WHOLE_NUMBER &&
+ !cached_parsed_phone_.IsValidNumber())
return base::string16();
- switch (type) {
+ switch (server_type) {
case PHONE_HOME_WHOLE_NUMBER:
return cached_parsed_phone_.GetWholeNumber();
@@ -138,11 +140,12 @@ base::string16 PhoneNumber::GetInfo(AutofillFieldType type,
}
}
-bool PhoneNumber::SetInfo(AutofillFieldType type,
+bool PhoneNumber::SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) {
- type = AutofillType::GetEquivalentFieldType(type);
- SetRawInfo(type, value);
+ ServerFieldType server_type =
+ AutofillType::GetEquivalentFieldType(type.server_type());
+ SetRawInfo(server_type, value);
if (number_.empty())
return true;
@@ -155,14 +158,14 @@ bool PhoneNumber::SetInfo(AutofillFieldType type,
void PhoneNumber::GetMatchingTypes(const base::string16& text,
const std::string& app_locale,
- FieldTypeSet* matching_types) const {
+ ServerFieldTypeSet* matching_types) const {
base::string16 stripped_text = text;
StripPunctuation(&stripped_text);
FormGroup::GetMatchingTypes(stripped_text, app_locale, matching_types);
// For US numbers, also compare to the three-digit prefix and the four-digit
// suffix, since web sites often split numbers into these two fields.
- base::string16 number = GetInfo(PHONE_HOME_NUMBER, app_locale);
+ base::string16 number = GetInfo(AutofillType(PHONE_HOME_NUMBER), app_locale);
if (GetRegion(*profile_, app_locale) == "US" &&
number.size() == (kPrefixLength + kSuffixLength)) {
base::string16 prefix = number.substr(kPrefixOffset, kPrefixLength);
@@ -171,7 +174,8 @@ void PhoneNumber::GetMatchingTypes(const base::string16& text,
matching_types->insert(PHONE_HOME_NUMBER);
}
- base::string16 whole_number = GetInfo(PHONE_HOME_WHOLE_NUMBER, app_locale);
+ base::string16 whole_number =
+ GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), app_locale);
if (!whole_number.empty()) {
base::string16 normalized_number =
i18n::NormalizePhoneNumber(text, GetRegion(*profile_, app_locale));
@@ -192,30 +196,31 @@ PhoneNumber::PhoneCombineHelper::PhoneCombineHelper() {
PhoneNumber::PhoneCombineHelper::~PhoneCombineHelper() {
}
-bool PhoneNumber::PhoneCombineHelper::SetInfo(AutofillFieldType field_type,
+bool PhoneNumber::PhoneCombineHelper::SetInfo(const AutofillType& field_type,
const base::string16& value) {
- field_type = AutofillType::GetEquivalentFieldType(field_type);
- if (field_type == PHONE_HOME_COUNTRY_CODE) {
+ ServerFieldType server_field_type =
+ AutofillType::GetEquivalentFieldType(field_type.server_type());
+ if (server_field_type == PHONE_HOME_COUNTRY_CODE) {
country_ = value;
return true;
}
- if (field_type == PHONE_HOME_CITY_CODE) {
+ if (server_field_type == PHONE_HOME_CITY_CODE) {
city_ = value;
return true;
}
- if (field_type == PHONE_HOME_CITY_AND_NUMBER) {
+ if (server_field_type == PHONE_HOME_CITY_AND_NUMBER) {
phone_ = value;
return true;
}
- if (field_type == PHONE_HOME_WHOLE_NUMBER) {
+ if (server_field_type == PHONE_HOME_WHOLE_NUMBER) {
whole_number_ = value;
return true;
}
- if (field_type == PHONE_HOME_NUMBER) {
+ if (server_field_type == PHONE_HOME_NUMBER) {
phone_.append(value);
return true;
}
diff --git a/components/autofill/core/browser/phone_number.h b/components/autofill/core/browser/phone_number.h
index 32ed209f0a..19f9f091da 100644
--- a/components/autofill/core/browser/phone_number.h
+++ b/components/autofill/core/browser/phone_number.h
@@ -10,7 +10,6 @@
#include "base/gtest_prod_util.h"
#include "base/strings/string16.h"
-#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/form_group.h"
#include "components/autofill/core/browser/phone_number_i18n.h"
@@ -30,15 +29,16 @@ class PhoneNumber : public FormGroup {
void set_profile(AutofillProfile* profile) { profile_ = profile; }
// FormGroup implementation:
- virtual void GetMatchingTypes(const base::string16& text,
- const std::string& app_locale,
- FieldTypeSet* matching_types) const OVERRIDE;
- virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
- virtual void SetRawInfo(AutofillFieldType type,
+ virtual void GetMatchingTypes(
+ const base::string16& text,
+ const std::string& app_locale,
+ ServerFieldTypeSet* matching_types) const OVERRIDE;
+ virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE;
+ virtual void SetRawInfo(ServerFieldType type,
const base::string16& value) OVERRIDE;
- virtual base::string16 GetInfo(AutofillFieldType type,
+ virtual base::string16 GetInfo(const AutofillType& type,
const std::string& app_locale) const OVERRIDE;
- virtual bool SetInfo(AutofillFieldType type,
+ virtual bool SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) OVERRIDE;
@@ -56,7 +56,7 @@ class PhoneNumber : public FormGroup {
// If |type| is a phone field type, saves the |value| accordingly and
// returns true. For all other field types returs false.
- bool SetInfo(AutofillFieldType type, const base::string16& value);
+ bool SetInfo(const AutofillType& type, const base::string16& value);
// Parses the number built up from pieces stored via SetInfo() according to
// the specified |profile|'s country code, falling back to the given
@@ -78,7 +78,8 @@ class PhoneNumber : public FormGroup {
private:
// FormGroup:
- virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
+ virtual void GetSupportedTypes(
+ ServerFieldTypeSet* supported_types) const OVERRIDE;
// Updates the cached parsed number if the profile's region has changed
// since the last time the cache was updated.
diff --git a/components/autofill/core/browser/phone_number_unittest.cc b/components/autofill/core/browser/phone_number_unittest.cc
index 417fb591be..fd654d06fa 100644
--- a/components/autofill/core/browser/phone_number_unittest.cc
+++ b/components/autofill/core/browser/phone_number_unittest.cc
@@ -5,6 +5,7 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/phone_number.h"
#include "components/autofill/core/browser/phone_number_i18n.h"
@@ -18,9 +19,9 @@ TEST(PhoneNumberTest, Matcher) {
// Set phone number so country_code == 1, city_code = 650, number = 2345678.
base::string16 phone(ASCIIToUTF16("1 [650] 234-5678"));
PhoneNumber phone_number(&profile);
- phone_number.SetInfo(PHONE_HOME_WHOLE_NUMBER, phone, "US");
+ phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phone, "US");
- FieldTypeSet matching_types;
+ ServerFieldTypeSet matching_types;
phone_number.GetMatchingTypes(base::string16(), "US", &matching_types);
EXPECT_EQ(1U, matching_types.size());
EXPECT_TRUE(matching_types.find(EMPTY_TYPE) != matching_types.end());
@@ -91,26 +92,26 @@ TEST(PhoneNumberTest, SetInfo) {
EXPECT_EQ(base::string16(), phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// Set the formatted info directly.
- EXPECT_TRUE(phone.SetInfo(PHONE_HOME_WHOLE_NUMBER,
+ EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
ASCIIToUTF16("(650) 234-5678"), "US"));
EXPECT_EQ(ASCIIToUTF16("(650) 234-5678"),
phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// Unformatted numbers should be formatted.
- EXPECT_TRUE(phone.SetInfo(PHONE_HOME_WHOLE_NUMBER,
+ EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
ASCIIToUTF16("8887776666"), "US"));
EXPECT_EQ(ASCIIToUTF16("(888) 777-6666"),
phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// Differently formatted numbers should be re-formatted.
- EXPECT_TRUE(phone.SetInfo(PHONE_HOME_WHOLE_NUMBER,
+ EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
ASCIIToUTF16("800-432-8765"), "US"));
EXPECT_EQ(ASCIIToUTF16("(800) 432-8765"),
phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// Invalid numbers should not be stored. In the US, phone numbers cannot
// start with the digit '1'.
- EXPECT_FALSE(phone.SetInfo(PHONE_HOME_WHOLE_NUMBER,
+ EXPECT_FALSE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
ASCIIToUTF16("650111111"), "US"));
EXPECT_EQ(base::string16(), phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
}
@@ -122,22 +123,26 @@ TEST(PhoneNumberTest, UpdateCachedPhoneNumber) {
PhoneNumber phone(&profile);
phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("6502345678"));
- EXPECT_EQ(ASCIIToUTF16("650"), phone.GetInfo(PHONE_HOME_CITY_CODE, "US"));
+ EXPECT_EQ(ASCIIToUTF16("650"),
+ phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
// Update the area code.
phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("8322345678"));
- EXPECT_EQ(ASCIIToUTF16("832"), phone.GetInfo(PHONE_HOME_CITY_CODE, "US"));
+ EXPECT_EQ(ASCIIToUTF16("832"),
+ phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
// Change the phone number to have a UK format, but try to parse with the
// wrong locale.
phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("07023456789"));
- EXPECT_EQ(base::string16(), phone.GetInfo(PHONE_HOME_CITY_CODE, "US"));
+ EXPECT_EQ(base::string16(),
+ phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
// Now try parsing using the correct locale. Note that the profile's country
// code should override the app locale, which is still set to "US".
profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("GB"));
phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("07023456789"));
- EXPECT_EQ(ASCIIToUTF16("70"), phone.GetInfo(PHONE_HOME_CITY_CODE, "US"));
+ EXPECT_EQ(ASCIIToUTF16("70"),
+ phone.GetInfo(AutofillType(PHONE_HOME_CITY_CODE), "US"));
}
TEST(PhoneNumberTest, PhoneCombineHelper) {
@@ -145,13 +150,13 @@ TEST(PhoneNumberTest, PhoneCombineHelper) {
profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
PhoneNumber::PhoneCombineHelper number1;
- EXPECT_FALSE(number1.SetInfo(ADDRESS_BILLING_CITY,
+ EXPECT_FALSE(number1.SetInfo(AutofillType(ADDRESS_BILLING_CITY),
ASCIIToUTF16("1")));
- EXPECT_TRUE(number1.SetInfo(PHONE_HOME_COUNTRY_CODE,
+ EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE),
ASCIIToUTF16("1")));
- EXPECT_TRUE(number1.SetInfo(PHONE_HOME_CITY_CODE,
+ EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_CITY_CODE),
ASCIIToUTF16("650")));
- EXPECT_TRUE(number1.SetInfo(PHONE_HOME_NUMBER,
+ EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_NUMBER),
ASCIIToUTF16("2345678")));
base::string16 parsed_phone;
EXPECT_TRUE(number1.ParseNumber(profile, "en-US", &parsed_phone));
@@ -159,34 +164,34 @@ TEST(PhoneNumberTest, PhoneCombineHelper) {
EXPECT_EQ(ASCIIToUTF16("+1 650-234-5678"), parsed_phone);
PhoneNumber::PhoneCombineHelper number3;
- EXPECT_TRUE(number3.SetInfo(PHONE_HOME_CITY_CODE,
+ EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_CITY_CODE),
ASCIIToUTF16("650")));
- EXPECT_TRUE(number3.SetInfo(PHONE_HOME_NUMBER,
+ EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_NUMBER),
ASCIIToUTF16("2345680")));
EXPECT_TRUE(number3.ParseNumber(profile, "en-US", &parsed_phone));
// National format as it does not have a country code.
EXPECT_EQ(ASCIIToUTF16("(650) 234-5680"), parsed_phone);
PhoneNumber::PhoneCombineHelper number4;
- EXPECT_TRUE(number4.SetInfo(PHONE_HOME_CITY_CODE,
+ EXPECT_TRUE(number4.SetInfo(AutofillType(PHONE_HOME_CITY_CODE),
ASCIIToUTF16("123"))); // Incorrect city code.
- EXPECT_TRUE(number4.SetInfo(PHONE_HOME_NUMBER,
+ EXPECT_TRUE(number4.SetInfo(AutofillType(PHONE_HOME_NUMBER),
ASCIIToUTF16("2345680")));
EXPECT_FALSE(number4.ParseNumber(profile, "en-US", &parsed_phone));
EXPECT_EQ(base::string16(), parsed_phone);
PhoneNumber::PhoneCombineHelper number5;
- EXPECT_TRUE(number5.SetInfo(PHONE_HOME_CITY_AND_NUMBER,
+ EXPECT_TRUE(number5.SetInfo(AutofillType(PHONE_HOME_CITY_AND_NUMBER),
ASCIIToUTF16("6502345681")));
EXPECT_TRUE(number5.ParseNumber(profile, "en-US", &parsed_phone));
EXPECT_EQ(ASCIIToUTF16("(650) 234-5681"), parsed_phone);
PhoneNumber::PhoneCombineHelper number6;
- EXPECT_TRUE(number6.SetInfo(PHONE_HOME_CITY_CODE,
+ EXPECT_TRUE(number6.SetInfo(AutofillType(PHONE_HOME_CITY_CODE),
ASCIIToUTF16("650")));
- EXPECT_TRUE(number6.SetInfo(PHONE_HOME_NUMBER,
+ EXPECT_TRUE(number6.SetInfo(AutofillType(PHONE_HOME_NUMBER),
ASCIIToUTF16("234")));
- EXPECT_TRUE(number6.SetInfo(PHONE_HOME_NUMBER,
+ EXPECT_TRUE(number6.SetInfo(AutofillType(PHONE_HOME_NUMBER),
ASCIIToUTF16("5682")));
EXPECT_TRUE(number6.ParseNumber(profile, "en-US", &parsed_phone));
EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone);
@@ -194,11 +199,11 @@ TEST(PhoneNumberTest, PhoneCombineHelper) {
// Ensure parsing is possible when falling back to detecting the country code
// based on the app locale.
PhoneNumber::PhoneCombineHelper number7;
- EXPECT_TRUE(number7.SetInfo(PHONE_HOME_CITY_CODE,
+ EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_CITY_CODE),
ASCIIToUTF16("650")));
- EXPECT_TRUE(number7.SetInfo(PHONE_HOME_NUMBER,
+ EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER),
ASCIIToUTF16("234")));
- EXPECT_TRUE(number7.SetInfo(PHONE_HOME_NUMBER,
+ EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER),
ASCIIToUTF16("5682")));
EXPECT_TRUE(number7.ParseNumber(AutofillProfile(), "en-US", &parsed_phone));
EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone);
diff --git a/components/autofill/core/browser/webdata/autofill_table.cc b/components/autofill/core/browser/webdata/autofill_table.cc
index 07955b29ce..9066d9c0df 100644
--- a/components/autofill/core/browser/webdata/autofill_table.cc
+++ b/components/autofill/core/browser/webdata/autofill_table.cc
@@ -72,7 +72,7 @@ void BindAutofillProfileToStatement(const AutofillProfile& profile,
s->BindString16(5, LimitDataSize(text));
text = profile.GetRawInfo(ADDRESS_HOME_ZIP);
s->BindString16(6, LimitDataSize(text));
- text = profile.GetInfo(ADDRESS_HOME_COUNTRY, app_locale);
+ text = profile.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), app_locale);
s->BindString16(7, LimitDataSize(text));
text = profile.GetRawInfo(ADDRESS_HOME_COUNTRY);
s->BindString16(8, LimitDataSize(text));
@@ -1928,7 +1928,8 @@ bool AutofillTable::MigrateToVersion33ProfilesBasedOnFirstName() {
profile.SetRawInfo(ADDRESS_HOME_CITY, s.ColumnString16(8));
profile.SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(9));
profile.SetRawInfo(ADDRESS_HOME_ZIP, s.ColumnString16(10));
- profile.SetInfo(ADDRESS_HOME_COUNTRY, s.ColumnString16(11), app_locale_);
+ profile.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), s.ColumnString16(11),
+ app_locale_);
profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, s.ColumnString16(12));
int64 date_modified = s.ColumnInt64(13);
@@ -2151,7 +2152,7 @@ bool AutofillTable::MigrateToVersion37MergeAndCullOlderProfiles() {
s.BindString16(5, LimitDataSize(text));
text = iter->GetRawInfo(ADDRESS_HOME_ZIP);
s.BindString16(6, LimitDataSize(text));
- text = iter->GetInfo(ADDRESS_HOME_COUNTRY, app_locale_);
+ text = iter->GetInfo(AutofillType(ADDRESS_HOME_COUNTRY), app_locale_);
s.BindString16(7, LimitDataSize(text));
text = iter->GetRawInfo(ADDRESS_HOME_COUNTRY);
s.BindString16(8, LimitDataSize(text));
diff --git a/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/WebContentsDelegateAndroid.java b/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/WebContentsDelegateAndroid.java
index 62d24031dc..c09cb89629 100644
--- a/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/WebContentsDelegateAndroid.java
+++ b/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/WebContentsDelegateAndroid.java
@@ -26,7 +26,7 @@ public class WebContentsDelegateAndroid {
// Equivalent of WebCore::WebConsoleMessage::LevelError.
public static final int LOG_LEVEL_ERROR = 3;
- // Flags passed to the WebContentsDelegate.navigationStateChanged to tell it
+ // Flags passed to the WebContentsDelegateAndroid.navigationStateChanged to tell it
// what has changed. Should match the values in invalidate_type.h.
// Equivalent of InvalidateTypes::INVALIDATE_TYPE_URL.
public static final int INVALIDATE_TYPE_URL = 1 << 0;
@@ -47,8 +47,13 @@ public class WebContentsDelegateAndroid {
return mMostRecentProgress;
}
+ /**
+ * @param disposition The new tab disposition as per the constants in
+ * org.chromium.ui.WindowOpenDisposition (See window_open_disposition_list.h
+ * for the enumeration definitions).
+ */
@CalledByNative
- public void openNewTab(String url, String extraHeaders, byte[] postData, boolean incognito) {
+ public void openNewTab(String url, String extraHeaders, byte[] postData, int disposition) {
}
@CalledByNative
diff --git a/components/web_contents_delegate_android/web_contents_delegate_android.cc b/components/web_contents_delegate_android/web_contents_delegate_android.cc
index f2003c928b..8f599a16b0 100644
--- a/components/web_contents_delegate_android/web_contents_delegate_android.cc
+++ b/components/web_contents_delegate_android/web_contents_delegate_android.cc
@@ -103,7 +103,7 @@ WebContents* WebContentsDelegateAndroid::OpenURLFromTab(
java_url.obj(),
extra_headers.obj(),
post_data.obj(),
- disposition == OFF_THE_RECORD);
+ disposition);
return NULL;
}
diff --git a/components/webdata/common/web_database_migration_unittest.cc b/components/webdata/common/web_database_migration_unittest.cc
index 927fae63ad..5e6ef6e9dc 100644
--- a/components/webdata/common/web_database_migration_unittest.cc
+++ b/components/webdata/common/web_database_migration_unittest.cc
@@ -60,7 +60,8 @@ void AutofillProfile31FromStatement(const sql::Statement& s,
profile->SetRawInfo(autofill::ADDRESS_HOME_STATE, s.ColumnString16(10));
profile->SetRawInfo(autofill::ADDRESS_HOME_ZIP, s.ColumnString16(11));
profile->SetInfo(
- autofill::ADDRESS_HOME_COUNTRY, s.ColumnString16(12), "en-US");
+ autofill::AutofillType(autofill::ADDRESS_HOME_COUNTRY),
+ s.ColumnString16(12), "en-US");
profile->SetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER, s.ColumnString16(13));
*date_modified = s.ColumnInt64(15);
profile->set_guid(s.ColumnString(16));
@@ -81,7 +82,8 @@ void AutofillProfile33FromStatement(const sql::Statement& s,
profile->SetRawInfo(autofill::ADDRESS_HOME_STATE, s.ColumnString16(5));
profile->SetRawInfo(autofill::ADDRESS_HOME_ZIP, s.ColumnString16(6));
profile->SetInfo(
- autofill::ADDRESS_HOME_COUNTRY, s.ColumnString16(7), "en-US");
+ autofill::AutofillType(autofill::ADDRESS_HOME_COUNTRY),
+ s.ColumnString16(7), "en-US");
*date_modified = s.ColumnInt64(8);
}