| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 // Functor used to check for case-insensitive equality of two strings. | 226 // Functor used to check for case-insensitive equality of two strings. |
| 227 struct CaseInsensitiveStringEquals { | 227 struct CaseInsensitiveStringEquals { |
| 228 public: | 228 public: |
| 229 CaseInsensitiveStringEquals(const base::string16& other) | 229 CaseInsensitiveStringEquals(const base::string16& other) |
| 230 : other_(other) {} | 230 : other_(other) {} |
| 231 | 231 |
| 232 bool operator()(const base::string16& x) const { | 232 bool operator()(const base::string16& x) const { |
| 233 return x.size() == other_.size() && | 233 return x.size() == other_.size() && |
| 234 StringToLowerASCII(x) == StringToLowerASCII(other_); | 234 base::StringToLowerASCII(x) == base::StringToLowerASCII(other_); |
| 235 } | 235 } |
| 236 | 236 |
| 237 private: | 237 private: |
| 238 const base::string16& other_; | 238 const base::string16& other_; |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 } // namespace | 241 } // namespace |
| 242 | 242 |
| 243 AutofillProfile::AutofillProfile(const std::string& guid, | 243 AutofillProfile::AutofillProfile(const std::string& guid, |
| 244 const std::string& origin) | 244 const std::string& origin) |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 // Phone numbers should be canonicalized prior to being compared. | 549 // Phone numbers should be canonicalized prior to being compared. |
| 550 if (*it != PHONE_HOME_WHOLE_NUMBER) { | 550 if (*it != PHONE_HOME_WHOLE_NUMBER) { |
| 551 continue; | 551 continue; |
| 552 } else if (!i18n::PhoneNumbersMatch( | 552 } else if (!i18n::PhoneNumbersMatch( |
| 553 GetRawInfo(*it), | 553 GetRawInfo(*it), |
| 554 profile.GetRawInfo(*it), | 554 profile.GetRawInfo(*it), |
| 555 base::UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)), | 555 base::UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)), |
| 556 app_locale)) { | 556 app_locale)) { |
| 557 return false; | 557 return false; |
| 558 } | 558 } |
| 559 } else if (StringToLowerASCII(GetRawInfo(*it)) != | 559 } else if (base::StringToLowerASCII(GetRawInfo(*it)) != |
| 560 StringToLowerASCII(profile.GetRawInfo(*it))) { | 560 base::StringToLowerASCII(profile.GetRawInfo(*it))) { |
| 561 return false; | 561 return false; |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 | 564 |
| 565 return true; | 565 return true; |
| 566 } | 566 } |
| 567 | 567 |
| 568 void AutofillProfile::OverwriteOrAppendNames( | 568 void AutofillProfile::OverwriteOrAppendNames( |
| 569 const std::vector<NameInfo>& names, | 569 const std::vector<NameInfo>& names, |
| 570 const std::string& app_locale) { | 570 const std::string& app_locale) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 582 current_name.SetRawInfo(NAME_FULL, | 582 current_name.SetRawInfo(NAME_FULL, |
| 583 imported_name.GetRawInfo(NAME_FULL)); | 583 imported_name.GetRawInfo(NAME_FULL)); |
| 584 } | 584 } |
| 585 | 585 |
| 586 should_append_imported_name = false; | 586 should_append_imported_name = false; |
| 587 break; | 587 break; |
| 588 } | 588 } |
| 589 | 589 |
| 590 AutofillType type = AutofillType(NAME_FULL); | 590 AutofillType type = AutofillType(NAME_FULL); |
| 591 base::string16 full_name = current_name.GetInfo(type, app_locale); | 591 base::string16 full_name = current_name.GetInfo(type, app_locale); |
| 592 if (StringToLowerASCII(full_name) == | 592 if (base::StringToLowerASCII(full_name) == |
| 593 StringToLowerASCII(imported_name.GetInfo(type, app_locale))) { | 593 base::StringToLowerASCII(imported_name.GetInfo(type, app_locale))) { |
| 594 // The imported name has the same full name string as one of the | 594 // The imported name has the same full name string as one of the |
| 595 // existing names for this profile. Because full names are | 595 // existing names for this profile. Because full names are |
| 596 // _heuristically_ parsed into {first, middle, last} name components, | 596 // _heuristically_ parsed into {first, middle, last} name components, |
| 597 // it's possible that either the existing name or the imported name | 597 // it's possible that either the existing name or the imported name |
| 598 // was misparsed. Prefer to keep the name whose {first, middle, | 598 // was misparsed. Prefer to keep the name whose {first, middle, |
| 599 // last} components do not match those computed by the heuristic | 599 // last} components do not match those computed by the heuristic |
| 600 // parse, as this more likely represents the correct, user-input parse | 600 // parse, as this more likely represents the correct, user-input parse |
| 601 // of the name. | 601 // of the name. |
| 602 NameInfo heuristically_parsed_name; | 602 NameInfo heuristically_parsed_name; |
| 603 heuristically_parsed_name.SetInfo(type, full_name, app_locale); | 603 heuristically_parsed_name.SetInfo(type, full_name, app_locale); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 FieldTypeGroup group = AutofillType(*iter).group(); | 647 FieldTypeGroup group = AutofillType(*iter).group(); |
| 648 // Special case names. | 648 // Special case names. |
| 649 if (group == NAME) { | 649 if (group == NAME) { |
| 650 OverwriteOrAppendNames(profile.name_, app_locale); | 650 OverwriteOrAppendNames(profile.name_, app_locale); |
| 651 continue; | 651 continue; |
| 652 } | 652 } |
| 653 | 653 |
| 654 // Single value field --- overwrite. | 654 // Single value field --- overwrite. |
| 655 if (!AutofillProfile::SupportsMultiValue(*iter)) { | 655 if (!AutofillProfile::SupportsMultiValue(*iter)) { |
| 656 base::string16 new_value = profile.GetRawInfo(*iter); | 656 base::string16 new_value = profile.GetRawInfo(*iter); |
| 657 if (StringToLowerASCII(GetRawInfo(*iter)) != | 657 if (base::StringToLowerASCII(GetRawInfo(*iter)) != |
| 658 StringToLowerASCII(new_value)) { | 658 base::StringToLowerASCII(new_value)) { |
| 659 SetRawInfo(*iter, new_value); | 659 SetRawInfo(*iter, new_value); |
| 660 } | 660 } |
| 661 continue; | 661 continue; |
| 662 } | 662 } |
| 663 | 663 |
| 664 // Multi value field --- overwrite/append. | 664 // Multi value field --- overwrite/append. |
| 665 std::vector<base::string16> new_values; | 665 std::vector<base::string16> new_values; |
| 666 profile.GetRawMultiInfo(*iter, &new_values); | 666 profile.GetRawMultiInfo(*iter, &new_values); |
| 667 std::vector<base::string16> existing_values; | 667 std::vector<base::string16> existing_values; |
| 668 GetRawMultiInfo(*iter, &existing_values); | 668 GetRawMultiInfo(*iter, &existing_values); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) | 981 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) |
| 982 << " " | 982 << " " |
| 983 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) | 983 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) |
| 984 << " " | 984 << " " |
| 985 << profile.language_code() | 985 << profile.language_code() |
| 986 << " " | 986 << " " |
| 987 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); | 987 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); |
| 988 } | 988 } |
| 989 | 989 |
| 990 } // namespace autofill | 990 } // namespace autofill |
| OLD | NEW |