OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/autofill_profile.h" | 5 #include "components/autofill/browser/autofill_profile.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <map> | 9 #include <map> |
10 #include <ostream> | 10 #include <ostream> |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 { | 216 { |
217 bool operator()(const base::string16& x, const base::string16& y) const { | 217 bool operator()(const base::string16& x, const base::string16& y) const { |
218 return | 218 return |
219 x.size() == y.size() && StringToLowerASCII(x) == StringToLowerASCII(y); | 219 x.size() == y.size() && StringToLowerASCII(x) == StringToLowerASCII(y); |
220 } | 220 } |
221 }; | 221 }; |
222 | 222 |
223 } // namespace | 223 } // namespace |
224 | 224 |
225 AutofillProfile::AutofillProfile(const std::string& guid) | 225 AutofillProfile::AutofillProfile(const std::string& guid) |
226 : guid_(guid), | 226 : AutofillDataModel(guid), |
227 name_(1), | 227 name_(1), |
228 email_(1), | 228 email_(1), |
229 home_number_(1, PhoneNumber(this)) { | 229 home_number_(1, PhoneNumber(this)) { |
230 } | 230 } |
231 | 231 |
232 AutofillProfile::AutofillProfile() | 232 AutofillProfile::AutofillProfile() |
233 : guid_(base::GenerateGUID()), | 233 : AutofillDataModel(base::GenerateGUID()), |
234 name_(1), | 234 name_(1), |
235 email_(1), | 235 email_(1), |
236 home_number_(1, PhoneNumber(this)) { | 236 home_number_(1, PhoneNumber(this)) { |
237 } | 237 } |
238 | 238 |
239 AutofillProfile::AutofillProfile(const AutofillProfile& profile) | 239 AutofillProfile::AutofillProfile(const AutofillProfile& profile) |
240 : FormGroup() { | 240 : AutofillDataModel(std::string()) { |
241 operator=(profile); | 241 operator=(profile); |
242 } | 242 } |
243 | 243 |
244 AutofillProfile::~AutofillProfile() { | 244 AutofillProfile::~AutofillProfile() { |
245 } | 245 } |
246 | 246 |
247 AutofillProfile& AutofillProfile::operator=(const AutofillProfile& profile) { | 247 AutofillProfile& AutofillProfile::operator=(const AutofillProfile& profile) { |
248 if (this == &profile) | 248 if (this == &profile) |
249 return *this; | 249 return *this; |
250 | 250 |
| 251 set_guid(profile.guid()); |
| 252 |
251 label_ = profile.label_; | 253 label_ = profile.label_; |
252 guid_ = profile.guid_; | |
253 | |
254 name_ = profile.name_; | 254 name_ = profile.name_; |
255 email_ = profile.email_; | 255 email_ = profile.email_; |
256 company_ = profile.company_; | 256 company_ = profile.company_; |
257 home_number_ = profile.home_number_; | 257 home_number_ = profile.home_number_; |
258 | 258 |
259 for (size_t i = 0; i < home_number_.size(); ++i) | 259 for (size_t i = 0; i < home_number_.size(); ++i) |
260 home_number_[i].set_profile(this); | 260 home_number_[i].set_profile(this); |
261 | 261 |
262 address_ = profile.address_; | 262 address_ = profile.address_; |
263 | 263 |
264 return *this; | 264 return *this; |
265 } | 265 } |
266 | 266 |
267 std::string AutofillProfile::GetGUID() const { | |
268 return guid(); | |
269 } | |
270 | |
271 void AutofillProfile::GetMatchingTypes(const base::string16& text, | 267 void AutofillProfile::GetMatchingTypes(const base::string16& text, |
272 const std::string& app_locale, | 268 const std::string& app_locale, |
273 FieldTypeSet* matching_types) const { | 269 FieldTypeSet* matching_types) const { |
274 FormGroupList info = FormGroups(); | 270 FormGroupList info = FormGroups(); |
275 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) | 271 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) |
276 (*it)->GetMatchingTypes(text, app_locale, matching_types); | 272 (*it)->GetMatchingTypes(text, app_locale, matching_types); |
277 } | 273 } |
278 | 274 |
279 base::string16 AutofillProfile::GetRawInfo(AutofillFieldType type) const { | 275 base::string16 AutofillProfile::GetRawInfo(AutofillFieldType type) const { |
280 AutofillFieldType return_type = AutofillType::GetEquivalentFieldType(type); | 276 AutofillFieldType return_type = AutofillType::GetEquivalentFieldType(type); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 int comparison = values_a[j].compare(values_b[j]); | 447 int comparison = values_a[j].compare(values_b[j]); |
452 if (comparison != 0) | 448 if (comparison != 0) |
453 return comparison; | 449 return comparison; |
454 } | 450 } |
455 } | 451 } |
456 | 452 |
457 return 0; | 453 return 0; |
458 } | 454 } |
459 | 455 |
460 bool AutofillProfile::operator==(const AutofillProfile& profile) const { | 456 bool AutofillProfile::operator==(const AutofillProfile& profile) const { |
461 return guid_ == profile.guid_ && Compare(profile) == 0; | 457 return guid() == profile.guid() && Compare(profile) == 0; |
462 } | 458 } |
463 | 459 |
464 bool AutofillProfile::operator!=(const AutofillProfile& profile) const { | 460 bool AutofillProfile::operator!=(const AutofillProfile& profile) const { |
465 return !operator==(profile); | 461 return !operator==(profile); |
466 } | 462 } |
467 | 463 |
468 const base::string16 AutofillProfile::PrimaryValue() const { | 464 const base::string16 AutofillProfile::PrimaryValue() const { |
469 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); | 465 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); |
470 } | 466 } |
471 | 467 |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) | 850 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) |
855 << " " | 851 << " " |
856 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) | 852 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) |
857 << " " | 853 << " " |
858 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) | 854 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) |
859 << " " | 855 << " " |
860 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); | 856 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); |
861 } | 857 } |
862 | 858 |
863 } // namespace autofill | 859 } // namespace autofill |
OLD | NEW |