Chromium Code Reviews| 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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 726 | 726 |
| 727 bool is_credit_card = FindByGUID<CreditCard>(local_credit_cards_, guid); | 727 bool is_credit_card = FindByGUID<CreditCard>(local_credit_cards_, guid); |
| 728 bool is_profile = !is_credit_card && | 728 bool is_profile = !is_credit_card && |
| 729 FindByGUID<AutofillProfile>(web_profiles_, guid); | 729 FindByGUID<AutofillProfile>(web_profiles_, guid); |
| 730 if (!is_credit_card && !is_profile) | 730 if (!is_credit_card && !is_profile) |
| 731 return; | 731 return; |
| 732 | 732 |
| 733 if (!database_.get()) | 733 if (!database_.get()) |
| 734 return; | 734 return; |
| 735 | 735 |
| 736 if (is_credit_card) | 736 if (is_credit_card) |
|
Mathieu
2017/05/17 15:55:32
add curlies
sebsg
2017/05/17 15:59:16
Done.
| |
| 737 database_->RemoveCreditCard(guid); | 737 database_->RemoveCreditCard(guid); |
| 738 else | 738 else { |
| 739 database_->RemoveAutofillProfile(guid); | 739 database_->RemoveAutofillProfile(guid); |
| 740 | 740 |
| 741 // Reset the billing_address_id of any card that refered to this profile. | |
| 742 for (CreditCard* credit_card : GetCreditCards()) { | |
| 743 if (credit_card->billing_address_id() == guid) { | |
| 744 credit_card->set_billing_address_id(""); | |
| 745 | |
| 746 if (credit_card->record_type() == CreditCard::LOCAL_CARD) | |
| 747 database_->UpdateCreditCard(*credit_card); | |
| 748 else | |
| 749 database_->UpdateServerCardMetadata(*credit_card); | |
| 750 } | |
| 751 } | |
| 752 } | |
| 753 | |
| 741 // Refresh our local cache and send notifications to observers. | 754 // Refresh our local cache and send notifications to observers. |
| 742 Refresh(); | 755 Refresh(); |
| 743 } | 756 } |
| 744 | 757 |
| 745 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) { | 758 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) { |
| 746 const std::vector<CreditCard*>& credit_cards = GetCreditCards(); | 759 const std::vector<CreditCard*>& credit_cards = GetCreditCards(); |
| 747 std::vector<CreditCard*>::const_iterator iter = | 760 std::vector<CreditCard*>::const_iterator iter = |
| 748 FindElementByGUID<CreditCard>(credit_cards, guid); | 761 FindElementByGUID<CreditCard>(credit_cards, guid); |
| 749 return iter != credit_cards.end() ? *iter : nullptr; | 762 return iter != credit_cards.end() ? *iter : nullptr; |
| 750 } | 763 } |
| (...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2051 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); | 2064 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); |
| 2052 | 2065 |
| 2053 AutofillMetrics::LogWalletAddressConversionType( | 2066 AutofillMetrics::LogWalletAddressConversionType( |
| 2054 AutofillMetrics::CONVERTED_ADDRESS_ADDED); | 2067 AutofillMetrics::CONVERTED_ADDRESS_ADDED); |
| 2055 } | 2068 } |
| 2056 | 2069 |
| 2057 return guid; | 2070 return guid; |
| 2058 } | 2071 } |
| 2059 | 2072 |
| 2060 } // namespace autofill | 2073 } // namespace autofill |
| OLD | NEW |