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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 base::string16 type = TypeForDisplay(); | 504 base::string16 type = TypeForDisplay(); |
505 | 505 |
506 base::string16 digits = LastFourDigits(); | 506 base::string16 digits = LastFourDigits(); |
507 if (digits.empty()) | 507 if (digits.empty()) |
508 return type; | 508 return type; |
509 | 509 |
510 // TODO(estade): i18n? | 510 // TODO(estade): i18n? |
511 return type + base::string16(kMidlineEllipsis) + digits; | 511 return type + base::string16(kMidlineEllipsis) + digits; |
512 } | 512 } |
513 | 513 |
514 base::string16 CreditCard::BankNameAndLastFourDigits() const { | |
515 base::string16 digits = LastFourDigits(); | |
516 // TODO(szhangcs) The length to show here is limited, so we are going to do a | |
517 // mapping from long bank names to short bank names. We will do the mapping | |
Mathieu
2017/03/31 18:25:10
This comment is too detailed for the chromium code
Shanfeng
2017/04/12 01:58:59
Done.
| |
518 // after Bin Service verified what are the Bin ranges that have good data | |
519 // quality. | |
520 if (digits.empty()) | |
521 return ASCIIToUTF16(bank_name_); | |
522 size_t bank_name_length = 8; | |
Jared Saul
2017/03/03 23:40:09
Any particular reason behind the choice of 8? I'm
Shanfeng
2017/03/04 00:01:08
No perticular reason. 8 looks long enough on the n
| |
523 if (bank_name_.size() < bank_name_length) { | |
524 bank_name_length = bank_name_.size(); | |
525 } | |
526 return ASCIIToUTF16(bank_name_.substr(0, bank_name_length)) + | |
Mathieu
2017/03/31 18:25:10
A truncate is not great. Have a look at https://cs
Shanfeng
2017/04/12 01:58:59
We will ensure the max length of bank name will be
| |
527 base::string16(kMidlineEllipsis) + digits; | |
528 } | |
529 | |
514 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { | 530 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { |
515 base::string16 month = ExpirationMonthAsString(); | 531 base::string16 month = ExpirationMonthAsString(); |
516 base::string16 year = Expiration2DigitYearAsString(); | 532 base::string16 year = Expiration2DigitYearAsString(); |
517 return month.empty() || year.empty() | 533 return month.empty() || year.empty() |
518 ? base::string16() | 534 ? base::string16() |
519 : l10n_util::GetStringFUTF16( | 535 : l10n_util::GetStringFUTF16( |
520 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); | 536 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); |
521 } | 537 } |
522 | 538 |
523 void CreditCard::operator=(const CreditCard& credit_card) { | 539 void CreditCard::operator=(const CreditCard& credit_card) { |
524 set_use_count(credit_card.use_count()); | 540 set_use_count(credit_card.use_count()); |
525 set_use_date(credit_card.use_date()); | 541 set_use_date(credit_card.use_date()); |
526 set_modification_date(credit_card.modification_date()); | 542 set_modification_date(credit_card.modification_date()); |
527 | 543 |
528 if (this == &credit_card) | 544 if (this == &credit_card) |
529 return; | 545 return; |
530 | 546 |
531 record_type_ = credit_card.record_type_; | 547 record_type_ = credit_card.record_type_; |
532 number_ = credit_card.number_; | 548 number_ = credit_card.number_; |
533 name_on_card_ = credit_card.name_on_card_; | 549 name_on_card_ = credit_card.name_on_card_; |
534 type_ = credit_card.type_; | 550 type_ = credit_card.type_; |
535 expiration_month_ = credit_card.expiration_month_; | 551 expiration_month_ = credit_card.expiration_month_; |
536 expiration_year_ = credit_card.expiration_year_; | 552 expiration_year_ = credit_card.expiration_year_; |
537 server_id_ = credit_card.server_id_; | 553 server_id_ = credit_card.server_id_; |
538 server_status_ = credit_card.server_status_; | 554 server_status_ = credit_card.server_status_; |
539 billing_address_id_ = credit_card.billing_address_id_; | 555 billing_address_id_ = credit_card.billing_address_id_; |
556 bank_name_ = credit_card.bank_name_; | |
540 | 557 |
541 set_guid(credit_card.guid()); | 558 set_guid(credit_card.guid()); |
542 set_origin(credit_card.origin()); | 559 set_origin(credit_card.origin()); |
543 } | 560 } |
544 | 561 |
545 base::string16 CreditCard::GetLastUsedDateForDisplay( | 562 base::string16 CreditCard::GetLastUsedDateForDisplay( |
546 const std::string& app_locale) const { | 563 const std::string& app_locale) const { |
547 bool show_expiration_date = | 564 bool show_expiration_date = |
548 ShowExpirationDateInAutofillCreditCardLastUsedDate(); | 565 ShowExpirationDateInAutofillCreditCardLastUsedDate(); |
549 | 566 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 } | 662 } |
646 | 663 |
647 int comparison = server_id_.compare(credit_card.server_id_); | 664 int comparison = server_id_.compare(credit_card.server_id_); |
648 if (comparison != 0) | 665 if (comparison != 0) |
649 return comparison; | 666 return comparison; |
650 | 667 |
651 comparison = billing_address_id_.compare(credit_card.billing_address_id_); | 668 comparison = billing_address_id_.compare(credit_card.billing_address_id_); |
652 if (comparison != 0) | 669 if (comparison != 0) |
653 return comparison; | 670 return comparison; |
654 | 671 |
672 comparison = bank_name_.compare(credit_card.bank_name_); | |
673 if (comparison != 0) | |
674 return comparison; | |
675 | |
655 if (static_cast<int>(server_status_) < | 676 if (static_cast<int>(server_status_) < |
656 static_cast<int>(credit_card.server_status_)) | 677 static_cast<int>(credit_card.server_status_)) |
657 return -1; | 678 return -1; |
658 if (static_cast<int>(server_status_) > | 679 if (static_cast<int>(server_status_) > |
659 static_cast<int>(credit_card.server_status_)) | 680 static_cast<int>(credit_card.server_status_)) |
660 return 1; | 681 return 1; |
661 if (static_cast<int>(record_type_) < | 682 if (static_cast<int>(record_type_) < |
662 static_cast<int>(credit_card.record_type_)) | 683 static_cast<int>(credit_card.record_type_)) |
663 return -1; | 684 return -1; |
664 if (static_cast<int>(record_type_) > | 685 if (static_cast<int>(record_type_) > |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 const char kDinersCard[] = "dinersCC"; | 948 const char kDinersCard[] = "dinersCC"; |
928 const char kDiscoverCard[] = "discoverCC"; | 949 const char kDiscoverCard[] = "discoverCC"; |
929 const char kGenericCard[] = "genericCC"; | 950 const char kGenericCard[] = "genericCC"; |
930 const char kJCBCard[] = "jcbCC"; | 951 const char kJCBCard[] = "jcbCC"; |
931 const char kMasterCard[] = "masterCardCC"; | 952 const char kMasterCard[] = "masterCardCC"; |
932 const char kMirCard[] = "mirCC"; | 953 const char kMirCard[] = "mirCC"; |
933 const char kUnionPay[] = "unionPayCC"; | 954 const char kUnionPay[] = "unionPayCC"; |
934 const char kVisaCard[] = "visaCC"; | 955 const char kVisaCard[] = "visaCC"; |
935 | 956 |
936 } // namespace autofill | 957 } // namespace autofill |
OLD | NEW |