Chromium Code Reviews| 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 // TODO(szhangcs) The length to show here is limited, so we are going to do a | |
| 518 // mapping from long bank names to short bank names. We will do the mapping | |
| 519 // after Bin Service verified what are the Bin ranges that have good data | |
| 520 // quality. | |
| 521 if (digits.empty()) | |
| 522 return ASCIIToUTF16(bank_name_); | |
| 523 size_t bank_name_length = 8; | |
|
sebsg
2017/04/12 22:18:15
You could use a min function? To get the min of th
Shanfeng
2017/04/13 18:29:09
Done.
| |
| 524 if (bank_name_.size() < bank_name_length) { | |
| 525 bank_name_length = bank_name_.size(); | |
| 526 } | |
| 527 return ASCIIToUTF16(bank_name_.substr(0, bank_name_length)) + | |
| 528 base::string16(kMidlineEllipsis) + digits; | |
|
sebsg
2017/04/12 22:18:15
So what happens if the bank name is longer? Does i
Shanfeng
2017/04/13 18:29:09
Yeah... 8 digits are too short. Verified that 15 c
| |
| 529 } | |
| 530 | |
| 515 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { | 531 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { |
| 516 base::string16 month = ExpirationMonthAsString(); | 532 base::string16 month = ExpirationMonthAsString(); |
| 517 base::string16 year = Expiration2DigitYearAsString(); | 533 base::string16 year = Expiration2DigitYearAsString(); |
| 518 return month.empty() || year.empty() | 534 return month.empty() || year.empty() |
| 519 ? base::string16() | 535 ? base::string16() |
| 520 : l10n_util::GetStringFUTF16( | 536 : l10n_util::GetStringFUTF16( |
| 521 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); | 537 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); |
| 522 } | 538 } |
| 523 | 539 |
| 524 void CreditCard::operator=(const CreditCard& credit_card) { | 540 void CreditCard::operator=(const CreditCard& credit_card) { |
| 525 set_use_count(credit_card.use_count()); | 541 set_use_count(credit_card.use_count()); |
| 526 set_use_date(credit_card.use_date()); | 542 set_use_date(credit_card.use_date()); |
| 527 set_modification_date(credit_card.modification_date()); | 543 set_modification_date(credit_card.modification_date()); |
| 528 | 544 |
| 529 if (this == &credit_card) | 545 if (this == &credit_card) |
| 530 return; | 546 return; |
| 531 | 547 |
| 532 record_type_ = credit_card.record_type_; | 548 record_type_ = credit_card.record_type_; |
| 533 number_ = credit_card.number_; | 549 number_ = credit_card.number_; |
| 534 name_on_card_ = credit_card.name_on_card_; | 550 name_on_card_ = credit_card.name_on_card_; |
| 535 type_ = credit_card.type_; | 551 type_ = credit_card.type_; |
| 536 expiration_month_ = credit_card.expiration_month_; | 552 expiration_month_ = credit_card.expiration_month_; |
| 537 expiration_year_ = credit_card.expiration_year_; | 553 expiration_year_ = credit_card.expiration_year_; |
| 538 server_id_ = credit_card.server_id_; | 554 server_id_ = credit_card.server_id_; |
| 539 server_status_ = credit_card.server_status_; | 555 server_status_ = credit_card.server_status_; |
| 540 billing_address_id_ = credit_card.billing_address_id_; | 556 billing_address_id_ = credit_card.billing_address_id_; |
| 557 bank_name_ = credit_card.bank_name_; | |
| 541 | 558 |
| 542 set_guid(credit_card.guid()); | 559 set_guid(credit_card.guid()); |
| 543 set_origin(credit_card.origin()); | 560 set_origin(credit_card.origin()); |
| 544 } | 561 } |
| 545 | 562 |
| 546 base::string16 CreditCard::GetLastUsedDateForDisplay( | 563 base::string16 CreditCard::GetLastUsedDateForDisplay( |
| 547 const std::string& app_locale) const { | 564 const std::string& app_locale) const { |
| 548 bool show_expiration_date = | 565 bool show_expiration_date = |
| 549 ShowExpirationDateInAutofillCreditCardLastUsedDate(); | 566 ShowExpirationDateInAutofillCreditCardLastUsedDate(); |
| 550 | 567 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 } | 663 } |
| 647 | 664 |
| 648 int comparison = server_id_.compare(credit_card.server_id_); | 665 int comparison = server_id_.compare(credit_card.server_id_); |
| 649 if (comparison != 0) | 666 if (comparison != 0) |
| 650 return comparison; | 667 return comparison; |
| 651 | 668 |
| 652 comparison = billing_address_id_.compare(credit_card.billing_address_id_); | 669 comparison = billing_address_id_.compare(credit_card.billing_address_id_); |
| 653 if (comparison != 0) | 670 if (comparison != 0) |
| 654 return comparison; | 671 return comparison; |
| 655 | 672 |
| 673 comparison = bank_name_.compare(credit_card.bank_name_); | |
| 674 if (comparison != 0) | |
| 675 return comparison; | |
| 676 | |
| 656 if (static_cast<int>(server_status_) < | 677 if (static_cast<int>(server_status_) < |
| 657 static_cast<int>(credit_card.server_status_)) | 678 static_cast<int>(credit_card.server_status_)) |
| 658 return -1; | 679 return -1; |
| 659 if (static_cast<int>(server_status_) > | 680 if (static_cast<int>(server_status_) > |
| 660 static_cast<int>(credit_card.server_status_)) | 681 static_cast<int>(credit_card.server_status_)) |
| 661 return 1; | 682 return 1; |
| 662 if (static_cast<int>(record_type_) < | 683 if (static_cast<int>(record_type_) < |
| 663 static_cast<int>(credit_card.record_type_)) | 684 static_cast<int>(credit_card.record_type_)) |
| 664 return -1; | 685 return -1; |
| 665 if (static_cast<int>(record_type_) > | 686 if (static_cast<int>(record_type_) > |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 929 const char kDinersCard[] = "dinersCC"; | 950 const char kDinersCard[] = "dinersCC"; |
| 930 const char kDiscoverCard[] = "discoverCC"; | 951 const char kDiscoverCard[] = "discoverCC"; |
| 931 const char kGenericCard[] = "genericCC"; | 952 const char kGenericCard[] = "genericCC"; |
| 932 const char kJCBCard[] = "jcbCC"; | 953 const char kJCBCard[] = "jcbCC"; |
| 933 const char kMasterCard[] = "masterCardCC"; | 954 const char kMasterCard[] = "masterCardCC"; |
| 934 const char kMirCard[] = "mirCC"; | 955 const char kMirCard[] = "mirCC"; |
| 935 const char kUnionPay[] = "unionPayCC"; | 956 const char kUnionPay[] = "unionPayCC"; |
| 936 const char kVisaCard[] = "visaCC"; | 957 const char kVisaCard[] = "visaCC"; |
| 937 | 958 |
| 938 } // namespace autofill | 959 } // namespace autofill |
| OLD | NEW |