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

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

Issue 2626843004: [Payments] Add billing_address_id and has_converted to autofill_table (Closed)
Patch Set: Created 3 years, 11 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (is_off_the_record_ || !database_.get()) 474 if (is_off_the_record_ || !database_.get())
475 return; 475 return;
476 476
477 CreditCard* credit_card = GetCreditCardByGUID(data_model.guid()); 477 CreditCard* credit_card = GetCreditCardByGUID(data_model.guid());
478 if (credit_card) { 478 if (credit_card) {
479 credit_card->RecordAndLogUse(); 479 credit_card->RecordAndLogUse();
480 480
481 if (credit_card->record_type() == CreditCard::LOCAL_CARD) 481 if (credit_card->record_type() == CreditCard::LOCAL_CARD)
482 database_->UpdateCreditCard(*credit_card); 482 database_->UpdateCreditCard(*credit_card);
483 else 483 else
484 database_->UpdateServerCardUsageStats(*credit_card); 484 database_->UpdateServerCardMetadata(*credit_card);
485 485
486 Refresh(); 486 Refresh();
487 return; 487 return;
488 } 488 }
489 489
490 AutofillProfile* profile = GetProfileByGUID(data_model.guid()); 490 AutofillProfile* profile = GetProfileByGUID(data_model.guid());
491 if (profile) { 491 if (profile) {
492 profile->RecordAndLogUse(); 492 profile->RecordAndLogUse();
493 493
494 if (profile->record_type() == AutofillProfile::LOCAL_PROFILE) 494 if (profile->record_type() == AutofillProfile::LOCAL_PROFILE)
495 database_->UpdateAutofillProfile(*profile); 495 database_->UpdateAutofillProfile(*profile);
496 else if (profile->record_type() == AutofillProfile::SERVER_PROFILE) 496 else if (profile->record_type() == AutofillProfile::SERVER_PROFILE)
497 database_->UpdateServerAddressUsageStats(*profile); 497 database_->UpdateServerAddressMetadata(*profile);
498 498
499 Refresh(); 499 Refresh();
500 } 500 }
501 } 501 }
502 502
503 void PersonalDataManager::AddProfile(const AutofillProfile& profile) { 503 void PersonalDataManager::AddProfile(const AutofillProfile& profile) {
504 if (is_off_the_record_) 504 if (is_off_the_record_)
505 return; 505 return;
506 506
507 if (profile.IsEmpty(app_locale_)) 507 if (profile.IsEmpty(app_locale_))
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 if (existing_credit_card->record_type() == CreditCard::MASKED_SERVER_CARD) { 638 if (existing_credit_card->record_type() == CreditCard::MASKED_SERVER_CARD) {
639 database_->UnmaskServerCreditCard(credit_card, 639 database_->UnmaskServerCreditCard(credit_card,
640 credit_card.number()); 640 credit_card.number());
641 } else { 641 } else {
642 database_->MaskServerCreditCard(credit_card.server_id()); 642 database_->MaskServerCreditCard(credit_card.server_id());
643 } 643 }
644 644
645 Refresh(); 645 Refresh();
646 } 646 }
647 647
648 // TODO(crbug.com/680180): Update the function name in Android.
648 void PersonalDataManager::UpdateServerCardBillingAddress( 649 void PersonalDataManager::UpdateServerCardBillingAddress(
649 const CreditCard& credit_card) { 650 const CreditCard& credit_card) {
650 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type()); 651 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type());
651 652
652 if (!database_.get()) 653 if (is_off_the_record_ || !database_.get())
please use gerrit instead 2017/01/11 19:23:03 I don't see why off the record should prevent upda
sebsg 2017/01/12 15:36:30 off the record is currently used to avoid modifyin
653 return; 654 return;
654 655
655 CreditCard* existing_credit_card = nullptr; 656 database_->UpdateServerCardMetadata(credit_card);
656 for (auto& server_card : server_credit_cards_) {
657 if (credit_card.server_id() == server_card->server_id()) {
658 existing_credit_card = server_card.get();
659 break;
660 }
661 }
662 if (!existing_credit_card
663 || existing_credit_card->billing_address_id() ==
664 credit_card.billing_address_id()) {
665 return;
666 }
667
668 existing_credit_card->set_billing_address_id(
669 credit_card.billing_address_id());
670 database_->UpdateServerCardBillingAddress(*existing_credit_card);
671 657
672 Refresh(); 658 Refresh();
673 } 659 }
674 660
675 void PersonalDataManager::ResetFullServerCard(const std::string& guid) { 661 void PersonalDataManager::ResetFullServerCard(const std::string& guid) {
676 for (const auto& card : server_credit_cards_) { 662 for (const auto& card : server_credit_cards_) {
677 if (card->guid() == guid) { 663 if (card->guid() == guid) {
678 DCHECK_EQ(card->record_type(), CreditCard::FULL_SERVER_CARD); 664 DCHECK_EQ(card->record_type(), CreditCard::FULL_SERVER_CARD);
679 CreditCard card_copy = *card; 665 CreditCard card_copy = *card;
680 card_copy.set_record_type(CreditCard::MASKED_SERVER_CARD); 666 card_copy.set_record_type(CreditCard::MASKED_SERVER_CARD);
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 } 1847 }
1862 1848
1863 // If the card was modified, apply the changes to the database. 1849 // If the card was modified, apply the changes to the database.
1864 if (was_modified) { 1850 if (was_modified) {
1865 database_->UpdateCreditCard(*credit_card); 1851 database_->UpdateCreditCard(*credit_card);
1866 } 1852 }
1867 } 1853 }
1868 } 1854 }
1869 1855
1870 } // namespace autofill 1856 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698