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

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

Issue 1989173005: [Autofill] Dedupe similar profiles on insertion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 6 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 <memory> 10 #include <memory>
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 424 }
425 425
426 bool AutofillProfile::operator==(const AutofillProfile& profile) const { 426 bool AutofillProfile::operator==(const AutofillProfile& profile) const {
427 return guid() == profile.guid() && EqualsSansGuid(profile); 427 return guid() == profile.guid() && EqualsSansGuid(profile);
428 } 428 }
429 429
430 bool AutofillProfile::operator!=(const AutofillProfile& profile) const { 430 bool AutofillProfile::operator!=(const AutofillProfile& profile) const {
431 return !operator==(profile); 431 return !operator==(profile);
432 } 432 }
433 433
434 const base::string16 AutofillProfile::PrimaryValue() const { 434 const base::string16 AutofillProfile::PrimaryValue(
435 return GetRawInfo(NAME_FIRST) + GetRawInfo(NAME_LAST) + 435 const std::string& app_locale) const {
436 GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); 436 std::vector<base::string16> primary_values{
437 CanonicalizeProfileString(GetInfo(AutofillType(NAME_FIRST), app_locale)),
438 CanonicalizeProfileString(GetInfo(AutofillType(NAME_LAST), app_locale)),
439 CanonicalizeProfileString(
440 GetInfo(AutofillType(ADDRESS_HOME_LINE1), app_locale)),
441 CanonicalizeProfileString(
442 GetInfo(AutofillType(ADDRESS_HOME_CITY), app_locale))};
443 return base::JoinString(primary_values, base::UTF8ToUTF16(" "));
Roger McFarlane (Chromium) 2016/06/13 15:12:52 Do the join first and canonicalize after. i.e.:
sebsg 2016/06/13 17:57:59 Done.
437 } 444 }
438 445
439 bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile, 446 bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile,
440 const std::string& app_locale) const { 447 const std::string& app_locale) const {
441 ServerFieldTypeSet types; 448 ServerFieldTypeSet types;
442 GetSupportedTypes(&types); 449 GetSupportedTypes(&types);
443 return IsSubsetOfForFieldSet(profile, app_locale, types); 450 return IsSubsetOfForFieldSet(profile, app_locale, types);
444 } 451 }
445 452
446 bool AutofillProfile::IsSubsetOfForFieldSet( 453 bool AutofillProfile::IsSubsetOfForFieldSet(
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " " 1091 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " "
1085 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " " 1092 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " "
1086 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " " 1093 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " "
1087 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " " 1094 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " "
1088 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " " 1095 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " "
1089 << profile.language_code() << " " 1096 << profile.language_code() << " "
1090 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 1097 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
1091 } 1098 }
1092 1099
1093 } // namespace autofill 1100 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698