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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "components/autofill/core/browser/autofill_type.h" | 15 #include "components/autofill/core/browser/autofill_type.h" |
16 #include "components/autofill/core/browser/field_types.h" | |
17 | 16 |
18 namespace autofill { | 17 namespace autofill { |
19 | 18 |
20 static const AutofillFieldType kAutofillNameInfoTypes[] = { | 19 static const ServerFieldType kAutofillNameInfoTypes[] = { |
21 NAME_FIRST, | 20 NAME_FIRST, |
22 NAME_MIDDLE, | 21 NAME_MIDDLE, |
23 NAME_LAST | 22 NAME_LAST |
24 }; | 23 }; |
25 | 24 |
26 static const size_t kAutofillNameInfoLength = | 25 static const size_t kAutofillNameInfoLength = |
27 arraysize(kAutofillNameInfoTypes); | 26 arraysize(kAutofillNameInfoTypes); |
28 | 27 |
29 NameInfo::NameInfo() {} | 28 NameInfo::NameInfo() {} |
30 | 29 |
31 NameInfo::NameInfo(const NameInfo& info) : FormGroup() { | 30 NameInfo::NameInfo(const NameInfo& info) : FormGroup() { |
32 *this = info; | 31 *this = info; |
33 } | 32 } |
34 | 33 |
35 NameInfo::~NameInfo() {} | 34 NameInfo::~NameInfo() {} |
36 | 35 |
37 NameInfo& NameInfo::operator=(const NameInfo& info) { | 36 NameInfo& NameInfo::operator=(const NameInfo& info) { |
38 if (this == &info) | 37 if (this == &info) |
39 return *this; | 38 return *this; |
40 | 39 |
41 first_ = info.first_; | 40 first_ = info.first_; |
42 middle_ = info.middle_; | 41 middle_ = info.middle_; |
43 last_ = info.last_; | 42 last_ = info.last_; |
44 return *this; | 43 return *this; |
45 } | 44 } |
46 | 45 |
47 void NameInfo::GetSupportedTypes(FieldTypeSet* supported_types) const { | 46 void NameInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const { |
48 supported_types->insert(NAME_FIRST); | 47 supported_types->insert(NAME_FIRST); |
49 supported_types->insert(NAME_MIDDLE); | 48 supported_types->insert(NAME_MIDDLE); |
50 supported_types->insert(NAME_LAST); | 49 supported_types->insert(NAME_LAST); |
51 supported_types->insert(NAME_MIDDLE_INITIAL); | 50 supported_types->insert(NAME_MIDDLE_INITIAL); |
52 supported_types->insert(NAME_FULL); | 51 supported_types->insert(NAME_FULL); |
53 } | 52 } |
54 | 53 |
55 base::string16 NameInfo::GetRawInfo(AutofillFieldType type) const { | 54 base::string16 NameInfo::GetRawInfo(ServerFieldType type) const { |
56 type = AutofillType::GetEquivalentFieldType(type); | 55 type = AutofillType::GetEquivalentFieldType(type); |
57 if (type == NAME_FIRST) | 56 if (type == NAME_FIRST) |
58 return first(); | 57 return first(); |
59 | 58 |
60 if (type == NAME_MIDDLE) | 59 if (type == NAME_MIDDLE) |
61 return middle(); | 60 return middle(); |
62 | 61 |
63 if (type == NAME_LAST) | 62 if (type == NAME_LAST) |
64 return last(); | 63 return last(); |
65 | 64 |
66 if (type == NAME_MIDDLE_INITIAL) | 65 if (type == NAME_MIDDLE_INITIAL) |
67 return MiddleInitial(); | 66 return MiddleInitial(); |
68 | 67 |
69 if (type == NAME_FULL) | 68 if (type == NAME_FULL) |
70 return FullName(); | 69 return FullName(); |
71 | 70 |
72 return base::string16(); | 71 return base::string16(); |
73 } | 72 } |
74 | 73 |
75 void NameInfo::SetRawInfo(AutofillFieldType type, const base::string16& value) { | 74 void NameInfo::SetRawInfo(ServerFieldType type, const base::string16& value) { |
76 type = AutofillType::GetEquivalentFieldType(type); | 75 type = AutofillType::GetEquivalentFieldType(type); |
77 DCHECK_EQ(NAME, AutofillType(type).group()); | 76 DCHECK_EQ(NAME, AutofillType(type).group()); |
78 if (type == NAME_FIRST) | 77 if (type == NAME_FIRST) |
79 first_ = value; | 78 first_ = value; |
80 else if (type == NAME_MIDDLE || type == NAME_MIDDLE_INITIAL) | 79 else if (type == NAME_MIDDLE || type == NAME_MIDDLE_INITIAL) |
81 middle_ = value; | 80 middle_ = value; |
82 else if (type == NAME_LAST) | 81 else if (type == NAME_LAST) |
83 last_ = value; | 82 last_ = value; |
84 else if (type == NAME_FULL) | 83 else if (type == NAME_FULL) |
85 SetFullName(value); | 84 SetFullName(value); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 EmailInfo::~EmailInfo() {} | 143 EmailInfo::~EmailInfo() {} |
145 | 144 |
146 EmailInfo& EmailInfo::operator=(const EmailInfo& info) { | 145 EmailInfo& EmailInfo::operator=(const EmailInfo& info) { |
147 if (this == &info) | 146 if (this == &info) |
148 return *this; | 147 return *this; |
149 | 148 |
150 email_ = info.email_; | 149 email_ = info.email_; |
151 return *this; | 150 return *this; |
152 } | 151 } |
153 | 152 |
154 void EmailInfo::GetSupportedTypes(FieldTypeSet* supported_types) const { | 153 void EmailInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const { |
155 supported_types->insert(EMAIL_ADDRESS); | 154 supported_types->insert(EMAIL_ADDRESS); |
156 } | 155 } |
157 | 156 |
158 base::string16 EmailInfo::GetRawInfo(AutofillFieldType type) const { | 157 base::string16 EmailInfo::GetRawInfo(ServerFieldType type) const { |
159 if (type == EMAIL_ADDRESS) | 158 if (type == EMAIL_ADDRESS) |
160 return email_; | 159 return email_; |
161 | 160 |
162 return base::string16(); | 161 return base::string16(); |
163 } | 162 } |
164 | 163 |
165 void EmailInfo::SetRawInfo(AutofillFieldType type, | 164 void EmailInfo::SetRawInfo(ServerFieldType type, const base::string16& value) { |
166 const base::string16& value) { | |
167 DCHECK_EQ(EMAIL_ADDRESS, type); | 165 DCHECK_EQ(EMAIL_ADDRESS, type); |
168 email_ = value; | 166 email_ = value; |
169 } | 167 } |
170 | 168 |
171 CompanyInfo::CompanyInfo() {} | 169 CompanyInfo::CompanyInfo() {} |
172 | 170 |
173 CompanyInfo::CompanyInfo(const CompanyInfo& info) : FormGroup() { | 171 CompanyInfo::CompanyInfo(const CompanyInfo& info) : FormGroup() { |
174 *this = info; | 172 *this = info; |
175 } | 173 } |
176 | 174 |
177 CompanyInfo::~CompanyInfo() {} | 175 CompanyInfo::~CompanyInfo() {} |
178 | 176 |
179 CompanyInfo& CompanyInfo::operator=(const CompanyInfo& info) { | 177 CompanyInfo& CompanyInfo::operator=(const CompanyInfo& info) { |
180 if (this == &info) | 178 if (this == &info) |
181 return *this; | 179 return *this; |
182 | 180 |
183 company_name_ = info.company_name_; | 181 company_name_ = info.company_name_; |
184 return *this; | 182 return *this; |
185 } | 183 } |
186 | 184 |
187 void CompanyInfo::GetSupportedTypes(FieldTypeSet* supported_types) const { | 185 void CompanyInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const { |
188 supported_types->insert(COMPANY_NAME); | 186 supported_types->insert(COMPANY_NAME); |
189 } | 187 } |
190 | 188 |
191 base::string16 CompanyInfo::GetRawInfo(AutofillFieldType type) const { | 189 base::string16 CompanyInfo::GetRawInfo(ServerFieldType type) const { |
192 if (type == COMPANY_NAME) | 190 if (type == COMPANY_NAME) |
193 return company_name_; | 191 return company_name_; |
194 | 192 |
195 return base::string16(); | 193 return base::string16(); |
196 } | 194 } |
197 | 195 |
198 void CompanyInfo::SetRawInfo(AutofillFieldType type, | 196 void CompanyInfo::SetRawInfo(ServerFieldType type, |
199 const base::string16& value) { | 197 const base::string16& value) { |
200 DCHECK_EQ(COMPANY_NAME, type); | 198 DCHECK_EQ(COMPANY_NAME, type); |
201 company_name_ = value; | 199 company_name_ = value; |
202 } | 200 } |
203 | 201 |
204 } // namespace autofill | 202 } // namespace autofill |
OLD | NEW |