| Index: chrome/browser/ui/views/payments/profile_list_view_controller.cc
|
| diff --git a/chrome/browser/ui/views/payments/profile_list_view_controller.cc b/chrome/browser/ui/views/payments/profile_list_view_controller.cc
|
| index 02d4b5cd0c973f43a0b6f41b00d44e0329e4eec8..025571e4873dc24bc9858761cfeeb363896468f0 100644
|
| --- a/chrome/browser/ui/views/payments/profile_list_view_controller.cc
|
| +++ b/chrome/browser/ui/views/payments/profile_list_view_controller.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chrome/browser/ui/views/payments/profile_list_view_controller.h"
|
|
|
| +#include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_row_view.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
|
| #include "components/payments/content/payment_request_spec.h"
|
| @@ -28,13 +29,15 @@ class ProfileItem : public PaymentRequestItemList::Item {
|
| PaymentRequestState* state,
|
| PaymentRequestItemList* parent_list,
|
| ProfileListViewController* parent_view,
|
| + PaymentRequestDialogView* dialog,
|
| bool selected)
|
| : payments::PaymentRequestItemList::Item(spec,
|
| state,
|
| parent_list,
|
| selected),
|
| parent_view_(parent_view),
|
| - profile_(profile) {}
|
| + profile_(profile),
|
| + dialog_(dialog) {}
|
| ~ProfileItem() override {}
|
|
|
| private:
|
| @@ -45,7 +48,12 @@ class ProfileItem : public PaymentRequestItemList::Item {
|
| return parent_view_->GetLabel(profile_);
|
| }
|
|
|
| - void SelectedStateChanged() override {}
|
| + void SelectedStateChanged() override {
|
| + if (selected()) {
|
| + parent_view_->SelectProfile(profile_);
|
| + dialog_->GoBack();
|
| + }
|
| + }
|
|
|
| bool CanBeSelected() const override {
|
| // TODO(anthonyvd): Check for profile completedness.
|
| @@ -58,6 +66,7 @@ class ProfileItem : public PaymentRequestItemList::Item {
|
|
|
| ProfileListViewController* parent_view_;
|
| autofill::AutofillProfile* profile_;
|
| + PaymentRequestDialogView* dialog_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ProfileItem);
|
| };
|
| @@ -80,6 +89,14 @@ class ShippingProfileViewController : public ProfileListViewController {
|
| state()->GetApplicationLocale(), *profile);
|
| }
|
|
|
| + void SelectProfile(autofill::AutofillProfile* profile) override {
|
| + state()->SetSelectedShippingProfile(profile);
|
| + }
|
| +
|
| + autofill::AutofillProfile* GetSelectedProfile() override {
|
| + return state()->selected_shipping_profile();
|
| + }
|
| +
|
| std::vector<autofill::AutofillProfile*> GetProfiles() override {
|
| return state()->shipping_profiles();
|
| }
|
| @@ -110,6 +127,14 @@ class ContactProfileViewController : public ProfileListViewController {
|
| spec()->request_payer_email());
|
| }
|
|
|
| + void SelectProfile(autofill::AutofillProfile* profile) override {
|
| + state()->SetSelectedContactProfile(profile);
|
| + }
|
| +
|
| + autofill::AutofillProfile* GetSelectedProfile() override {
|
| + return state()->selected_contact_profile();
|
| + }
|
| +
|
| std::vector<autofill::AutofillProfile*> GetProfiles() override {
|
| return state()->contact_profiles();
|
| }
|
| @@ -152,14 +177,14 @@ ProfileListViewController::ProfileListViewController(
|
| ProfileListViewController::~ProfileListViewController() {}
|
|
|
| std::unique_ptr<views::View> ProfileListViewController::CreateView() {
|
| - autofill::AutofillProfile* selected_profile =
|
| - state()->selected_shipping_profile();
|
| + autofill::AutofillProfile* selected_profile = GetSelectedProfile();
|
|
|
| // This must be done at Create-time, rather than construct-time, because
|
| // the subclass method GetProfiles can't be called in the ctor.
|
| for (auto* profile : GetProfiles()) {
|
| - list_.AddItem(base::MakeUnique<ProfileItem>(
|
| - profile, spec(), state(), &list_, this, profile == selected_profile));
|
| + list_.AddItem(base::MakeUnique<ProfileItem>(profile, spec(), state(),
|
| + &list_, this, dialog(),
|
| + profile == selected_profile));
|
| }
|
|
|
| return CreatePaymentView(
|
|
|