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

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

Issue 1931123002: [Autofill] Make PersonalDataManager::OverwriteWith case sensitive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 bool AutofillProfile::OverwriteWith(const AutofillProfile& profile, 518 bool AutofillProfile::OverwriteWith(const AutofillProfile& profile,
519 const std::string& app_locale) { 519 const std::string& app_locale) {
520 // Verified profiles should never be overwritten with unverified data. 520 // Verified profiles should never be overwritten with unverified data.
521 DCHECK(!IsVerified() || profile.IsVerified()); 521 DCHECK(!IsVerified() || profile.IsVerified());
522 set_origin(profile.origin()); 522 set_origin(profile.origin());
523 set_language_code(profile.language_code()); 523 set_language_code(profile.language_code());
524 set_use_count(profile.use_count() + use_count()); 524 set_use_count(profile.use_count() + use_count());
525 if (profile.use_date() > use_date()) 525 if (profile.use_date() > use_date())
526 set_use_date(profile.use_date()); 526 set_use_date(profile.use_date());
527 527
528 ServerFieldTypeSet field_types; 528 ServerFieldTypeSet field_types;
Mathieu 2016/04/29 12:18:43 add a comment about |field_types|. Perhaps rename
sebsg 2016/04/29 15:04:49 Done.
529 profile.GetNonEmptyTypes(app_locale, &field_types); 529 profile.GetNonEmptyTypes(app_locale, &field_types);
530 530
531 // Only transfer "full" types (e.g. full name) and not fragments (e.g. 531 // Only transfer "full" types (e.g. full name) and not fragments (e.g.
532 // first name, last name). 532 // first name, last name).
533 CollapseCompoundFieldTypes(&field_types); 533 CollapseCompoundFieldTypes(&field_types);
534 534
535 // Remove ADDRESS_HOME_STREET_ADDRESS to ensure a merge of the address line by 535 // Remove ADDRESS_HOME_STREET_ADDRESS to ensure a merge of the address line by
536 // line. See comment below. 536 // line. See comment below.
537 field_types.erase(ADDRESS_HOME_STREET_ADDRESS); 537 field_types.erase(ADDRESS_HOME_STREET_ADDRESS);
538 538
(...skipping 13 matching lines...) Expand all
552 field_types.erase(ADDRESS_HOME_LINE2); 552 field_types.erase(ADDRESS_HOME_LINE2);
553 } 553 }
554 554
555 bool did_overwrite = false; 555 bool did_overwrite = false;
556 556
557 for (ServerFieldTypeSet::const_iterator iter = field_types.begin(); 557 for (ServerFieldTypeSet::const_iterator iter = field_types.begin();
558 iter != field_types.end(); ++iter) { 558 iter != field_types.end(); ++iter) {
559 FieldTypeGroup group = AutofillType(*iter).group(); 559 FieldTypeGroup group = AutofillType(*iter).group();
560 560
561 // Special case names. 561 // Special case names.
562 if (group == NAME) { 562 if (group == NAME) {
Mathieu 2016/04/29 12:18:43 nit: inline AutofillType(*iter).group() here
sebsg 2016/04/29 15:04:49 Done.
563 did_overwrite = OverwriteName(profile.name_, app_locale) || did_overwrite; 563 did_overwrite = OverwriteName(profile.name_, app_locale) || did_overwrite;
Mathieu 2016/04/29 12:18:43 seems like we are going to run OverwriteName for a
Mathieu 2016/04/29 12:18:43 optional nit: did_overwrite |= OverwriteName(...)
sebsg 2016/04/29 15:04:49 Done.
sebsg 2016/04/29 15:04:49 CollapseCompoundFieldTypes makes sure we only over
564 continue; 564 continue;
565 } 565 }
566 566
567 base::string16 new_value = profile.GetRawInfo(*iter); 567 base::string16 new_value = profile.GetRawInfo(*iter);
Mathieu 2016/04/29 12:18:43 Add a comment: // Overwrite the data in |this| pro
sebsg 2016/04/29 15:04:48 Done.
568 if (!compare.StringsEqual(GetRawInfo(*iter), new_value)) { 568 if (GetRawInfo(*iter) != new_value) {
569 SetRawInfo(*iter, new_value); 569 SetRawInfo(*iter, new_value);
570 did_overwrite = true; 570 did_overwrite = true;
571 } 571 }
572 } 572 }
573 573
574 return did_overwrite; 574 return did_overwrite;
575 } 575 }
576 576
577 bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile, 577 bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile,
578 const std::string& app_locale) { 578 const std::string& app_locale) {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " " 1050 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " "
1051 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " " 1051 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " "
1052 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " " 1052 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " "
1053 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " " 1053 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " "
1054 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " " 1054 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " "
1055 << profile.language_code() << " " 1055 << profile.language_code() << " "
1056 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 1056 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
1057 } 1057 }
1058 1058
1059 } // namespace autofill 1059 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698