OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/autofill/core/browser/contact_info.h" | 5 #include "components/autofill/core/browser/contact_info.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <ostream> | 8 #include <ostream> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 void NameInfo::GetSupportedTypes(NativeFieldTypeSet* supported_types) const { | 46 void NameInfo::GetSupportedTypes(NativeFieldTypeSet* supported_types) const { |
47 supported_types->insert(NAME_FIRST); | 47 supported_types->insert(NAME_FIRST); |
48 supported_types->insert(NAME_MIDDLE); | 48 supported_types->insert(NAME_MIDDLE); |
49 supported_types->insert(NAME_LAST); | 49 supported_types->insert(NAME_LAST); |
50 supported_types->insert(NAME_MIDDLE_INITIAL); | 50 supported_types->insert(NAME_MIDDLE_INITIAL); |
51 supported_types->insert(NAME_FULL); | 51 supported_types->insert(NAME_FULL); |
52 } | 52 } |
53 | 53 |
54 base::string16 NameInfo::GetRawInfo(NativeFieldType type) const { | 54 base::string16 NameInfo::GetRawInfo(NativeFieldType type) const { |
55 type = AutofillType::GetEquivalentFieldType(type); | 55 // TODO(isherman): Is GetEquivalentNativeType even necessary? |
56 if (type == NAME_FIRST) | 56 switch (AutofillType(type).GetEquivalentNativeType()) { |
57 return first(); | 57 case NAME_FIRST: |
| 58 return first(); |
58 | 59 |
59 if (type == NAME_MIDDLE) | 60 case NAME_MIDDLE: |
60 return middle(); | 61 return middle(); |
61 | 62 |
62 if (type == NAME_LAST) | 63 case NAME_LAST: |
63 return last(); | 64 return last(); |
64 | 65 |
65 if (type == NAME_MIDDLE_INITIAL) | 66 case NAME_MIDDLE_INITIAL: |
66 return MiddleInitial(); | 67 return MiddleInitial(); |
67 | 68 |
68 if (type == NAME_FULL) | 69 case NAME_FULL: |
69 return FullName(); | 70 return FullName(); |
70 | 71 |
71 return base::string16(); | 72 default: |
| 73 return base::string16(); |
| 74 } |
72 } | 75 } |
73 | 76 |
74 void NameInfo::SetRawInfo(NativeFieldType type, const base::string16& value) { | 77 void NameInfo::SetRawInfo(NativeFieldType type, const base::string16& value) { |
75 type = AutofillType::GetEquivalentFieldType(type); | 78 // TODO(isherman): Is GetEquivalentNativeType even necessary? |
76 DCHECK_EQ(NAME, AutofillType(type).group()); | 79 NativeFieldType native_type = AutofillType(type).GetEquivalentNativeType(); |
77 if (type == NAME_FIRST) | 80 DCHECK_EQ(NAME, AutofillType(native_type).group()); |
78 first_ = value; | 81 switch (native_type) { |
79 else if (type == NAME_MIDDLE || type == NAME_MIDDLE_INITIAL) | 82 case NAME_FIRST: |
80 middle_ = value; | 83 first_ = value; |
81 else if (type == NAME_LAST) | 84 break; |
82 last_ = value; | 85 |
83 else if (type == NAME_FULL) | 86 case NAME_MIDDLE: |
84 SetFullName(value); | 87 case NAME_MIDDLE_INITIAL: |
85 else | 88 middle_ = value; |
86 NOTREACHED(); | 89 break; |
| 90 |
| 91 case NAME_LAST: |
| 92 last_ = value; |
| 93 break; |
| 94 |
| 95 case NAME_FULL: |
| 96 SetFullName(value); |
| 97 break; |
| 98 |
| 99 default: |
| 100 NOTREACHED(); |
| 101 } |
87 } | 102 } |
88 | 103 |
89 base::string16 NameInfo::FullName() const { | 104 base::string16 NameInfo::FullName() const { |
90 std::vector<base::string16> full_name; | 105 std::vector<base::string16> full_name; |
91 if (!first_.empty()) | 106 if (!first_.empty()) |
92 full_name.push_back(first_); | 107 full_name.push_back(first_); |
93 | 108 |
94 if (!middle_.empty()) | 109 if (!middle_.empty()) |
95 full_name.push_back(middle_); | 110 full_name.push_back(middle_); |
96 | 111 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 return base::string16(); | 208 return base::string16(); |
194 } | 209 } |
195 | 210 |
196 void CompanyInfo::SetRawInfo(NativeFieldType type, | 211 void CompanyInfo::SetRawInfo(NativeFieldType type, |
197 const base::string16& value) { | 212 const base::string16& value) { |
198 DCHECK_EQ(COMPANY_NAME, type); | 213 DCHECK_EQ(COMPANY_NAME, type); |
199 company_name_ = value; | 214 company_name_ = value; |
200 } | 215 } |
201 | 216 |
202 } // namespace autofill | 217 } // namespace autofill |
OLD | NEW |