Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 switch (record_type()) { | |
| 791 case LOCAL_CARD: | |
| 792 return IsExpired(current_time); | |
| 793 case MASKED_SERVER_CARD: | |
| 794 case FULL_SERVER_CARD: | |
| 795 return server_status_ == EXPIRED || IsExpired(current_time); | |
|
Mathieu
2016/04/27 19:54:50
looks like this function could be replaced with
r
please use gerrit instead
2016/04/28 00:30:24
Done.
| |
| 796 } | |
| 797 NOTREACHED(); | |
| 798 return false; | |
| 799 } | |
| 800 | |
| 789 // So we can compare CreditCards with EXPECT_EQ(). | 801 // So we can compare CreditCards with EXPECT_EQ(). |
| 790 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) { | 802 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card) { |
| 791 return os << base::UTF16ToUTF8(credit_card.Label()) << " " | 803 return os << base::UTF16ToUTF8(credit_card.Label()) << " " |
| 792 << credit_card.guid() << " " << credit_card.origin() << " " | 804 << credit_card.guid() << " " << credit_card.origin() << " " |
| 793 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NAME_FULL)) | 805 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NAME_FULL)) |
| 794 << " " | 806 << " " |
| 795 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_TYPE)) | 807 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_TYPE)) |
| 796 << " " | 808 << " " |
| 797 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NUMBER)) | 809 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_NUMBER)) |
| 798 << " " | 810 << " " |
| 799 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_EXP_MONTH)) | 811 << base::UTF16ToUTF8(credit_card.GetRawInfo(CREDIT_CARD_EXP_MONTH)) |
| 800 << " " << base::UTF16ToUTF8( | 812 << " " << base::UTF16ToUTF8( |
| 801 credit_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 813 credit_card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 802 } | 814 } |
| 803 | 815 |
| 804 // These values must match the values in WebKitPlatformSupportImpl in | 816 // These values must match the values in WebKitPlatformSupportImpl in |
| 805 // webkit/glue. We send these strings to WebKit, which then asks | 817 // webkit/glue. We send these strings to WebKit, which then asks |
| 806 // WebKitPlatformSupportImpl to load the image data. | 818 // WebKitPlatformSupportImpl to load the image data. |
| 807 const char kAmericanExpressCard[] = "americanExpressCC"; | 819 const char kAmericanExpressCard[] = "americanExpressCC"; |
| 808 const char kDinersCard[] = "dinersCC"; | 820 const char kDinersCard[] = "dinersCC"; |
| 809 const char kDiscoverCard[] = "discoverCC"; | 821 const char kDiscoverCard[] = "discoverCC"; |
| 810 const char kGenericCard[] = "genericCC"; | 822 const char kGenericCard[] = "genericCC"; |
| 811 const char kJCBCard[] = "jcbCC"; | 823 const char kJCBCard[] = "jcbCC"; |
| 812 const char kMasterCard[] = "masterCardCC"; | 824 const char kMasterCard[] = "masterCardCC"; |
| 813 const char kUnionPay[] = "unionPayCC"; | 825 const char kUnionPay[] = "unionPayCC"; |
| 814 const char kVisaCard[] = "visaCC"; | 826 const char kVisaCard[] = "visaCC"; |
| 815 | 827 |
| 816 } // namespace autofill | 828 } // namespace autofill |
| OLD | NEW |