| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/autofill/credit_card.h" | 5 #include "chrome/browser/autofill/credit_card.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 set_verification_code(value); | 196 set_verification_code(value); |
| 197 break; | 197 break; |
| 198 | 198 |
| 199 default: | 199 default: |
| 200 DLOG(ERROR) << "Attempting to set unknown info-type " | 200 DLOG(ERROR) << "Attempting to set unknown info-type " |
| 201 << type.field_type(); | 201 << type.field_type(); |
| 202 break; | 202 break; |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 string16 CreditCard::ObfuscatedNumber() const { |
| 207 if (number().empty()) |
| 208 return string16(); // No CC number, means empty preview. |
| 209 string16 result(ASCIIToUTF16("************")); |
| 210 result.append(last_four_digits()); |
| 211 |
| 212 return result; |
| 213 } |
| 214 |
| 206 string16 CreditCard::PreviewSummary() const { | 215 string16 CreditCard::PreviewSummary() const { |
| 207 string16 preview; | 216 string16 preview; |
| 208 if (number().empty()) | 217 if (number().empty()) |
| 209 return preview; // No CC number, means empty preview. | 218 return preview; // No CC number, means empty preview. |
| 210 string16 obfuscated_cc_number(ASCIIToUTF16("************")); | 219 string16 obfuscated_cc_number = ObfuscatedNumber(); |
| 211 obfuscated_cc_number.append(last_four_digits()); | |
| 212 if (!expiration_month() || !expiration_year()) | 220 if (!expiration_month() || !expiration_year()) |
| 213 return obfuscated_cc_number; // no expiration date set | 221 return obfuscated_cc_number; // no expiration date set |
| 214 // TODO(georgey): internationalize date | 222 // TODO(georgey): internationalize date |
| 215 string16 formatted_date(ExpirationMonthAsString()); | 223 string16 formatted_date(ExpirationMonthAsString()); |
| 216 formatted_date.append(ASCIIToUTF16("/")); | 224 formatted_date.append(ASCIIToUTF16("/")); |
| 217 formatted_date.append(Expiration4DigitYearAsString()); | 225 formatted_date.append(Expiration4DigitYearAsString()); |
| 218 | 226 |
| 219 preview = l10n_util::GetStringFUTF16( | 227 preview = l10n_util::GetStringFUTF16( |
| 220 IDS_CREDIT_CARD_NUMBER_PREVIEW_FORMAT, | 228 IDS_CREDIT_CARD_NUMBER_PREVIEW_FORMAT, |
| 221 obfuscated_cc_number, | 229 obfuscated_cc_number, |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 << " " | 496 << " " |
| 489 << UTF16ToUTF8(creditcard.GetFieldText( | 497 << UTF16ToUTF8(creditcard.GetFieldText( |
| 490 AutoFillType(CREDIT_CARD_VERIFICATION_CODE))) | 498 AutoFillType(CREDIT_CARD_VERIFICATION_CODE))) |
| 491 << " " | 499 << " " |
| 492 << UTF16ToUTF8(creditcard.GetFieldText( | 500 << UTF16ToUTF8(creditcard.GetFieldText( |
| 493 AutoFillType(CREDIT_CARD_EXP_MONTH))) | 501 AutoFillType(CREDIT_CARD_EXP_MONTH))) |
| 494 << " " | 502 << " " |
| 495 << UTF16ToUTF8(creditcard.GetFieldText( | 503 << UTF16ToUTF8(creditcard.GetFieldText( |
| 496 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR))); | 504 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR))); |
| 497 } | 505 } |
| OLD | NEW |