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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 base::string16 type = TypeForDisplay(); | 505 base::string16 type = TypeForDisplay(); |
506 | 506 |
507 base::string16 digits = LastFourDigits(); | 507 base::string16 digits = LastFourDigits(); |
508 if (digits.empty()) | 508 if (digits.empty()) |
509 return type; | 509 return type; |
510 | 510 |
511 // TODO(estade): i18n? | 511 // TODO(estade): i18n? |
512 return type + base::string16(kMidlineEllipsis) + digits; | 512 return type + base::string16(kMidlineEllipsis) + digits; |
513 } | 513 } |
514 | 514 |
| 515 base::string16 CreditCard::BankNameAndLastFourDigits() const { |
| 516 base::string16 digits = LastFourDigits(); |
| 517 // The length of bank_name will be at most 8 digits. |
| 518 if (digits.empty()) |
| 519 return ASCIIToUTF16(bank_name_); |
| 520 size_t bank_name_length = 8; |
| 521 if (bank_name_.size() < bank_name_length) { |
| 522 bank_name_length = bank_name_.size(); |
| 523 } |
| 524 return ASCIIToUTF16(bank_name_.substr(0, bank_name_length)) + |
| 525 base::string16(kMidlineEllipsis) + digits; |
| 526 } |
| 527 |
515 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { | 528 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { |
516 base::string16 month = ExpirationMonthAsString(); | 529 base::string16 month = ExpirationMonthAsString(); |
517 base::string16 year = Expiration2DigitYearAsString(); | 530 base::string16 year = Expiration2DigitYearAsString(); |
518 return month.empty() || year.empty() | 531 return month.empty() || year.empty() |
519 ? base::string16() | 532 ? base::string16() |
520 : l10n_util::GetStringFUTF16( | 533 : l10n_util::GetStringFUTF16( |
521 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); | 534 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); |
522 } | 535 } |
523 | 536 |
524 void CreditCard::operator=(const CreditCard& credit_card) { | 537 void CreditCard::operator=(const CreditCard& credit_card) { |
525 set_use_count(credit_card.use_count()); | 538 set_use_count(credit_card.use_count()); |
526 set_use_date(credit_card.use_date()); | 539 set_use_date(credit_card.use_date()); |
527 set_modification_date(credit_card.modification_date()); | 540 set_modification_date(credit_card.modification_date()); |
528 | 541 |
529 if (this == &credit_card) | 542 if (this == &credit_card) |
530 return; | 543 return; |
531 | 544 |
532 record_type_ = credit_card.record_type_; | 545 record_type_ = credit_card.record_type_; |
533 number_ = credit_card.number_; | 546 number_ = credit_card.number_; |
534 name_on_card_ = credit_card.name_on_card_; | 547 name_on_card_ = credit_card.name_on_card_; |
535 type_ = credit_card.type_; | 548 type_ = credit_card.type_; |
536 expiration_month_ = credit_card.expiration_month_; | 549 expiration_month_ = credit_card.expiration_month_; |
537 expiration_year_ = credit_card.expiration_year_; | 550 expiration_year_ = credit_card.expiration_year_; |
538 server_id_ = credit_card.server_id_; | 551 server_id_ = credit_card.server_id_; |
539 server_status_ = credit_card.server_status_; | 552 server_status_ = credit_card.server_status_; |
540 billing_address_id_ = credit_card.billing_address_id_; | 553 billing_address_id_ = credit_card.billing_address_id_; |
| 554 bank_name_ = credit_card.bank_name_; |
541 | 555 |
542 set_guid(credit_card.guid()); | 556 set_guid(credit_card.guid()); |
543 set_origin(credit_card.origin()); | 557 set_origin(credit_card.origin()); |
544 } | 558 } |
545 | 559 |
546 base::string16 CreditCard::GetLastUsedDateForDisplay( | 560 base::string16 CreditCard::GetLastUsedDateForDisplay( |
547 const std::string& app_locale) const { | 561 const std::string& app_locale) const { |
548 bool show_expiration_date = | 562 bool show_expiration_date = |
549 ShowExpirationDateInAutofillCreditCardLastUsedDate(); | 563 ShowExpirationDateInAutofillCreditCardLastUsedDate(); |
550 | 564 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } | 660 } |
647 | 661 |
648 int comparison = server_id_.compare(credit_card.server_id_); | 662 int comparison = server_id_.compare(credit_card.server_id_); |
649 if (comparison != 0) | 663 if (comparison != 0) |
650 return comparison; | 664 return comparison; |
651 | 665 |
652 comparison = billing_address_id_.compare(credit_card.billing_address_id_); | 666 comparison = billing_address_id_.compare(credit_card.billing_address_id_); |
653 if (comparison != 0) | 667 if (comparison != 0) |
654 return comparison; | 668 return comparison; |
655 | 669 |
| 670 comparison = bank_name_.compare(credit_card.bank_name_); |
| 671 if (comparison != 0) |
| 672 return comparison; |
| 673 |
656 if (static_cast<int>(server_status_) < | 674 if (static_cast<int>(server_status_) < |
657 static_cast<int>(credit_card.server_status_)) | 675 static_cast<int>(credit_card.server_status_)) |
658 return -1; | 676 return -1; |
659 if (static_cast<int>(server_status_) > | 677 if (static_cast<int>(server_status_) > |
660 static_cast<int>(credit_card.server_status_)) | 678 static_cast<int>(credit_card.server_status_)) |
661 return 1; | 679 return 1; |
662 if (static_cast<int>(record_type_) < | 680 if (static_cast<int>(record_type_) < |
663 static_cast<int>(credit_card.record_type_)) | 681 static_cast<int>(credit_card.record_type_)) |
664 return -1; | 682 return -1; |
665 if (static_cast<int>(record_type_) > | 683 if (static_cast<int>(record_type_) > |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 const char kDinersCard[] = "dinersCC"; | 947 const char kDinersCard[] = "dinersCC"; |
930 const char kDiscoverCard[] = "discoverCC"; | 948 const char kDiscoverCard[] = "discoverCC"; |
931 const char kGenericCard[] = "genericCC"; | 949 const char kGenericCard[] = "genericCC"; |
932 const char kJCBCard[] = "jcbCC"; | 950 const char kJCBCard[] = "jcbCC"; |
933 const char kMasterCard[] = "masterCardCC"; | 951 const char kMasterCard[] = "masterCardCC"; |
934 const char kMirCard[] = "mirCC"; | 952 const char kMirCard[] = "mirCC"; |
935 const char kUnionPay[] = "unionPayCC"; | 953 const char kUnionPay[] = "unionPayCC"; |
936 const char kVisaCard[] = "visaCC"; | 954 const char kVisaCard[] = "visaCC"; |
937 | 955 |
938 } // namespace autofill | 956 } // namespace autofill |
OLD | NEW |