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

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

Issue 2894943002: Prevent existing card number to be used for new credit cards in the Payment Request (Closed)
Patch Set: Fixed unit tests crash Created 3 years, 7 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/personal_data_manager.h" 5 #include "components/autofill/core/browser/personal_data_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 Refresh(); 755 Refresh();
756 } 756 }
757 757
758 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) { 758 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) {
759 const std::vector<CreditCard*>& credit_cards = GetCreditCards(); 759 const std::vector<CreditCard*>& credit_cards = GetCreditCards();
760 std::vector<CreditCard*>::const_iterator iter = 760 std::vector<CreditCard*>::const_iterator iter =
761 FindElementByGUID<CreditCard>(credit_cards, guid); 761 FindElementByGUID<CreditCard>(credit_cards, guid);
762 return iter != credit_cards.end() ? *iter : nullptr; 762 return iter != credit_cards.end() ? *iter : nullptr;
763 } 763 }
764 764
765 CreditCard* PersonalDataManager::GetCreditCardByNumber(
766 const std::string& number) {
767 CreditCard numbered_card;
768 numbered_card.SetNumber(base::ASCIIToUTF16(number));
769 for (CreditCard* credit_card : GetCreditCards()) {
770 DCHECK(credit_card);
771 if (credit_card->HasSameNumberAs(numbered_card))
772 return credit_card;
773 }
774 return nullptr;
775 }
776
765 void PersonalDataManager::GetNonEmptyTypes( 777 void PersonalDataManager::GetNonEmptyTypes(
766 ServerFieldTypeSet* non_empty_types) { 778 ServerFieldTypeSet* non_empty_types) {
767 for (AutofillProfile* profile : GetProfiles()) 779 for (AutofillProfile* profile : GetProfiles())
768 profile->GetNonEmptyTypes(app_locale_, non_empty_types); 780 profile->GetNonEmptyTypes(app_locale_, non_empty_types);
769 for (CreditCard* card : GetCreditCards()) 781 for (CreditCard* card : GetCreditCards())
770 card->GetNonEmptyTypes(app_locale_, non_empty_types); 782 card->GetNonEmptyTypes(app_locale_, non_empty_types);
771 } 783 }
772 784
773 bool PersonalDataManager::IsDataLoaded() const { 785 bool PersonalDataManager::IsDataLoaded() const {
774 return is_data_loaded_; 786 return is_data_loaded_;
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); 2076 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email);
2065 2077
2066 AutofillMetrics::LogWalletAddressConversionType( 2078 AutofillMetrics::LogWalletAddressConversionType(
2067 AutofillMetrics::CONVERTED_ADDRESS_ADDED); 2079 AutofillMetrics::CONVERTED_ADDRESS_ADDED);
2068 } 2080 }
2069 2081
2070 return guid; 2082 return guid;
2071 } 2083 }
2072 2084
2073 } // namespace autofill 2085 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/personal_data_manager.h ('k') | components/payments_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698