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

Unified Diff: components/autofill/core/browser/address.cc

Issue 22040002: [Autofill] Add a separate enumeration for HTML field type hints. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser test Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/address.cc
diff --git a/components/autofill/core/browser/address.cc b/components/autofill/core/browser/address.cc
index 339352f8d53fab4bade5a3f21d68c38973aa6a02..ca522f6d35ea5fb2ed97945a32759e83feff2d75 100644
--- a/components/autofill/core/browser/address.cc
+++ b/components/autofill/core/browser/address.cc
@@ -44,70 +44,84 @@ Address& Address::operator=(const Address& address) {
}
base::string16 Address::GetRawInfo(ServerFieldType type) const {
- type = AutofillType::GetEquivalentFieldType(type);
- if (type == ADDRESS_HOME_LINE1)
- return line1_;
+ // TODO(isherman): Is GetStorableType even necessary?
+ switch (AutofillType(type).GetStorableType()) {
+ case ADDRESS_HOME_LINE1:
+ return line1_;
- if (type == ADDRESS_HOME_LINE2)
- return line2_;
+ case ADDRESS_HOME_LINE2:
+ return line2_;
- if (type == ADDRESS_HOME_CITY)
- return city_;
+ case ADDRESS_HOME_CITY:
+ return city_;
- if (type == ADDRESS_HOME_STATE)
- return state_;
+ case ADDRESS_HOME_STATE:
+ return state_;
- if (type == ADDRESS_HOME_ZIP)
- return zip_code_;
+ case ADDRESS_HOME_ZIP:
+ return zip_code_;
- if (type == ADDRESS_HOME_COUNTRY)
- return country_code_;
+ case ADDRESS_HOME_COUNTRY:
+ return country_code_;
- return base::string16();
+ default:
+ return base::string16();
+ }
}
void Address::SetRawInfo(ServerFieldType type, const base::string16& value) {
- type = AutofillType::GetEquivalentFieldType(type);
- if (type == ADDRESS_HOME_LINE1) {
- line1_ = value;
- } else if (type == ADDRESS_HOME_LINE2) {
- line2_ = value;
- } else if (type == ADDRESS_HOME_CITY) {
- city_ = value;
- } else if (type == ADDRESS_HOME_STATE) {
- state_ = value;
- } else if (type == ADDRESS_HOME_COUNTRY) {
- DCHECK(value.empty() || value.length() == 2u);
- country_code_ = value;
- } else if (type == ADDRESS_HOME_ZIP) {
- zip_code_ = value;
- } else {
- NOTREACHED();
+ // TODO(isherman): Is GetStorableType even necessary?
+ switch (AutofillType(type).GetStorableType()) {
+ case ADDRESS_HOME_LINE1:
+ line1_ = value;
+ break;
+
+ case ADDRESS_HOME_LINE2:
+ line2_ = value;
+ break;
+
+ case ADDRESS_HOME_CITY:
+ city_ = value;
+ break;
+
+ case ADDRESS_HOME_STATE:
+ state_ = value;
+ break;
+
+ case ADDRESS_HOME_COUNTRY:
+ DCHECK(value.empty() || value.length() == 2u);
+ country_code_ = value;
+ break;
+
+ case ADDRESS_HOME_ZIP:
+ zip_code_ = value;
+ break;
+
+ default:
+ NOTREACHED();
}
}
base::string16 Address::GetInfo(const AutofillType& type,
const std::string& app_locale) const {
- ServerFieldType server_type =
- AutofillType::GetEquivalentFieldType(type.server_type());
- if (server_type == ADDRESS_HOME_COUNTRY && !country_code_.empty())
+ ServerFieldType storable_type = type.GetStorableType();
+ if (storable_type == ADDRESS_HOME_COUNTRY && !country_code_.empty())
return AutofillCountry(UTF16ToASCII(country_code_), app_locale).name();
- return GetRawInfo(server_type);
+ return GetRawInfo(storable_type);
}
bool Address::SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) {
- ServerFieldType server_type =
- AutofillType::GetEquivalentFieldType(type.server_type());
- if (server_type == ADDRESS_HOME_COUNTRY && !value.empty()) {
+ ServerFieldType storable_type = type.GetStorableType();
+ if (storable_type == ADDRESS_HOME_COUNTRY && !value.empty()) {
country_code_ =
ASCIIToUTF16(AutofillCountry::GetCountryCode(value, app_locale));
return !country_code_.empty();
}
- SetRawInfo(server_type, value);
+ SetRawInfo(storable_type, value);
return true;
}
« no previous file with comments | « components/autofill/content/browser/wallet/wallet_items.cc ('k') | components/autofill/core/browser/autofill_data_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698