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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 590 |
591 return builder.CreateWithChevron(std::move(item_summaries), | 591 return builder.CreateWithChevron(std::move(item_summaries), |
592 std::move(item_amounts)); | 592 std::move(item_amounts)); |
593 } | 593 } |
594 | 594 |
595 std::unique_ptr<views::View> | 595 std::unique_ptr<views::View> |
596 PaymentSheetViewController::CreateShippingSectionContent() { | 596 PaymentSheetViewController::CreateShippingSectionContent() { |
597 if (current_update_reason_ == | 597 if (current_update_reason_ == |
598 PaymentRequestSpec::UpdateReason::SHIPPING_ADDRESS) { | 598 PaymentRequestSpec::UpdateReason::SHIPPING_ADDRESS) { |
599 return CreateCheckingSpinnerView(); | 599 return CreateCheckingSpinnerView(); |
| 600 } |
| 601 |
| 602 autofill::AutofillProfile* profile = state()->selected_shipping_profile(); |
| 603 if (!profile) |
| 604 return base::MakeUnique<views::Label>(base::string16()); |
| 605 |
| 606 // If there is a shipping option error related to the selected address, |
| 607 // display it (without disabling the row because the user should feel like |
| 608 // they can click on it to correct the problem). Otherwise, display the |
| 609 // address possibly with the missing information to make it complete. |
| 610 if (!spec()->selected_shipping_option_error().empty()) { |
| 611 return GetShippingAddressLabelWithError( |
| 612 AddressStyleType::SUMMARY, state()->GetApplicationLocale(), *profile, |
| 613 spec()->selected_shipping_option_error(), /*disabled_state=*/false); |
600 } else { | 614 } else { |
601 auto* profile = state()->selected_shipping_profile(); | 615 return GetShippingAddressLabelWithMissingInfo( |
602 | 616 AddressStyleType::SUMMARY, state()->GetApplicationLocale(), *profile, |
603 return profile | 617 *(state()->profile_comparator())); |
604 ? GetShippingAddressLabel( | |
605 AddressStyleType::SUMMARY, state()->GetApplicationLocale(), | |
606 *profile, *spec(), *(state()->profile_comparator())) | |
607 : base::MakeUnique<views::Label>(base::string16()); | |
608 } | 618 } |
609 } | 619 } |
610 | 620 |
611 // Creates the Shipping row, which contains a "Shipping address" label, the | 621 // Creates the Shipping row, which contains a "Shipping address" label, the |
612 // user's selected shipping address, and a chevron. | 622 // user's selected shipping address, and a chevron. |
613 // +----------------------------------------------+ | 623 // +----------------------------------------------+ |
614 // | Shipping Address Barack Obama | | 624 // | Shipping Address Barack Obama | |
615 // | 1600 Pennsylvania Ave. > | | 625 // | 1600 Pennsylvania Ave. > | |
616 // | 1800MYPOTUS | | 626 // | 1800MYPOTUS | |
617 // +----------------------------------------------+ | 627 // +----------------------------------------------+ |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 } else { | 866 } else { |
857 return builder | 867 return builder |
858 .Id(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON) | 868 .Id(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON) |
859 .CreateWithButton( | 869 .CreateWithButton( |
860 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CHOOSE_AN_ADDRESS), | 870 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CHOOSE_AN_ADDRESS), |
861 l10n_util::GetStringUTF16(IDS_CHOOSE), /*button_enabled=*/false); | 871 l10n_util::GetStringUTF16(IDS_CHOOSE), /*button_enabled=*/false); |
862 } | 872 } |
863 } | 873 } |
864 | 874 |
865 } // namespace payments | 875 } // namespace payments |
OLD | NEW |