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

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

Issue 2829853008: Stores server card as a full server card when upload to server succeeds. (Closed)
Patch Set: Renames AddServerCreditCard to AddFullServerCreditCard. Adds DCHECK to verify that we are in a tran… Created 3 years, 8 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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 if (!database_.get()) 604 if (!database_.get())
605 return; 605 return;
606 606
607 // Make the update. 607 // Make the update.
608 database_->UpdateCreditCard(credit_card); 608 database_->UpdateCreditCard(credit_card);
609 609
610 // Refresh our local cache and send notifications to observers. 610 // Refresh our local cache and send notifications to observers.
611 Refresh(); 611 Refresh();
612 } 612 }
613 613
614 void PersonalDataManager::AddFullServerCreditCard(
615 const CreditCard& credit_card) {
616 DCHECK_EQ(CreditCard::FULL_SERVER_CARD, credit_card.record_type());
617 DCHECK(!credit_card.IsEmpty(app_locale_));
618 DCHECK(!credit_card.server_id().empty());
619
620 if (is_off_the_record_ || !database_.get())
621 return;
622
623 // Don't add a duplicate.
624 if (FindByGUID<CreditCard>(server_credit_cards_, credit_card.guid()) ||
625 FindByContents(server_credit_cards_, credit_card))
626 return;
627
628 // Add the new credit card to the web database.
629 database_->AddFullServerCreditCard(credit_card);
630
631 // Refresh our local cache and send notifications to observers.
632 Refresh();
633 }
634
614 void PersonalDataManager::UpdateServerCreditCard( 635 void PersonalDataManager::UpdateServerCreditCard(
615 const CreditCard& credit_card) { 636 const CreditCard& credit_card) {
616 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type()); 637 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type());
617 638
618 if (is_off_the_record_ || !database_.get()) 639 if (is_off_the_record_ || !database_.get())
619 return; 640 return;
620 641
621 // Look up by server id, not GUID. 642 // Look up by server id, not GUID.
622 const CreditCard* existing_credit_card = nullptr; 643 const CreditCard* existing_credit_card = nullptr;
623 for (const auto& server_card : server_credit_cards_) { 644 for (const auto& server_card : server_credit_cards_) {
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); 2037 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email);
2017 2038
2018 AutofillMetrics::LogWalletAddressConversionType( 2039 AutofillMetrics::LogWalletAddressConversionType(
2019 AutofillMetrics::CONVERTED_ADDRESS_ADDED); 2040 AutofillMetrics::CONVERTED_ADDRESS_ADDED);
2020 } 2041 }
2021 2042
2022 return guid; 2043 return guid;
2023 } 2044 }
2024 2045
2025 } // namespace autofill 2046 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698