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 <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // Tags for the buttons in the payment sheet | 58 // Tags for the buttons in the payment sheet |
59 enum class PaymentSheetViewControllerTags { | 59 enum class PaymentSheetViewControllerTags { |
60 SHOW_ORDER_SUMMARY_BUTTON = kFirstTagValue, // Navigate to order summary | 60 SHOW_ORDER_SUMMARY_BUTTON = kFirstTagValue, // Navigate to order summary |
61 SHOW_SHIPPING_BUTTON, // Navigate to the shipping address screen | 61 SHOW_SHIPPING_BUTTON, // Navigate to the shipping address screen |
62 ADD_SHIPPING_BUTTON, // Navigate to the shipping address editor | 62 ADD_SHIPPING_BUTTON, // Navigate to the shipping address editor |
63 SHOW_PAYMENT_METHOD_BUTTON, // Navigate to the payment method screen | 63 SHOW_PAYMENT_METHOD_BUTTON, // Navigate to the payment method screen |
64 ADD_PAYMENT_METHOD_BUTTON, // Navigate to the payment method editor | 64 ADD_PAYMENT_METHOD_BUTTON, // Navigate to the payment method editor |
65 SHOW_CONTACT_INFO_BUTTON, // Navigate to the contact info screen | 65 SHOW_CONTACT_INFO_BUTTON, // Navigate to the contact info screen |
66 ADD_CONTACT_INFO_BUTTON, // Navigate to the contact info editor | 66 ADD_CONTACT_INFO_BUTTON, // Navigate to the contact info editor |
67 SHOW_SHIPPING_OPTION_BUTTON, // Navigate to the shipping options screen | 67 SHOW_SHIPPING_OPTION_BUTTON, // Navigate to the shipping options screen |
68 PAY_BUTTON | 68 PAY_BUTTON, |
| 69 MAX_TAG, // Always keep last. |
69 }; | 70 }; |
70 | 71 |
71 // A class that ensures proper elision of labels in the form | 72 // A class that ensures proper elision of labels in the form |
72 // "[preview] and N more" where preview might be elided to allow "and N more" to | 73 // "[preview] and N more" where preview might be elided to allow "and N more" to |
73 // be always visible. | 74 // be always visible. |
74 class PreviewEliderLabel : public views::Label { | 75 class PreviewEliderLabel : public views::Label { |
75 public: | 76 public: |
76 // Creates a PreviewEliderLabel where |preview_text| might be elided, | 77 // Creates a PreviewEliderLabel where |preview_text| might be elided, |
77 // |format_string| is the string with format argument numbers in ICU syntax | 78 // |format_string| is the string with format argument numbers in ICU syntax |
78 // and |n| is the "N more" item count. | 79 // and |n| is the "N more" item count. |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): | 484 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): |
484 dialog()->ShowOrderSummary(); | 485 dialog()->ShowOrderSummary(); |
485 break; | 486 break; |
486 | 487 |
487 case static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON): | 488 case static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON): |
488 dialog()->ShowShippingProfileSheet(); | 489 dialog()->ShowShippingProfileSheet(); |
489 break; | 490 break; |
490 | 491 |
491 case static_cast<int>(PaymentSheetViewControllerTags::ADD_SHIPPING_BUTTON): | 492 case static_cast<int>(PaymentSheetViewControllerTags::ADD_SHIPPING_BUTTON): |
492 dialog()->ShowShippingAddressEditor( | 493 dialog()->ShowShippingAddressEditor( |
| 494 BackNavigationType::kPaymentSheet, |
493 /*on_edited=*/base::OnceClosure(), // This is always an add. | 495 /*on_edited=*/base::OnceClosure(), // This is always an add. |
494 /*on_added=*/ | 496 /*on_added=*/ |
495 base::BindOnce(&PaymentRequestState::AddAutofillShippingProfile, | 497 base::BindOnce(&PaymentRequestState::AddAutofillShippingProfile, |
496 base::Unretained(state()), /*selected=*/true), | 498 base::Unretained(state()), /*selected=*/true), |
497 nullptr); | 499 nullptr); |
498 break; | 500 break; |
499 | 501 |
500 case static_cast<int>( | 502 case static_cast<int>( |
501 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON): | 503 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON): |
502 dialog()->ShowPaymentMethodSheet(); | 504 dialog()->ShowPaymentMethodSheet(); |
503 break; | 505 break; |
504 | 506 |
505 case static_cast<int>( | 507 case static_cast<int>( |
506 PaymentSheetViewControllerTags::ADD_PAYMENT_METHOD_BUTTON): | 508 PaymentSheetViewControllerTags::ADD_PAYMENT_METHOD_BUTTON): |
507 dialog()->ShowCreditCardEditor( | 509 dialog()->ShowCreditCardEditor( |
| 510 BackNavigationType::kPaymentSheet, |
| 511 static_cast<int>(PaymentSheetViewControllerTags::MAX_TAG), |
508 /*on_edited=*/base::OnceClosure(), // This is always an add. | 512 /*on_edited=*/base::OnceClosure(), // This is always an add. |
509 /*on_added=*/ | 513 /*on_added=*/ |
510 base::BindOnce(&PaymentRequestState::AddAutofillPaymentInstrument, | 514 base::BindOnce(&PaymentRequestState::AddAutofillPaymentInstrument, |
511 base::Unretained(state()), /*selected=*/true), | 515 base::Unretained(state()), /*selected=*/true), |
512 /*credit_card=*/nullptr); | 516 /*credit_card=*/nullptr); |
513 | 517 |
514 break; | 518 break; |
515 | 519 |
516 case static_cast<int>( | 520 case static_cast<int>( |
517 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON): | 521 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON): |
518 dialog()->ShowContactProfileSheet(); | 522 dialog()->ShowContactProfileSheet(); |
519 break; | 523 break; |
520 | 524 |
521 case static_cast<int>( | 525 case static_cast<int>( |
522 PaymentSheetViewControllerTags::ADD_CONTACT_INFO_BUTTON): | 526 PaymentSheetViewControllerTags::ADD_CONTACT_INFO_BUTTON): |
523 dialog()->ShowContactInfoEditor(); | 527 dialog()->ShowContactInfoEditor(BackNavigationType::kPaymentSheet); |
524 break; | 528 break; |
525 | 529 |
526 case static_cast<int>( | 530 case static_cast<int>( |
527 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON): | 531 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON): |
528 dialog()->ShowShippingOptionSheet(); | 532 dialog()->ShowShippingOptionSheet(); |
529 break; | 533 break; |
530 | 534 |
531 default: | 535 default: |
532 PaymentRequestSheetController::ButtonPressed(sender, event); | 536 PaymentRequestSheetController::ButtonPressed(sender, event); |
533 break; | 537 break; |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 } else { | 892 } else { |
889 return builder | 893 return builder |
890 .Id(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON) | 894 .Id(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON) |
891 .CreateWithButton( | 895 .CreateWithButton( |
892 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CHOOSE_AN_ADDRESS), | 896 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CHOOSE_AN_ADDRESS), |
893 l10n_util::GetStringUTF16(IDS_CHOOSE), /*button_enabled=*/false); | 897 l10n_util::GetStringUTF16(IDS_CHOOSE), /*button_enabled=*/false); |
894 } | 898 } |
895 } | 899 } |
896 | 900 |
897 } // namespace payments | 901 } // namespace payments |
OLD | NEW |