| 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 21 matching lines...) Expand all Loading... |
| 32 #include "grit/components_scaled_resources.h" | 32 #include "grit/components_scaled_resources.h" |
| 33 #include "grit/components_strings.h" | 33 #include "grit/components_strings.h" |
| 34 #include "third_party/icu/source/common/unicode/uloc.h" | 34 #include "third_party/icu/source/common/unicode/uloc.h" |
| 35 #include "third_party/icu/source/i18n/unicode/dtfmtsym.h" | 35 #include "third_party/icu/source/i18n/unicode/dtfmtsym.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 | 37 |
| 38 using base::ASCIIToUTF16; | 38 using base::ASCIIToUTF16; |
| 39 | 39 |
| 40 namespace autofill { | 40 namespace autofill { |
| 41 | 41 |
| 42 const base::char16 kMidlineEllipsis[] = { 0x22ef, 0 }; | 42 const base::char16 kMidlineEllipsis[] = { 0x0020, 0x0020, |
| 43 0x2022, 0x2006, |
| 44 0x2022, 0x2006, |
| 45 0x2022, 0x2006, |
| 46 0x2022, 0x2006, 0 }; |
| 43 | 47 |
| 44 namespace { | 48 namespace { |
| 45 | 49 |
| 46 const base::char16 kCreditCardObfuscationSymbol = '*'; | 50 const base::char16 kCreditCardObfuscationSymbol = '*'; |
| 47 const base::char16 kNonBreakingSpace[] = { 0x00a0, 0 }; | |
| 48 | 51 |
| 49 bool ConvertYear(const base::string16& year, int* num) { | 52 bool ConvertYear(const base::string16& year, int* num) { |
| 50 // If the |year| is empty, clear the stored value. | 53 // If the |year| is empty, clear the stored value. |
| 51 if (year.empty()) { | 54 if (year.empty()) { |
| 52 *num = 0; | 55 *num = 0; |
| 53 return true; | 56 return true; |
| 54 } | 57 } |
| 55 | 58 |
| 56 // Try parsing the |year| as a number. | 59 // Try parsing the |year| as a number. |
| 57 if (base::StringToInt(year, num)) | 60 if (base::StringToInt(year, num)) |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } | 495 } |
| 493 | 496 |
| 494 base::string16 CreditCard::TypeAndLastFourDigits() const { | 497 base::string16 CreditCard::TypeAndLastFourDigits() const { |
| 495 base::string16 type = TypeForDisplay(); | 498 base::string16 type = TypeForDisplay(); |
| 496 | 499 |
| 497 base::string16 digits = LastFourDigits(); | 500 base::string16 digits = LastFourDigits(); |
| 498 if (digits.empty()) | 501 if (digits.empty()) |
| 499 return type; | 502 return type; |
| 500 | 503 |
| 501 // TODO(estade): i18n? | 504 // TODO(estade): i18n? |
| 502 return type + base::string16(kNonBreakingSpace) + | 505 return type + base::string16(kMidlineEllipsis) + digits; |
| 503 base::string16(kMidlineEllipsis) + digits; | |
| 504 } | 506 } |
| 505 | 507 |
| 506 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { | 508 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { |
| 507 base::string16 month = ExpirationMonthAsString(); | 509 base::string16 month = ExpirationMonthAsString(); |
| 508 base::string16 year = Expiration2DigitYearAsString(); | 510 base::string16 year = Expiration2DigitYearAsString(); |
| 509 return month.empty() || year.empty() | 511 return month.empty() || year.empty() |
| 510 ? base::string16() | 512 ? base::string16() |
| 511 : l10n_util::GetStringFUTF16( | 513 : l10n_util::GetStringFUTF16( |
| 512 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); | 514 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); |
| 513 } | 515 } |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 const char kDinersCard[] = "dinersCC"; | 872 const char kDinersCard[] = "dinersCC"; |
| 871 const char kDiscoverCard[] = "discoverCC"; | 873 const char kDiscoverCard[] = "discoverCC"; |
| 872 const char kGenericCard[] = "genericCC"; | 874 const char kGenericCard[] = "genericCC"; |
| 873 const char kJCBCard[] = "jcbCC"; | 875 const char kJCBCard[] = "jcbCC"; |
| 874 const char kMasterCard[] = "masterCardCC"; | 876 const char kMasterCard[] = "masterCardCC"; |
| 875 const char kMirCard[] = "mirCC"; | 877 const char kMirCard[] = "mirCC"; |
| 876 const char kUnionPay[] = "unionPayCC"; | 878 const char kUnionPay[] = "unionPayCC"; |
| 877 const char kVisaCard[] = "visaCC"; | 879 const char kVisaCard[] = "visaCC"; |
| 878 | 880 |
| 879 } // namespace autofill | 881 } // namespace autofill |
| OLD | NEW |