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

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

Issue 1885773002: [Autofill] Don't fill expiration date of expired credit cards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 4 years, 8 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 | « components/autofill/core/browser/credit_card.cc ('k') | no next file » | 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/personal_data_manager.h" 5 #include "components/autofill/core/browser/personal_data_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 std::list<const CreditCard*> cards_to_suggest(credit_cards.begin(), 800 std::list<const CreditCard*> cards_to_suggest(credit_cards.begin(),
801 credit_cards.end()); 801 credit_cards.end());
802 802
803 DedupeCreditCardToSuggest(&cards_to_suggest); 803 DedupeCreditCardToSuggest(&cards_to_suggest);
804 804
805 // Rank the cards by frecency (see AutofillDataModel for details). All expired 805 // Rank the cards by frecency (see AutofillDataModel for details). All expired
806 // cards should be suggested last, also by frecency. 806 // cards should be suggested last, also by frecency.
807 base::Time comparison_time = base::Time::Now(); 807 base::Time comparison_time = base::Time::Now();
808 cards_to_suggest.sort( 808 cards_to_suggest.sort(
809 [comparison_time](const CreditCard* a, const CreditCard* b) { 809 [comparison_time](const CreditCard* a, const CreditCard* b) {
810 bool a_has_valid_expiration = IsValidCreditCardExpirationDate( 810 bool a_is_expired = a->IsExpired(comparison_time);
811 a->expiration_year(), a->expiration_month(), comparison_time); 811 if (a_is_expired != b->IsExpired(comparison_time))
812 if (a_has_valid_expiration != 812 return !a_is_expired;
813 IsValidCreditCardExpirationDate(
814 b->expiration_year(), b->expiration_month(), comparison_time))
815 return a_has_valid_expiration;
816 813
817 return a->CompareFrecency(b, comparison_time); 814 return a->CompareFrecency(b, comparison_time);
818 }); 815 });
819 816
820 return GetSuggestionsForCards(type, field_contents, cards_to_suggest); 817 return GetSuggestionsForCards(type, field_contents, cards_to_suggest);
821 } 818 }
822 819
823 bool PersonalDataManager::IsAutofillEnabled() const { 820 bool PersonalDataManager::IsAutofillEnabled() const {
824 return ::autofill::IsAutofillEnabled(pref_service_); 821 return ::autofill::IsAutofillEnabled(pref_service_);
825 } 822 }
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 std::stable_sort(suggestions.begin(), suggestions.end(), 1499 std::stable_sort(suggestions.begin(), suggestions.end(),
1503 [](const Suggestion& a, const Suggestion& b) { 1500 [](const Suggestion& a, const Suggestion& b) {
1504 return a.match < b.match; 1501 return a.match < b.match;
1505 }); 1502 });
1506 } 1503 }
1507 1504
1508 return suggestions; 1505 return suggestions;
1509 } 1506 }
1510 1507
1511 } // namespace autofill 1508 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/credit_card.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698