| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/payments/profile_list_view_controller.h" | 5 #include "chrome/browser/ui/views/payments/profile_list_view_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" | 7 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" |
| 8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | 8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| 9 #include "components/payments/content/payment_request.h" | 9 #include "components/payments/content/payment_request.h" |
| 10 #include "components/strings/grit/components_strings.h" | 10 #include "components/strings/grit/components_strings.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 ShippingProfileViewController(PaymentRequest* request, | 87 ShippingProfileViewController(PaymentRequest* request, |
| 88 PaymentRequestDialogView* dialog) | 88 PaymentRequestDialogView* dialog) |
| 89 : ProfileListViewController(request, dialog) {} | 89 : ProfileListViewController(request, dialog) {} |
| 90 ~ShippingProfileViewController() override {} | 90 ~ShippingProfileViewController() override {} |
| 91 | 91 |
| 92 protected: | 92 protected: |
| 93 // ProfileListViewController: | 93 // ProfileListViewController: |
| 94 std::unique_ptr<views::View> GetLabel( | 94 std::unique_ptr<views::View> GetLabel( |
| 95 autofill::AutofillProfile* profile) override { | 95 autofill::AutofillProfile* profile) override { |
| 96 return GetShippingAddressLabel(AddressStyleType::DETAILED, | 96 return GetShippingAddressLabel(AddressStyleType::DETAILED, |
| 97 request_->locale(), *profile); | 97 request()->GetApplicationLocale(), *profile); |
| 98 } | 98 } |
| 99 | 99 |
| 100 std::vector<autofill::AutofillProfile*> GetProfiles() override { | 100 std::vector<autofill::AutofillProfile*> GetProfiles() override { |
| 101 return request_->shipping_profiles(); | 101 return request()->state()->shipping_profiles(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 base::string16 GetHeaderString() override { | 104 base::string16 GetHeaderString() override { |
| 105 return GetShippingAddressSectionString(request_->options()->shipping_type); | 105 return GetShippingAddressSectionString( |
| 106 request()->spec()->options().shipping_type); |
| 106 } | 107 } |
| 107 | 108 |
| 108 private: | 109 private: |
| 109 DISALLOW_COPY_AND_ASSIGN(ShippingProfileViewController); | 110 DISALLOW_COPY_AND_ASSIGN(ShippingProfileViewController); |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 class ContactProfileViewController : public ProfileListViewController { | 113 class ContactProfileViewController : public ProfileListViewController { |
| 113 public: | 114 public: |
| 114 ContactProfileViewController(PaymentRequest* request, | 115 ContactProfileViewController(PaymentRequest* request, |
| 115 PaymentRequestDialogView* dialog) | 116 PaymentRequestDialogView* dialog) |
| 116 : ProfileListViewController(request, dialog) {} | 117 : ProfileListViewController(request, dialog) {} |
| 117 ~ContactProfileViewController() override {} | 118 ~ContactProfileViewController() override {} |
| 118 | 119 |
| 119 protected: | 120 protected: |
| 120 // ProfileListViewController: | 121 // ProfileListViewController: |
| 121 std::unique_ptr<views::View> GetLabel( | 122 std::unique_ptr<views::View> GetLabel( |
| 122 autofill::AutofillProfile* profile) override { | 123 autofill::AutofillProfile* profile) override { |
| 123 return GetContactInfoLabel(AddressStyleType::DETAILED, request_->locale(), | 124 return GetContactInfoLabel(AddressStyleType::DETAILED, |
| 124 *profile, request_->request_payer_name(), | 125 request()->GetApplicationLocale(), *profile, |
| 125 request_->request_payer_phone(), | 126 request()->spec()->request_payer_name(), |
| 126 request_->request_payer_email()); | 127 request()->spec()->request_payer_phone(), |
| 128 request()->spec()->request_payer_email()); |
| 127 } | 129 } |
| 128 | 130 |
| 129 std::vector<autofill::AutofillProfile*> GetProfiles() override { | 131 std::vector<autofill::AutofillProfile*> GetProfiles() override { |
| 130 return request_->contact_profiles(); | 132 return request()->state()->contact_profiles(); |
| 131 } | 133 } |
| 132 | 134 |
| 133 base::string16 GetHeaderString() override { | 135 base::string16 GetHeaderString() override { |
| 134 return l10n_util::GetStringUTF16( | 136 return l10n_util::GetStringUTF16( |
| 135 IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME); | 137 IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME); |
| 136 } | 138 } |
| 137 | 139 |
| 138 private: | 140 private: |
| 139 DISALLOW_COPY_AND_ASSIGN(ContactProfileViewController); | 141 DISALLOW_COPY_AND_ASSIGN(ContactProfileViewController); |
| 140 }; | 142 }; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 153 std::unique_ptr<ProfileListViewController> | 155 std::unique_ptr<ProfileListViewController> |
| 154 ProfileListViewController::GetContactProfileViewController( | 156 ProfileListViewController::GetContactProfileViewController( |
| 155 PaymentRequest* request, | 157 PaymentRequest* request, |
| 156 PaymentRequestDialogView* dialog) { | 158 PaymentRequestDialogView* dialog) { |
| 157 return base::MakeUnique<ContactProfileViewController>(request, dialog); | 159 return base::MakeUnique<ContactProfileViewController>(request, dialog); |
| 158 } | 160 } |
| 159 | 161 |
| 160 ProfileListViewController::ProfileListViewController( | 162 ProfileListViewController::ProfileListViewController( |
| 161 PaymentRequest* request, | 163 PaymentRequest* request, |
| 162 PaymentRequestDialogView* dialog) | 164 PaymentRequestDialogView* dialog) |
| 163 : PaymentRequestSheetController(request, dialog), request_(request) {} | 165 : PaymentRequestSheetController(request, dialog) {} |
| 164 | 166 |
| 165 ProfileListViewController::~ProfileListViewController() {} | 167 ProfileListViewController::~ProfileListViewController() {} |
| 166 | 168 |
| 167 std::unique_ptr<views::View> ProfileListViewController::CreateView() { | 169 std::unique_ptr<views::View> ProfileListViewController::CreateView() { |
| 168 autofill::AutofillProfile* selected_profile = | 170 autofill::AutofillProfile* selected_profile = |
| 169 request()->selected_shipping_profile(); | 171 request()->state()->selected_shipping_profile(); |
| 170 | 172 |
| 171 // This must be done at Create-time, rather than construct-time, because | 173 // This must be done at Create-time, rather than construct-time, because |
| 172 // the subclass method GetProfiles can't be called in the ctor. | 174 // the subclass method GetProfiles can't be called in the ctor. |
| 173 for (auto* profile : GetProfiles()) { | 175 for (auto* profile : GetProfiles()) { |
| 174 list_.AddItem(base::MakeUnique<ProfileItem>( | 176 list_.AddItem(base::MakeUnique<ProfileItem>( |
| 175 profile, request(), &list_, this, profile == selected_profile)); | 177 profile, request(), &list_, this, profile == selected_profile)); |
| 176 } | 178 } |
| 177 | 179 |
| 178 return CreatePaymentView( | 180 return CreatePaymentView( |
| 179 CreateSheetHeaderView( | 181 CreateSheetHeaderView( |
| 180 /* show_back_arrow = */ true, GetHeaderString(), this), | 182 /* show_back_arrow = */ true, GetHeaderString(), this), |
| 181 list_.CreateListView()); | 183 list_.CreateListView()); |
| 182 } | 184 } |
| 183 | 185 |
| 184 } // namespace payments | 186 } // namespace payments |
| OLD | NEW |