OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/payment_sheet_view_controller.h" | 5 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 void PaymentSheetViewController::ButtonPressed( | 226 void PaymentSheetViewController::ButtonPressed( |
227 views::Button* sender, const ui::Event& event) { | 227 views::Button* sender, const ui::Event& event) { |
228 switch (sender->tag()) { | 228 switch (sender->tag()) { |
229 case static_cast<int>( | 229 case static_cast<int>( |
230 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): | 230 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): |
231 dialog()->ShowOrderSummary(); | 231 dialog()->ShowOrderSummary(); |
232 break; | 232 break; |
233 | 233 |
234 case static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON): | 234 case static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON): |
235 dialog()->ShowShippingListSheet(); | 235 dialog()->ShowShippingProfileSheet(); |
236 break; | 236 break; |
237 | 237 |
238 case static_cast<int>( | 238 case static_cast<int>( |
239 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON): | 239 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON): |
240 dialog()->ShowPaymentMethodSheet(); | 240 dialog()->ShowPaymentMethodSheet(); |
241 break; | 241 break; |
242 | 242 |
243 case static_cast<int>( | 243 case static_cast<int>( |
244 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON): | 244 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON): |
245 dialog()->ShowContactInfoSheet(); | 245 dialog()->ShowContactProfileSheet(); |
246 break; | 246 break; |
247 | 247 |
248 default: | 248 default: |
249 PaymentRequestSheetController::ButtonPressed(sender, event); | 249 PaymentRequestSheetController::ButtonPressed(sender, event); |
250 break; | 250 break; |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 void PaymentSheetViewController::UpdatePayButtonState(bool enabled) { | 254 void PaymentSheetViewController::UpdatePayButtonState(bool enabled) { |
255 pay_button_->SetEnabled(enabled); | 255 pay_button_->SetEnabled(enabled); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON)); | 287 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON)); |
288 section->set_id( | 288 section->set_id( |
289 static_cast<int>(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION)); | 289 static_cast<int>(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION)); |
290 return section; | 290 return section; |
291 } | 291 } |
292 | 292 |
293 std::unique_ptr<views::View> | 293 std::unique_ptr<views::View> |
294 PaymentSheetViewController::CreateShippingSectionContent() { | 294 PaymentSheetViewController::CreateShippingSectionContent() { |
295 auto* profile = request()->selected_shipping_profile(); | 295 auto* profile = request()->selected_shipping_profile(); |
296 | 296 |
297 // TODO(tmartino): Empty string param is app locale; this should be passed | 297 return profile ? payments::GetShippingAddressLabel( |
298 // at construct-time and stored as a member in a future CL. | 298 AddressStyleType::SUMMARY, request()->locale(), *profile) |
299 return profile ? payments::GetShippingAddressLabel(AddressStyleType::SUMMARY, | |
300 std::string(), *profile) | |
301 : base::MakeUnique<views::Label>(base::string16()); | 299 : base::MakeUnique<views::Label>(base::string16()); |
302 } | 300 } |
303 | 301 |
304 // Creates the Shipping row, which contains a "Shipping address" label, the | 302 // Creates the Shipping row, which contains a "Shipping address" label, the |
305 // user's selected shipping address, and a chevron. | 303 // user's selected shipping address, and a chevron. |
306 // +----------------------------------------------+ | 304 // +----------------------------------------------+ |
307 // | Shipping Address Barack Obama | | 305 // | Shipping Address Barack Obama | |
308 // | 1600 Pennsylvania Ave. > | | 306 // | 1600 Pennsylvania Ave. > | |
309 // | 1800MYPOTUS | | 307 // | 1800MYPOTUS | |
310 // +----------------------------------------------+ | 308 // +----------------------------------------------+ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 section->set_tag(static_cast<int>( | 363 section->set_tag(static_cast<int>( |
366 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON)); | 364 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON)); |
367 section->set_id( | 365 section->set_id( |
368 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)); | 366 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)); |
369 return section; | 367 return section; |
370 } | 368 } |
371 | 369 |
372 std::unique_ptr<views::View> | 370 std::unique_ptr<views::View> |
373 PaymentSheetViewController::CreateContactInfoSectionContent() { | 371 PaymentSheetViewController::CreateContactInfoSectionContent() { |
374 auto* profile = request()->selected_contact_profile(); | 372 auto* profile = request()->selected_contact_profile(); |
375 // TODO(tmartino): Replace empty string with app locale. | 373 |
376 return profile ? payments::GetContactInfoLabel(AddressStyleType::SUMMARY, | 374 return profile ? payments::GetContactInfoLabel( |
377 std::string(), *profile, true, | 375 AddressStyleType::SUMMARY, request()->locale(), *profile, |
378 true, true) | 376 request()->request_payer_name(), |
| 377 request()->request_payer_email(), |
| 378 request()->request_payer_phone()) |
379 : base::MakeUnique<views::Label>(base::string16()); | 379 : base::MakeUnique<views::Label>(base::string16()); |
380 } | 380 } |
381 | 381 |
382 // Creates the Contact Info row, which contains a "Contact info" label; the | 382 // Creates the Contact Info row, which contains a "Contact info" label; the |
383 // name, email address, and/or phone number; and a chevron. | 383 // name, email address, and/or phone number; and a chevron. |
384 // +----------------------------------------------+ | 384 // +----------------------------------------------+ |
385 // | Contact info Barack Obama | | 385 // | Contact info Barack Obama | |
386 // | 1800MYPOTUS > | | 386 // | 1800MYPOTUS > | |
387 // | potus@whitehouse.gov | | 387 // | potus@whitehouse.gov | |
388 // +----------------------------------------------+ | 388 // +----------------------------------------------+ |
389 std::unique_ptr<views::Button> | 389 std::unique_ptr<views::Button> |
390 PaymentSheetViewController::CreateContactInfoRow() { | 390 PaymentSheetViewController::CreateContactInfoRow() { |
391 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( | 391 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( |
392 this, | 392 this, |
393 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME), | 393 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME), |
394 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), | 394 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), |
395 widest_name_column_view_width_); | 395 widest_name_column_view_width_); |
396 section->set_tag(static_cast<int>( | 396 section->set_tag(static_cast<int>( |
397 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); | 397 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); |
398 section->set_id( | 398 section->set_id( |
399 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); | 399 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); |
400 return section; | 400 return section; |
401 } | 401 } |
402 | 402 |
403 } // namespace payments | 403 } // namespace payments |
OLD | NEW |