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

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: And yet another small goof fix... :-( 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 e6babf41d8909d0a28b11b2f3a91a2cead55fb87..1a868b56c4822af0b3ac0138695b2aa2295c5c3b 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
@@ -67,8 +67,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) {
@@ -113,6 +117,8 @@ 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);
+ on_edited_.Reset();
} 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
@@ -123,6 +129,8 @@ bool ShippingAddressEditorViewController::ValidateModelAndSave() {
DCHECK(success);
profile_to_edit_->set_origin(autofill::kSettingsOrigin);
state()->GetPersonalDataManager()->UpdateProfile(*profile_to_edit_);
+ std::move(on_edited_).Run();
+ on_added_.Reset();
}
return true;

Powered by Google App Engine
This is Rietveld 408576698