Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: components/autofill/core/browser/autofill_profile.cc

Issue 970403002: Don't suggest autofill profiles that are subsets of other profiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 return !operator==(profile); 558 return !operator==(profile);
559 } 559 }
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 GetSupportedTypes(&types);
569 return IsSubsetOfForFieldSet(profile, app_locale, types);
570 }
569 571
572 bool AutofillProfile::IsSubsetOfForFieldSet(
573 const AutofillProfile& profile,
574 const std::string& app_locale,
575 const ServerFieldTypeSet& types) const {
570 for (ServerFieldType type : types) { 576 for (ServerFieldType type : types) {
577 base::string16 value = GetRawInfo(type);
578 if (value.empty())
579 continue;
580
571 if (type == NAME_FULL || type == ADDRESS_HOME_STREET_ADDRESS) { 581 if (type == NAME_FULL || type == ADDRESS_HOME_STREET_ADDRESS) {
572 // Ignore the compound "full name" field type. We are only interested in 582 // Ignore the compound "full name" field type. We are only interested in
573 // comparing the constituent parts. For example, if |this| has a middle 583 // comparing the constituent parts. For example, if |this| has a middle
574 // name saved, but |profile| lacks one, |profile| could still be a subset 584 // name saved, but |profile| lacks one, |profile| could still be a subset
575 // of |this|. Likewise, ignore the compound "street address" type, as we 585 // of |this|. Likewise, ignore the compound "street address" type, as we
576 // are only interested in matching line-by-line. 586 // are only interested in matching line-by-line.
577 continue; 587 continue;
578 } else if (AutofillType(type).group() == PHONE_HOME) { 588 } else if (AutofillType(type).group() == PHONE_HOME) {
579 // Phone numbers should be canonicalized prior to being compared. 589 // Phone numbers should be canonicalized prior to being compared.
580 if (type != PHONE_HOME_WHOLE_NUMBER) { 590 if (type != PHONE_HOME_WHOLE_NUMBER) {
581 continue; 591 continue;
582 } else if (!i18n::PhoneNumbersMatch( 592 } else if (!i18n::PhoneNumbersMatch(
583 GetRawInfo(type), profile.GetRawInfo(type), 593 value, profile.GetRawInfo(type),
584 base::UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)), 594 base::UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)),
585 app_locale)) { 595 app_locale)) {
586 return false; 596 return false;
587 } 597 }
588 } else if (base::StringToLowerASCII(GetRawInfo(type)) != 598 } else if (base::StringToLowerASCII(value) !=
589 base::StringToLowerASCII(profile.GetRawInfo(type))) { 599 base::StringToLowerASCII(profile.GetRawInfo(type))) {
590 return false; 600 return false;
591 } 601 }
592 } 602 }
593 603
594 return true; 604 return true;
595 } 605 }
596 606
597 void AutofillProfile::CopyAndUpdateNameList( 607 void AutofillProfile::CopyAndUpdateNameList(
598 const std::vector<base::string16> names, 608 const std::vector<base::string16> names,
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) 1153 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE))
1144 << " " 1154 << " "
1145 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) 1155 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY))
1146 << " " 1156 << " "
1147 << profile.language_code() 1157 << profile.language_code()
1148 << " " 1158 << " "
1149 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); 1159 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER));
1150 } 1160 }
1151 1161
1152 } // namespace autofill 1162 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_profile.h ('k') | components/autofill/core/browser/personal_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698