| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 if ((!name_on_card_.empty() && name_on_card_ != other.name_on_card_) || | 599 if ((!name_on_card_.empty() && name_on_card_ != other.name_on_card_) || |
| 600 (expiration_month_ != 0 && | 600 (expiration_month_ != 0 && |
| 601 expiration_month_ != other.expiration_month_) || | 601 expiration_month_ != other.expiration_month_) || |
| 602 (expiration_year_ != 0 && expiration_year_ != other.expiration_year_)) { | 602 (expiration_year_ != 0 && expiration_year_ != other.expiration_year_)) { |
| 603 return false; | 603 return false; |
| 604 } | 604 } |
| 605 | 605 |
| 606 if (number_.empty()) | 606 if (number_.empty()) |
| 607 return true; | 607 return true; |
| 608 | 608 |
| 609 if (other.record_type() == FULL_SERVER_CARD) | 609 return HasSameNumberAs(other); |
| 610 return StripSeparators(number_) == StripSeparators(other.number_); | 610 } |
| 611 | 611 |
| 612 bool CreditCard::HasSameNumberAs(const CreditCard& other) const { |
| 612 // For masked cards, this is the best we can do to compare card numbers. | 613 // For masked cards, this is the best we can do to compare card numbers. |
| 613 return TypeAndLastFourDigits() == other.TypeAndLastFourDigits(); | 614 if (record_type() == MASKED_SERVER_CARD || |
| 615 other.record_type() == MASKED_SERVER_CARD) { |
| 616 return TypeAndLastFourDigits() == other.TypeAndLastFourDigits(); |
| 617 } |
| 618 |
| 619 return StripSeparators(number_) == StripSeparators(other.number_); |
| 614 } | 620 } |
| 615 | 621 |
| 616 bool CreditCard::operator==(const CreditCard& credit_card) const { | 622 bool CreditCard::operator==(const CreditCard& credit_card) const { |
| 617 return guid() == credit_card.guid() && | 623 return guid() == credit_card.guid() && |
| 618 origin() == credit_card.origin() && | 624 origin() == credit_card.origin() && |
| 619 Compare(credit_card) == 0; | 625 Compare(credit_card) == 0; |
| 620 } | 626 } |
| 621 | 627 |
| 622 bool CreditCard::operator!=(const CreditCard& credit_card) const { | 628 bool CreditCard::operator!=(const CreditCard& credit_card) const { |
| 623 return !operator==(credit_card); | 629 return !operator==(credit_card); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 const char kAmericanExpressCard[] = "americanExpressCC"; | 797 const char kAmericanExpressCard[] = "americanExpressCC"; |
| 792 const char kDinersCard[] = "dinersCC"; | 798 const char kDinersCard[] = "dinersCC"; |
| 793 const char kDiscoverCard[] = "discoverCC"; | 799 const char kDiscoverCard[] = "discoverCC"; |
| 794 const char kGenericCard[] = "genericCC"; | 800 const char kGenericCard[] = "genericCC"; |
| 795 const char kJCBCard[] = "jcbCC"; | 801 const char kJCBCard[] = "jcbCC"; |
| 796 const char kMasterCard[] = "masterCardCC"; | 802 const char kMasterCard[] = "masterCardCC"; |
| 797 const char kUnionPay[] = "unionPayCC"; | 803 const char kUnionPay[] = "unionPayCC"; |
| 798 const char kVisaCard[] = "visaCC"; | 804 const char kVisaCard[] = "visaCC"; |
| 799 | 805 |
| 800 } // namespace autofill | 806 } // namespace autofill |
| OLD | NEW |