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

Unified Diff: components/autofill/core/browser/personal_data_manager.cc

Issue 2892533003: [Payments] Reset card billing address when related profile is deleted. (Closed)
Patch Set: Added curly Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/autofill/core/browser/personal_data_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « no previous file | components/autofill/core/browser/personal_data_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698