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

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

Issue 2164143002: Use the max use count on autofill profile merge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_profile_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 !comparator.MergeEmailAddresses(profile, *this, &email) || 457 !comparator.MergeEmailAddresses(profile, *this, &email) ||
458 !comparator.MergeCompanyNames(profile, *this, &company) || 458 !comparator.MergeCompanyNames(profile, *this, &company) ||
459 !comparator.MergePhoneNumbers(profile, *this, &phone_number) || 459 !comparator.MergePhoneNumbers(profile, *this, &phone_number) ||
460 !comparator.MergeAddresses(profile, *this, &address)) { 460 !comparator.MergeAddresses(profile, *this, &address)) {
461 NOTREACHED(); 461 NOTREACHED();
462 return false; 462 return false;
463 } 463 }
464 464
465 set_origin(profile.origin()); 465 set_origin(profile.origin());
466 set_language_code(profile.language_code()); 466 set_language_code(profile.language_code());
467 set_use_count(profile.use_count() + use_count()); 467 set_use_count(std::max(profile.use_count(), use_count()));
Mathieu 2016/07/21 19:16:01 Let's add the rationale for the future reader!
Roger McFarlane (Chromium) 2016/07/22 01:15:25 Done.
468 if (profile.use_date() > use_date()) 468 set_use_date(std::max(profile.use_date(), use_date()));
469 set_use_date(profile.use_date());
470 469
471 // Now that the preferred values have been obtained, update the fields which 470 // Now that the preferred values have been obtained, update the fields which
472 // need to be modified, if any. Note: that we're comparing the fields for 471 // need to be modified, if any. Note: that we're comparing the fields for
473 // representational equality below (i.e., are the values byte for byte the 472 // representational equality below (i.e., are the values byte for byte the
474 // same). 473 // same).
475 474
476 bool modified = false; 475 bool modified = false;
477 476
478 if (name_ != name) { 477 if (name_ != name) {
479 name_ = name; 478 name_ = name;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " " 845 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " "
847 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " " 846 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " "
848 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " " 847 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " "
849 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " " 848 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " "
850 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " " 849 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " "
851 << profile.language_code() << " " 850 << profile.language_code() << " "
852 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 851 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
853 } 852 }
854 853
855 } // namespace autofill 854 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_profile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698