Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: components/autofill/core/browser/credit_card.cc

Issue 1808613004: Don't ever attempt to upload credit cards whose numbers match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/autofill/core/browser/credit_card.h ('k') | components/autofill/core/browser/credit_card_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698