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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 // Will normalize 2-digit years to the 4-digit version. | 474 // Will normalize 2-digit years to the 4-digit version. |
475 if (expiration_year > 0 && expiration_year < 100) { | 475 if (expiration_year > 0 && expiration_year < 100) { |
476 base::Time::Exploded now_exploded; | 476 base::Time::Exploded now_exploded; |
477 AutofillClock::Now().LocalExplode(&now_exploded); | 477 AutofillClock::Now().LocalExplode(&now_exploded); |
478 expiration_year += (now_exploded.year / 100) * 100; | 478 expiration_year += (now_exploded.year / 100) * 100; |
479 } | 479 } |
480 | 480 |
481 expiration_year_ = expiration_year; | 481 expiration_year_ = expiration_year; |
482 } | 482 } |
483 | 483 |
| 484 base::string16 CreditCard::BankNameAndLastFourDigits() const { |
| 485 base::string16 digits = LastFourDigits(); |
| 486 // TODO(szhangcs): truncate bank name. |
| 487 if (digits.empty()) |
| 488 return ASCIIToUTF16(bank_name_); |
| 489 return ASCIIToUTF16(bank_name_) + base::string16(kMidlineEllipsis) + digits; |
| 490 } |
| 491 |
484 void CreditCard::operator=(const CreditCard& credit_card) { | 492 void CreditCard::operator=(const CreditCard& credit_card) { |
485 set_use_count(credit_card.use_count()); | 493 set_use_count(credit_card.use_count()); |
486 set_use_date(credit_card.use_date()); | 494 set_use_date(credit_card.use_date()); |
487 set_modification_date(credit_card.modification_date()); | 495 set_modification_date(credit_card.modification_date()); |
488 | 496 |
489 if (this == &credit_card) | 497 if (this == &credit_card) |
490 return; | 498 return; |
491 | 499 |
492 record_type_ = credit_card.record_type_; | 500 record_type_ = credit_card.record_type_; |
493 number_ = credit_card.number_; | 501 number_ = credit_card.number_; |
494 name_on_card_ = credit_card.name_on_card_; | 502 name_on_card_ = credit_card.name_on_card_; |
495 network_ = credit_card.network_; | 503 network_ = credit_card.network_; |
496 expiration_month_ = credit_card.expiration_month_; | 504 expiration_month_ = credit_card.expiration_month_; |
497 expiration_year_ = credit_card.expiration_year_; | 505 expiration_year_ = credit_card.expiration_year_; |
498 server_id_ = credit_card.server_id_; | 506 server_id_ = credit_card.server_id_; |
499 server_status_ = credit_card.server_status_; | 507 server_status_ = credit_card.server_status_; |
500 billing_address_id_ = credit_card.billing_address_id_; | 508 billing_address_id_ = credit_card.billing_address_id_; |
| 509 bank_name_ = credit_card.bank_name_; |
501 | 510 |
502 set_guid(credit_card.guid()); | 511 set_guid(credit_card.guid()); |
503 set_origin(credit_card.origin()); | 512 set_origin(credit_card.origin()); |
504 } | 513 } |
505 | 514 |
506 bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card, | 515 bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card, |
507 const std::string& app_locale) { | 516 const std::string& app_locale) { |
508 if (this->GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale) != | 517 if (this->GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale) != |
509 imported_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale)) { | 518 imported_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale)) { |
510 return false; | 519 return false; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 } | 566 } |
558 | 567 |
559 int comparison = server_id_.compare(credit_card.server_id_); | 568 int comparison = server_id_.compare(credit_card.server_id_); |
560 if (comparison != 0) | 569 if (comparison != 0) |
561 return comparison; | 570 return comparison; |
562 | 571 |
563 comparison = billing_address_id_.compare(credit_card.billing_address_id_); | 572 comparison = billing_address_id_.compare(credit_card.billing_address_id_); |
564 if (comparison != 0) | 573 if (comparison != 0) |
565 return comparison; | 574 return comparison; |
566 | 575 |
| 576 comparison = bank_name_.compare(credit_card.bank_name_); |
| 577 if (comparison != 0) |
| 578 return comparison; |
| 579 |
567 if (static_cast<int>(server_status_) < | 580 if (static_cast<int>(server_status_) < |
568 static_cast<int>(credit_card.server_status_)) | 581 static_cast<int>(credit_card.server_status_)) |
569 return -1; | 582 return -1; |
570 if (static_cast<int>(server_status_) > | 583 if (static_cast<int>(server_status_) > |
571 static_cast<int>(credit_card.server_status_)) | 584 static_cast<int>(credit_card.server_status_)) |
572 return 1; | 585 return 1; |
573 if (static_cast<int>(record_type_) < | 586 if (static_cast<int>(record_type_) < |
574 static_cast<int>(credit_card.record_type_)) | 587 static_cast<int>(credit_card.record_type_)) |
575 return -1; | 588 return -1; |
576 if (static_cast<int>(record_type_) > | 589 if (static_cast<int>(record_type_) > |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 const char kDiscoverCard[] = "discoverCC"; | 967 const char kDiscoverCard[] = "discoverCC"; |
955 const char kEloCard[] = "eloCC"; | 968 const char kEloCard[] = "eloCC"; |
956 const char kGenericCard[] = "genericCC"; | 969 const char kGenericCard[] = "genericCC"; |
957 const char kJCBCard[] = "jcbCC"; | 970 const char kJCBCard[] = "jcbCC"; |
958 const char kMasterCard[] = "masterCardCC"; | 971 const char kMasterCard[] = "masterCardCC"; |
959 const char kMirCard[] = "mirCC"; | 972 const char kMirCard[] = "mirCC"; |
960 const char kUnionPay[] = "unionPayCC"; | 973 const char kUnionPay[] = "unionPayCC"; |
961 const char kVisaCard[] = "visaCC"; | 974 const char kVisaCard[] = "visaCC"; |
962 | 975 |
963 } // namespace autofill | 976 } // namespace autofill |
OLD | NEW |