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