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

Unified Diff: components/autofill/core/browser/contact_info.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, 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/contact_info.cc
diff --git a/components/autofill/core/browser/contact_info.cc b/components/autofill/core/browser/contact_info.cc
index 202867613b5f57ef4a6b4262af19b87e55da6e40..979434fc564a37c834371a8e0adc7fdf49280fdb 100644
--- a/components/autofill/core/browser/contact_info.cc
+++ b/components/autofill/core/browser/contact_info.cc
@@ -52,38 +52,53 @@ void NameInfo::GetSupportedTypes(NativeFieldTypeSet* supported_types) const {
}
base::string16 NameInfo::GetRawInfo(NativeFieldType type) const {
- type = AutofillType::GetEquivalentFieldType(type);
- if (type == NAME_FIRST)
- return first();
+ // TODO(isherman): Is GetEquivalentNativeType even necessary?
+ switch (AutofillType(type).GetEquivalentNativeType()) {
+ case NAME_FIRST:
+ return first();
- if (type == NAME_MIDDLE)
- return middle();
+ case NAME_MIDDLE:
+ return middle();
- if (type == NAME_LAST)
- return last();
+ case NAME_LAST:
+ return last();
- if (type == NAME_MIDDLE_INITIAL)
- return MiddleInitial();
+ case NAME_MIDDLE_INITIAL:
+ return MiddleInitial();
- if (type == NAME_FULL)
- return FullName();
+ case NAME_FULL:
+ return FullName();
- return base::string16();
+ default:
+ return base::string16();
+ }
}
void NameInfo::SetRawInfo(NativeFieldType type, const base::string16& value) {
- type = AutofillType::GetEquivalentFieldType(type);
- DCHECK_EQ(NAME, AutofillType(type).group());
- if (type == NAME_FIRST)
- first_ = value;
- else if (type == NAME_MIDDLE || type == NAME_MIDDLE_INITIAL)
- middle_ = value;
- else if (type == NAME_LAST)
- last_ = value;
- else if (type == NAME_FULL)
- SetFullName(value);
- else
- NOTREACHED();
+ // TODO(isherman): Is GetEquivalentNativeType even necessary?
+ NativeFieldType native_type = AutofillType(type).GetEquivalentNativeType();
+ DCHECK_EQ(NAME, AutofillType(native_type).group());
+ switch (native_type) {
+ case NAME_FIRST:
+ first_ = value;
+ break;
+
+ case NAME_MIDDLE:
+ case NAME_MIDDLE_INITIAL:
+ middle_ = value;
+ break;
+
+ case NAME_LAST:
+ last_ = value;
+ break;
+
+ case NAME_FULL:
+ SetFullName(value);
+ break;
+
+ default:
+ NOTREACHED();
+ }
}
base::string16 NameInfo::FullName() const {

Powered by Google App Engine
This is Rietveld 408576698