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

Unified Diff: chrome/browser/ui/views/payments/shipping_address_editor_view_controller.cc

Issue 2841643002: When a new Payments address is created from the editor, use it as the chosen address (Closed)
Patch Set: Self CR 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/shipping_address_editor_view_controller.cc
diff --git a/chrome/browser/ui/views/payments/shipping_address_editor_view_controller.cc b/chrome/browser/ui/views/payments/shipping_address_editor_view_controller.cc
index 76f6e10373fc589dc0ac0124f32bd4dadfe25742..64a050595d05c4b515791f815c58061e6838d9f5 100644
--- a/chrome/browser/ui/views/payments/shipping_address_editor_view_controller.cc
+++ b/chrome/browser/ui/views/payments/shipping_address_editor_view_controller.cc
@@ -74,8 +74,12 @@ ShippingAddressEditorViewController::ShippingAddressEditorViewController(
PaymentRequestSpec* spec,
PaymentRequestState* state,
PaymentRequestDialogView* dialog,
+ base::OnceClosure on_edited,
+ base::OnceCallback<void(const autofill::AutofillProfile&)> on_added,
autofill::AutofillProfile* profile)
: EditorViewController(spec, state, dialog),
+ on_edited_(std::move(on_edited)),
+ on_added_(std::move(on_added)),
profile_to_edit_(profile),
chosen_country_index_(0),
failed_to_load_region_data_(false) {
@@ -120,6 +124,7 @@ bool ShippingAddressEditorViewController::ValidateModelAndSave() {
// Add the profile (will not add a duplicate).
profile.set_origin(autofill::kSettingsOrigin);
state()->GetPersonalDataManager()->AddProfile(profile);
+ std::move(on_added_).Run(profile);
} else {
// Copy the temporary object's data to the object to be edited. Prefer this
// method to copying |profile| into |profile_to_edit_|, because the latter
@@ -130,6 +135,7 @@ bool ShippingAddressEditorViewController::ValidateModelAndSave() {
DCHECK(success);
profile_to_edit_->set_origin(autofill::kSettingsOrigin);
state()->GetPersonalDataManager()->UpdateProfile(*profile_to_edit_);
+ std::move(on_edited_).Run();
}
return true;

Powered by Google App Engine
This is Rietveld 408576698