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

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

Issue 2109643003: Add billing address to masked server credit cards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete AutofillServerCardPreferences.java Created 4 years, 5 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 #include <algorithm> 8 #include <algorithm>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 if (existing_credit_card->record_type() == CreditCard::MASKED_SERVER_CARD) { 577 if (existing_credit_card->record_type() == CreditCard::MASKED_SERVER_CARD) {
578 database_->UnmaskServerCreditCard(credit_card, 578 database_->UnmaskServerCreditCard(credit_card,
579 credit_card.number()); 579 credit_card.number());
580 } else { 580 } else {
581 database_->MaskServerCreditCard(credit_card.server_id()); 581 database_->MaskServerCreditCard(credit_card.server_id());
582 } 582 }
583 583
584 Refresh(); 584 Refresh();
585 } 585 }
586 586
587 void PersonalDataManager::UpdateServerCardBillingAddress(
588 const CreditCard& credit_card) {
589 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type());
590
591 if (!database_.get())
592 return;
593
594 CreditCard* existing_credit_card = nullptr;
595 for (auto it : server_credit_cards_) {
596 if (credit_card.guid() == it->guid()) {
597 existing_credit_card = it;
598 break;
599 }
600 }
601 if (!existing_credit_card
602 || existing_credit_card->billing_address_id() ==
603 credit_card.billing_address_id()) {
604 return;
605 }
606
607 existing_credit_card->set_billing_address_id(
608 credit_card.billing_address_id());
609 database_->UpdateServerCardBillingAddress(*existing_credit_card);
610
611 Refresh();
612 }
613
587 void PersonalDataManager::ResetFullServerCard(const std::string& guid) { 614 void PersonalDataManager::ResetFullServerCard(const std::string& guid) {
588 for (const CreditCard* card : server_credit_cards_) { 615 for (const CreditCard* card : server_credit_cards_) {
589 if (card->guid() == guid) { 616 if (card->guid() == guid) {
590 DCHECK_EQ(card->record_type(), CreditCard::FULL_SERVER_CARD); 617 DCHECK_EQ(card->record_type(), CreditCard::FULL_SERVER_CARD);
591 CreditCard card_copy = *card; 618 CreditCard card_copy = *card;
592 card_copy.set_record_type(CreditCard::MASKED_SERVER_CARD); 619 card_copy.set_record_type(CreditCard::MASKED_SERVER_CARD);
593 card_copy.SetNumber(card->LastFourDigits()); 620 card_copy.SetNumber(card->LastFourDigits());
594 UpdateServerCreditCard(card_copy); 621 UpdateServerCreditCard(card_copy);
595 break; 622 break;
596 } 623 }
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 break; 1707 break;
1681 } 1708 }
1682 } 1709 }
1683 } 1710 }
1684 } 1711 }
1685 AutofillMetrics::LogNumberOfProfilesRemovedDuringDedupe( 1712 AutofillMetrics::LogNumberOfProfilesRemovedDuringDedupe(
1686 profiles_to_delete->size()); 1713 profiles_to_delete->size());
1687 } 1714 }
1688 1715
1689 } // namespace autofill 1716 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698