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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 set_origin(credit_card.origin()); | 527 set_origin(credit_card.origin()); |
528 } | 528 } |
529 | 529 |
530 bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card, | 530 bool CreditCard::UpdateFromImportedCard(const CreditCard& imported_card, |
531 const std::string& app_locale) { | 531 const std::string& app_locale) { |
532 if (this->GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale) != | 532 if (this->GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale) != |
533 imported_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale)) { | 533 imported_card.GetInfo(AutofillType(CREDIT_CARD_NUMBER), app_locale)) { |
534 return false; | 534 return false; |
535 } | 535 } |
536 | 536 |
537 // Heuristically aggregated data should never overwrite verified data. | 537 // Heuristically aggregated data should never overwrite verified data. |
Mathieu
2016/04/26 20:06:19
update comment
sebsg
2016/04/26 21:06:14
Done.
| |
538 // Instead, discard any heuristically aggregated credit cards that disagree | 538 // Instead, discard any heuristically aggregated credit cards that disagree |
539 // with explicitly entered data, so that the UI is not cluttered with | 539 // with explicitly entered data, so that the UI is not cluttered with |
540 // duplicate cards. | 540 // duplicate cards. |
541 if (this->IsVerified() && !imported_card.IsVerified()) | 541 if (this->IsVerified() && !imported_card.IsVerified()) { |
542 // If the original card is expired and the imported card is not, and the | |
543 // name on the cards are identical, update the expiration date. | |
544 if (this->IsExpired(base::Time::Now()) && | |
545 !imported_card.IsExpired(base::Time::Now()) && | |
546 (name_on_card_ == imported_card.name_on_card_)) { | |
547 DCHECK(imported_card.expiration_month_ && imported_card.expiration_year_); | |
548 expiration_month_ = imported_card.expiration_month_; | |
549 expiration_year_ = imported_card.expiration_year_; | |
550 } | |
542 return true; | 551 return true; |
552 } | |
543 | 553 |
544 set_origin(imported_card.origin()); | 554 set_origin(imported_card.origin()); |
545 | 555 |
546 // Note that the card number is intentionally not updated, so as to preserve | 556 // Note that the card number is intentionally not updated, so as to preserve |
547 // any formatting (i.e. separator characters). Since the card number is not | 557 // any formatting (i.e. separator characters). Since the card number is not |
548 // updated, there is no reason to update the card type, either. | 558 // updated, there is no reason to update the card type, either. |
549 if (!imported_card.name_on_card_.empty()) | 559 if (!imported_card.name_on_card_.empty()) |
550 name_on_card_ = imported_card.name_on_card_; | 560 name_on_card_ = imported_card.name_on_card_; |
551 | 561 |
552 // The expiration date for |imported_card| should always be set. | 562 // The expiration date for |imported_card| should always be set. |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
797 const char kAmericanExpressCard[] = "americanExpressCC"; | 807 const char kAmericanExpressCard[] = "americanExpressCC"; |
798 const char kDinersCard[] = "dinersCC"; | 808 const char kDinersCard[] = "dinersCC"; |
799 const char kDiscoverCard[] = "discoverCC"; | 809 const char kDiscoverCard[] = "discoverCC"; |
800 const char kGenericCard[] = "genericCC"; | 810 const char kGenericCard[] = "genericCC"; |
801 const char kJCBCard[] = "jcbCC"; | 811 const char kJCBCard[] = "jcbCC"; |
802 const char kMasterCard[] = "masterCardCC"; | 812 const char kMasterCard[] = "masterCardCC"; |
803 const char kUnionPay[] = "unionPayCC"; | 813 const char kUnionPay[] = "unionPayCC"; |
804 const char kVisaCard[] = "visaCC"; | 814 const char kVisaCard[] = "visaCC"; |
805 | 815 |
806 } // namespace autofill | 816 } // namespace autofill |
OLD | NEW |