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

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

Issue 1818403003: Don't ever attempt to upload credit cards whose numbers match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 if ((!name_on_card_.empty() && name_on_card_ != other.name_on_card_) || 591 if ((!name_on_card_.empty() && name_on_card_ != other.name_on_card_) ||
592 (expiration_month_ != 0 && 592 (expiration_month_ != 0 &&
593 expiration_month_ != other.expiration_month_) || 593 expiration_month_ != other.expiration_month_) ||
594 (expiration_year_ != 0 && expiration_year_ != other.expiration_year_)) { 594 (expiration_year_ != 0 && expiration_year_ != other.expiration_year_)) {
595 return false; 595 return false;
596 } 596 }
597 597
598 if (number_.empty()) 598 if (number_.empty())
599 return true; 599 return true;
600 600
601 if (other.record_type() == FULL_SERVER_CARD) 601 return HasSameNumberAs(other);
602 return StripSeparators(number_) == StripSeparators(other.number_); 602 }
603 603
604 bool CreditCard::HasSameNumberAs(const CreditCard& other) const {
604 // For masked cards, this is the best we can do to compare card numbers. 605 // For masked cards, this is the best we can do to compare card numbers.
605 return TypeAndLastFourDigits() == other.TypeAndLastFourDigits(); 606 if (record_type() == MASKED_SERVER_CARD ||
607 other.record_type() == MASKED_SERVER_CARD) {
608 return TypeAndLastFourDigits() == other.TypeAndLastFourDigits();
609 }
610
611 return StripSeparators(number_) == StripSeparators(other.number_);
606 } 612 }
607 613
608 bool CreditCard::operator==(const CreditCard& credit_card) const { 614 bool CreditCard::operator==(const CreditCard& credit_card) const {
609 return guid() == credit_card.guid() && 615 return guid() == credit_card.guid() &&
610 origin() == credit_card.origin() && 616 origin() == credit_card.origin() &&
611 Compare(credit_card) == 0; 617 Compare(credit_card) == 0;
612 } 618 }
613 619
614 bool CreditCard::operator!=(const CreditCard& credit_card) const { 620 bool CreditCard::operator!=(const CreditCard& credit_card) const {
615 return !operator==(credit_card); 621 return !operator==(credit_card);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 const char kAmericanExpressCard[] = "americanExpressCC"; 794 const char kAmericanExpressCard[] = "americanExpressCC";
789 const char kDinersCard[] = "dinersCC"; 795 const char kDinersCard[] = "dinersCC";
790 const char kDiscoverCard[] = "discoverCC"; 796 const char kDiscoverCard[] = "discoverCC";
791 const char kGenericCard[] = "genericCC"; 797 const char kGenericCard[] = "genericCC";
792 const char kJCBCard[] = "jcbCC"; 798 const char kJCBCard[] = "jcbCC";
793 const char kMasterCard[] = "masterCardCC"; 799 const char kMasterCard[] = "masterCardCC";
794 const char kUnionPay[] = "unionPayCC"; 800 const char kUnionPay[] = "unionPayCC";
795 const char kVisaCard[] = "visaCC"; 801 const char kVisaCard[] = "visaCC";
796 802
797 } // namespace autofill 803 } // 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