OLD | NEW |
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 Loading... |
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::AddServerCreditCard(const CreditCard& credit_card) { |
| 615 DCHECK_EQ(CreditCard::FULL_SERVER_CARD, credit_card.record_type()); |
| 616 DCHECK(!credit_card.IsEmpty(app_locale_)); |
| 617 DCHECK(!credit_card.server_id().empty()); |
| 618 |
| 619 if (is_off_the_record_ || !database_.get()) |
| 620 return; |
| 621 |
| 622 // Don't add a duplicate. |
| 623 if (FindByGUID<CreditCard>(server_credit_cards_, credit_card.guid()) || |
| 624 FindByContents(server_credit_cards_, credit_card)) |
| 625 return; |
| 626 |
| 627 // Add the new credit card to the web database. |
| 628 database_->AddServerCreditCard(credit_card); |
| 629 |
| 630 // Refresh our local cache and send notifications to observers. |
| 631 Refresh(); |
| 632 } |
| 633 |
614 void PersonalDataManager::UpdateServerCreditCard( | 634 void PersonalDataManager::UpdateServerCreditCard( |
615 const CreditCard& credit_card) { | 635 const CreditCard& credit_card) { |
616 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type()); | 636 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type()); |
617 | 637 |
618 if (is_off_the_record_ || !database_.get()) | 638 if (is_off_the_record_ || !database_.get()) |
619 return; | 639 return; |
620 | 640 |
621 // Look up by server id, not GUID. | 641 // Look up by server id, not GUID. |
622 const CreditCard* existing_credit_card = nullptr; | 642 const CreditCard* existing_credit_card = nullptr; |
623 for (const auto& server_card : server_credit_cards_) { | 643 for (const auto& server_card : server_credit_cards_) { |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); | 2036 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); |
2017 | 2037 |
2018 AutofillMetrics::LogWalletAddressConversionType( | 2038 AutofillMetrics::LogWalletAddressConversionType( |
2019 AutofillMetrics::CONVERTED_ADDRESS_ADDED); | 2039 AutofillMetrics::CONVERTED_ADDRESS_ADDED); |
2020 } | 2040 } |
2021 | 2041 |
2022 return guid; | 2042 return guid; |
2023 } | 2043 } |
2024 | 2044 |
2025 } // namespace autofill | 2045 } // namespace autofill |
OLD | NEW |