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

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

Issue 1926553002: Prompt for expiration date for local cards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify the test cases 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/credit_card.h" 5 #include "components/autofill/core/browser/credit_card.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 } 779 }
780 780
781 return false; 781 return false;
782 } 782 }
783 783
784 bool CreditCard::IsExpired(const base::Time& current_time) const { 784 bool CreditCard::IsExpired(const base::Time& current_time) const {
785 return !IsValidCreditCardExpirationDate(expiration_year_, expiration_month_, 785 return !IsValidCreditCardExpirationDate(expiration_year_, expiration_month_,
786 current_time); 786 current_time);
787 } 787 }
788 788
789 bool CreditCard::ShouldUpdateExpiration(const base::Time& current_time) const {
790 // Local cards always have OK server status.
791 DCHECK(server_status_ == OK || record_type_ != LOCAL_CARD);
792 return server_status_ == EXPIRED || IsExpired(current_time);
793 }
794
789 // So we can compare CreditCards with EXPECT_EQ(). 795 // So we can compare CreditCards with EXPECT_EQ().
790 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) { 796 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) {
791 return os << base::UTF16ToUTF8(credit_card.Label()) << " " 797 return os << base::UTF16ToUTF8(credit_card.Label()) << " "
792 << credit_card.guid() << " " << credit_card.origin() << " " 798 << credit_card.guid() << " " << credit_card.origin() << " "
793 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NAME_FULL)) 799 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NAME_FULL))
794 << " " 800 << " "
795 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_TYPE)) 801 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_TYPE))
796 << " " 802 << " "
797 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NUMBER)) 803 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NUMBER))
798 << " " 804 << " "
799 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_EXP_MONTH)) 805 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_EXP_MONTH))
800 << " " << base::UTF16ToUTF8( 806 << " " << base::UTF16ToUTF8(
801 credit_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); 807 credit_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
802 } 808 }
803 809
804 // These values must match the values in WebKitPlatformSupportImpl in 810 // These values must match the values in WebKitPlatformSupportImpl in
805 // webkit/glue. We send these strings to WebKit, which then asks 811 // webkit/glue. We send these strings to WebKit, which then asks
806 // WebKitPlatformSupportImpl to load the image data. 812 // WebKitPlatformSupportImpl to load the image data.
807 const char kAmericanExpressCard[] = "americanExpressCC"; 813 const char kAmericanExpressCard[] = "americanExpressCC";
808 const char kDinersCard[] = "dinersCC"; 814 const char kDinersCard[] = "dinersCC";
809 const char kDiscoverCard[] = "discoverCC"; 815 const char kDiscoverCard[] = "discoverCC";
810 const char kGenericCard[] = "genericCC"; 816 const char kGenericCard[] = "genericCC";
811 const char kJCBCard[] = "jcbCC"; 817 const char kJCBCard[] = "jcbCC";
812 const char kMasterCard[] = "masterCardCC"; 818 const char kMasterCard[] = "masterCardCC";
813 const char kUnionPay[] = "unionPayCC"; 819 const char kUnionPay[] = "unionPayCC";
814 const char kVisaCard[] = "visaCC"; 820 const char kVisaCard[] = "visaCC";
815 821
816 } // namespace autofill 822 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/credit_card.h ('k') | components/autofill/core/browser/credit_card_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698