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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 | 776 |
| 777 void CreditCard::SetNumber(const base::string16& number) { | 777 void CreditCard::SetNumber(const base::string16& number) { |
| 778 number_ = number; | 778 number_ = number; |
| 779 | 779 |
| 780 // Set the type based on the card number, but only for full numbers, not | 780 // Set the type based on the card number, but only for full numbers, not |
| 781 // when we have masked cards from the server (last 4 digits). | 781 // when we have masked cards from the server (last 4 digits). |
| 782 if (record_type_ != MASKED_SERVER_CARD) | 782 if (record_type_ != MASKED_SERVER_CARD) |
| 783 type_ = GetCreditCardType(StripSeparators(number_)); | 783 type_ = GetCreditCardType(StripSeparators(number_)); |
| 784 } | 784 } |
| 785 | 785 |
| 786 base::string16 CreditCard::LastUsedDateAsString() const { | |
| 787 base::Time::Exploded exploded; | |
| 788 use_date().LocalExplode(&exploded); | |
| 789 base::string16 month = FormatDateTo2Digit(exploded.month); | |
| 790 base::string16 day_of_month = FormatDateTo2Digit(exploded.day_of_month); | |
| 791 base::string16 hour = FormatDateTo2Digit(exploded.hour); | |
| 792 base::string16 minute = FormatDateTo2Digit(exploded.minute); | |
|
csashi
2017/01/03 20:54:06
You do not need hour and minutes unless use_count(
jiahuiguo
2017/01/18 00:13:44
Good point!
| |
| 793 return use_count() > 1 | |
| 794 ? l10n_util::GetStringFUTF16( | |
| 795 IDS_AUTOFILL_CREDIT_CARD_LAST_USED_DATE_LABEL, | |
| 796 month, | |
| 797 day_of_month, | |
| 798 hour, | |
| 799 minute) | |
| 800 : l10n_util::GetStringFUTF16( | |
| 801 IDS_AUTOFILL_CREDIT_CARD_ADDED_TO_CHROME_DATE_LABEL, | |
| 802 month, | |
| 803 day_of_month); | |
| 804 } | |
| 805 | |
| 806 base::string16 CreditCard::FormatDateTo2Digit(int date_info) const { | |
| 807 DCHECK(date_info > 0); | |
| 808 base::string16 dateIn2Digit = base::IntToString16(date_info); | |
| 809 if (date_info >= 10) | |
| 810 return dateIn2Digit; | |
| 811 | |
| 812 base::string16 zero = ASCIIToUTF16("0"); | |
| 813 zero.append(dateIn2Digit); | |
| 814 return zero; | |
|
csashi
2017/01/03 20:54:06
You are not returning zero. May be call this padde
jiahuiguo
2017/01/18 00:13:44
Done.
| |
| 815 } | |
| 816 | |
| 786 void CreditCard::RecordAndLogUse() { | 817 void CreditCard::RecordAndLogUse() { |
| 787 UMA_HISTOGRAM_COUNTS_1000("Autofill.DaysSinceLastUse.CreditCard", | 818 UMA_HISTOGRAM_COUNTS_1000("Autofill.DaysSinceLastUse.CreditCard", |
| 788 (base::Time::Now() - use_date()).InDays()); | 819 (base::Time::Now() - use_date()).InDays()); |
| 789 RecordUse(); | 820 RecordUse(); |
| 790 } | 821 } |
| 791 | 822 |
| 792 // static | 823 // static |
| 793 bool CreditCard::ConvertMonth(const base::string16& month, | 824 bool CreditCard::ConvertMonth(const base::string16& month, |
| 794 const std::string& app_locale, | 825 const std::string& app_locale, |
| 795 int* num) { | 826 int* num) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 const char kDinersCard[] = "dinersCC"; | 903 const char kDinersCard[] = "dinersCC"; |
| 873 const char kDiscoverCard[] = "discoverCC"; | 904 const char kDiscoverCard[] = "discoverCC"; |
| 874 const char kGenericCard[] = "genericCC"; | 905 const char kGenericCard[] = "genericCC"; |
| 875 const char kJCBCard[] = "jcbCC"; | 906 const char kJCBCard[] = "jcbCC"; |
| 876 const char kMasterCard[] = "masterCardCC"; | 907 const char kMasterCard[] = "masterCardCC"; |
| 877 const char kMirCard[] = "mirCC"; | 908 const char kMirCard[] = "mirCC"; |
| 878 const char kUnionPay[] = "unionPayCC"; | 909 const char kUnionPay[] = "unionPayCC"; |
| 879 const char kVisaCard[] = "visaCC"; | 910 const char kVisaCard[] = "visaCC"; |
| 880 | 911 |
| 881 } // namespace autofill | 912 } // namespace autofill |
| OLD | NEW |