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

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: Add docs Created 7 years, 5 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 bd88f4f7bf4c15243ced58ebf5b59728eafd92aa..3ca44a71b0254c69e9c0725f85e2f38ad33435b2 100644
--- a/components/autofill/core/browser/address.cc
+++ b/components/autofill/core/browser/address.cc
@@ -44,52 +44,67 @@ Address& Address::operator=(const Address& address) {
}
base::string16 Address::GetRawInfo(NativeFieldType type) const {
- type = AutofillType::GetEquivalentFieldType(type);
- if (type == ADDRESS_HOME_LINE1)
- return line1_;
+ // TODO(isherman): Is GetEquivalentNativeType even necessary?
Evan Stade 2013/08/05 18:47:24 I'm assuming you mean you could just switch on |ty
Ilya Sherman 2013/08/06 05:05:39 Yeah. This requires fixing up a couple of call si
+ switch (AutofillType(type).GetEquivalentNativeType()) {
+ 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(NativeFieldType 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 GetEquivalentNativeType even necessary?
+ switch (AutofillType(type).GetEquivalentNativeType()) {
+ 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 {
- NativeFieldType native_type =
- AutofillType::GetEquivalentFieldType(type.native_type());
+ NativeFieldType native_type = type.GetEquivalentNativeType();
if (native_type == ADDRESS_HOME_COUNTRY && !country_code_.empty())
return AutofillCountry(UTF16ToASCII(country_code_), app_locale).name();
@@ -99,8 +114,7 @@ base::string16 Address::GetInfo(const AutofillType& type,
bool Address::SetInfo(const AutofillType& type,
const base::string16& value,
const std::string& app_locale) {
- NativeFieldType native_type =
- AutofillType::GetEquivalentFieldType(type.native_type());
+ NativeFieldType native_type = type.GetEquivalentNativeType();
if (native_type == ADDRESS_HOME_COUNTRY && !value.empty()) {
country_code_ =
ASCIIToUTF16(AutofillCountry::GetCountryCode(value, app_locale));

Powered by Google App Engine
This is Rietveld 408576698