| 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 491 |
| 492 record_type_ = credit_card.record_type_; | 492 record_type_ = credit_card.record_type_; |
| 493 number_ = credit_card.number_; | 493 number_ = credit_card.number_; |
| 494 name_on_card_ = credit_card.name_on_card_; | 494 name_on_card_ = credit_card.name_on_card_; |
| 495 network_ = credit_card.network_; | 495 network_ = credit_card.network_; |
| 496 expiration_month_ = credit_card.expiration_month_; | 496 expiration_month_ = credit_card.expiration_month_; |
| 497 expiration_year_ = credit_card.expiration_year_; | 497 expiration_year_ = credit_card.expiration_year_; |
| 498 server_id_ = credit_card.server_id_; | 498 server_id_ = credit_card.server_id_; |
| 499 server_status_ = credit_card.server_status_; | 499 server_status_ = credit_card.server_status_; |
| 500 billing_address_id_ = credit_card.billing_address_id_; | 500 billing_address_id_ = credit_card.billing_address_id_; |
| 501 bank_name_ = credit_card.bank_name_; | |
| 502 | 501 |
| 503 set_guid(credit_card.guid()); | 502 set_guid(credit_card.guid()); |
| 504 set_origin(credit_card.origin()); | 503 set_origin(credit_card.origin()); |
| 505 } | 504 } |
| 506 | 505 |
| 507 bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card, | 506 bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card, |
| 508 const std::string& app_locale) { | 507 const std::string& app_locale) { |
| 509 if (this->GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale) != | 508 if (this->GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale) != |
| 510 imported_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale)) { | 509 imported_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale)) { |
| 511 return false; | 510 return false; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 557 } |
| 559 | 558 |
| 560 int comparison = server_id_.compare(credit_card.server_id_); | 559 int comparison = server_id_.compare(credit_card.server_id_); |
| 561 if (comparison != 0) | 560 if (comparison != 0) |
| 562 return comparison; | 561 return comparison; |
| 563 | 562 |
| 564 comparison = billing_address_id_.compare(credit_card.billing_address_id_); | 563 comparison = billing_address_id_.compare(credit_card.billing_address_id_); |
| 565 if (comparison != 0) | 564 if (comparison != 0) |
| 566 return comparison; | 565 return comparison; |
| 567 | 566 |
| 568 comparison = bank_name_.compare(credit_card.bank_name_); | |
| 569 if (comparison != 0) | |
| 570 return comparison; | |
| 571 | |
| 572 if (static_cast<int>(server_status_) < | 567 if (static_cast<int>(server_status_) < |
| 573 static_cast<int>(credit_card.server_status_)) | 568 static_cast<int>(credit_card.server_status_)) |
| 574 return -1; | 569 return -1; |
| 575 if (static_cast<int>(server_status_) > | 570 if (static_cast<int>(server_status_) > |
| 576 static_cast<int>(credit_card.server_status_)) | 571 static_cast<int>(credit_card.server_status_)) |
| 577 return 1; | 572 return 1; |
| 578 if (static_cast<int>(record_type_) < | 573 if (static_cast<int>(record_type_) < |
| 579 static_cast<int>(credit_card.record_type_)) | 574 static_cast<int>(credit_card.record_type_)) |
| 580 return -1; | 575 return -1; |
| 581 if (static_cast<int>(record_type_) > | 576 if (static_cast<int>(record_type_) > |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 | 732 |
| 738 return number.substr(number.size() - kNumLastDigits, kNumLastDigits); | 733 return number.substr(number.size() - kNumLastDigits, kNumLastDigits); |
| 739 } | 734 } |
| 740 | 735 |
| 741 base::string16 CreditCard::NetworkForDisplay() const { | 736 base::string16 CreditCard::NetworkForDisplay() const { |
| 742 return CreditCard::NetworkForDisplay(network_); | 737 return CreditCard::NetworkForDisplay(network_); |
| 743 } | 738 } |
| 744 | 739 |
| 745 base::string16 CreditCard::NetworkAndLastFourDigits() const { | 740 base::string16 CreditCard::NetworkAndLastFourDigits() const { |
| 746 base::string16 network = NetworkForDisplay(); | 741 base::string16 network = NetworkForDisplay(); |
| 747 // TODO(crbug.com/734197): truncate network. | |
| 748 | 742 |
| 749 base::string16 digits = LastFourDigits(); | 743 base::string16 digits = LastFourDigits(); |
| 750 if (digits.empty()) | 744 if (digits.empty()) |
| 751 return network; | 745 return network; |
| 752 | 746 |
| 753 // TODO(estade): i18n? | 747 // TODO(estade): i18n? |
| 754 return network + base::string16(kMidlineEllipsis) + digits; | 748 return network + base::string16(kMidlineEllipsis) + digits; |
| 755 } | 749 } |
| 756 | 750 |
| 757 base::string16 CreditCard::BankNameAndLastFourDigits() const { | |
| 758 base::string16 digits = LastFourDigits(); | |
| 759 // TODO(crbug.com/734197): truncate bank name. | |
| 760 if (digits.empty()) | |
| 761 return ASCIIToUTF16(bank_name_); | |
| 762 return ASCIIToUTF16(bank_name_) + base::string16(kMidlineEllipsis) + digits; | |
| 763 } | |
| 764 | |
| 765 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { | 751 base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { |
| 766 base::string16 month = ExpirationMonthAsString(); | 752 base::string16 month = ExpirationMonthAsString(); |
| 767 base::string16 year = Expiration2DigitYearAsString(); | 753 base::string16 year = Expiration2DigitYearAsString(); |
| 768 return month.empty() || year.empty() | 754 return month.empty() || year.empty() |
| 769 ? base::string16() | 755 ? base::string16() |
| 770 : l10n_util::GetStringFUTF16( | 756 : l10n_util::GetStringFUTF16( |
| 771 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); | 757 IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); |
| 772 } | 758 } |
| 773 | 759 |
| 774 base::string16 CreditCard::GetLastUsedDateForDisplay( | 760 base::string16 CreditCard::GetLastUsedDateForDisplay( |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 const char kDiscoverCard[] = "discoverCC"; | 954 const char kDiscoverCard[] = "discoverCC"; |
| 969 const char kEloCard[] = "eloCC"; | 955 const char kEloCard[] = "eloCC"; |
| 970 const char kGenericCard[] = "genericCC"; | 956 const char kGenericCard[] = "genericCC"; |
| 971 const char kJCBCard[] = "jcbCC"; | 957 const char kJCBCard[] = "jcbCC"; |
| 972 const char kMasterCard[] = "masterCardCC"; | 958 const char kMasterCard[] = "masterCardCC"; |
| 973 const char kMirCard[] = "mirCC"; | 959 const char kMirCard[] = "mirCC"; |
| 974 const char kUnionPay[] = "unionPayCC"; | 960 const char kUnionPay[] = "unionPayCC"; |
| 975 const char kVisaCard[] = "visaCC"; | 961 const char kVisaCard[] = "visaCC"; |
| 976 | 962 |
| 977 } // namespace autofill | 963 } // namespace autofill |
| OLD | NEW |