Index: components/autofill/core/browser/personal_data_manager.cc |
diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc |
index ca700932942c19cfeb0b54804d33e976f2460145..05fdec3eec69b899d3a81499ddd14a6bee8cffec 100644 |
--- a/components/autofill/core/browser/personal_data_manager.cc |
+++ b/components/autofill/core/browser/personal_data_manager.cc |
@@ -733,11 +733,24 @@ void PersonalDataManager::RemoveByGUID(const std::string& guid) { |
if (!database_.get()) |
return; |
- if (is_credit_card) |
+ if (is_credit_card) { |
database_->RemoveCreditCard(guid); |
- else |
+ } else { |
database_->RemoveAutofillProfile(guid); |
+ // Reset the billing_address_id of any card that refered to this profile. |
+ for (CreditCard* credit_card : GetCreditCards()) { |
+ if (credit_card->billing_address_id() == guid) { |
+ credit_card->set_billing_address_id(""); |
+ |
+ if (credit_card->record_type() == CreditCard::LOCAL_CARD) |
+ database_->UpdateCreditCard(*credit_card); |
+ else |
+ database_->UpdateServerCardMetadata(*credit_card); |
+ } |
+ } |
+ } |
+ |
// Refresh our local cache and send notifications to observers. |
Refresh(); |
} |