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/autofill_profile.h" | 5 #include "components/autofill/core/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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 | 560 |
561 const base::string16 AutofillProfile::PrimaryValue() const { | 561 const base::string16 AutofillProfile::PrimaryValue() const { |
562 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); | 562 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); |
563 } | 563 } |
564 | 564 |
565 bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile, | 565 bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile, |
566 const std::string& app_locale) const { | 566 const std::string& app_locale) const { |
567 ServerFieldTypeSet types; | 567 ServerFieldTypeSet types; |
568 GetNonEmptyTypes(app_locale, &types); | 568 GetNonEmptyTypes(app_locale, &types); |
569 | 569 |
570 for (ServerFieldTypeSet::const_iterator it = types.begin(); it != types.end(); | 570 for (ServerFieldType type : types) { |
571 ++it) { | 571 if (type == NAME_FULL || type == ADDRESS_HOME_STREET_ADDRESS) { |
572 if (*it == NAME_FULL || *it == ADDRESS_HOME_STREET_ADDRESS) { | |
573 // Ignore the compound "full name" field type. We are only interested in | 572 // Ignore the compound "full name" field type. We are only interested in |
574 // comparing the constituent parts. For example, if |this| has a middle | 573 // comparing the constituent parts. For example, if |this| has a middle |
575 // name saved, but |profile| lacks one, |profile| could still be a subset | 574 // name saved, but |profile| lacks one, |profile| could still be a subset |
576 // of |this|. Likewise, ignore the compound "street address" type, as we | 575 // of |this|. Likewise, ignore the compound "street address" type, as we |
577 // are only interested in matching line-by-line. | 576 // are only interested in matching line-by-line. |
578 continue; | 577 continue; |
579 } else if (AutofillType(*it).group() == PHONE_HOME) { | 578 } else if (AutofillType(type).group() == PHONE_HOME) { |
580 // Phone numbers should be canonicalized prior to being compared. | 579 // Phone numbers should be canonicalized prior to being compared. |
581 if (*it != PHONE_HOME_WHOLE_NUMBER) { | 580 if (type != PHONE_HOME_WHOLE_NUMBER) { |
582 continue; | 581 continue; |
583 } else if (!i18n::PhoneNumbersMatch( | 582 } else if (!i18n::PhoneNumbersMatch( |
584 GetRawInfo(*it), | 583 GetRawInfo(type), profile.GetRawInfo(type), |
585 profile.GetRawInfo(*it), | 584 base::UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)), |
586 base::UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)), | 585 app_locale)) { |
587 app_locale)) { | |
588 return false; | 586 return false; |
589 } | 587 } |
590 } else if (base::StringToLowerASCII(GetRawInfo(*it)) != | 588 } else if (base::StringToLowerASCII(GetRawInfo(type)) != |
591 base::StringToLowerASCII(profile.GetRawInfo(*it))) { | 589 base::StringToLowerASCII(profile.GetRawInfo(type))) { |
592 return false; | 590 return false; |
593 } | 591 } |
594 } | 592 } |
595 | 593 |
596 return true; | 594 return true; |
597 } | 595 } |
598 | 596 |
599 void AutofillProfile::CopyAndUpdateNameList( | 597 void AutofillProfile::CopyAndUpdateNameList( |
600 const std::vector<base::string16> names, | 598 const std::vector<base::string16> names, |
601 const AutofillProfile* from, | 599 const AutofillProfile* from, |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) | 1143 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) |
1146 << " " | 1144 << " " |
1147 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) | 1145 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) |
1148 << " " | 1146 << " " |
1149 << profile.language_code() | 1147 << profile.language_code() |
1150 << " " | 1148 << " " |
1151 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); | 1149 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); |
1152 } | 1150 } |
1153 | 1151 |
1154 } // namespace autofill | 1152 } // namespace autofill |
OLD | NEW |