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

Unified Diff: components/autofill/core/browser/credit_card.cc

Issue 2607043002: [Autofill] Credit Card Autofill Last Used Date Experiment (Closed)
Patch Set: Show expiration date if keyboard accessory is enabled Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/credit_card.cc
diff --git a/components/autofill/core/browser/credit_card.cc b/components/autofill/core/browser/credit_card.cc
index 3b402eae9e873dbb85ae52383d1ebaa1a1e4d2bd..a49e75b3e98776494b5932b992f65aa1407ee1cc 100644
--- a/components/autofill/core/browser/credit_card.cc
+++ b/components/autofill/core/browser/credit_card.cc
@@ -783,6 +783,37 @@ void CreditCard::SetNumber(const base::string16& number) {
type_ = GetCreditCardType(StripSeparators(number_));
}
+base::string16 CreditCard::LastUsedDateAsString() const {
+ base::Time::Exploded exploded;
+ use_date().LocalExplode(&exploded);
+ base::string16 month = FormatDateTo2Digit(exploded.month);
+ base::string16 day_of_month = FormatDateTo2Digit(exploded.day_of_month);
+ base::string16 hour = FormatDateTo2Digit(exploded.hour);
+ 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!
+ return use_count() > 1
+ ? l10n_util::GetStringFUTF16(
+ IDS_AUTOFILL_CREDIT_CARD_LAST_USED_DATE_LABEL,
+ month,
+ day_of_month,
+ hour,
+ minute)
+ : l10n_util::GetStringFUTF16(
+ IDS_AUTOFILL_CREDIT_CARD_ADDED_TO_CHROME_DATE_LABEL,
+ month,
+ day_of_month);
+}
+
+base::string16 CreditCard::FormatDateTo2Digit(int date_info) const {
+ DCHECK(date_info > 0);
+ base::string16 dateIn2Digit = base::IntToString16(date_info);
+ if (date_info >= 10)
+ return dateIn2Digit;
+
+ base::string16 zero = ASCIIToUTF16("0");
+ zero.append(dateIn2Digit);
+ 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.
+}
+
void CreditCard::RecordAndLogUse() {
UMA_HISTOGRAM_COUNTS_1000("Autofill.DaysSinceLastUse.CreditCard",
(base::Time::Now() - use_date()).InDays());

Powered by Google App Engine
This is Rietveld 408576698