| 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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 618 |
| 619 return builder.CreateWithChevron(std::move(item_summaries), | 619 return builder.CreateWithChevron(std::move(item_summaries), |
| 620 std::move(item_amounts)); | 620 std::move(item_amounts)); |
| 621 } | 621 } |
| 622 | 622 |
| 623 std::unique_ptr<views::View> | 623 std::unique_ptr<views::View> |
| 624 PaymentSheetViewController::CreateShippingSectionContent() { | 624 PaymentSheetViewController::CreateShippingSectionContent() { |
| 625 if (current_update_reason_ == | 625 if (current_update_reason_ == |
| 626 PaymentRequestSpec::UpdateReason::SHIPPING_ADDRESS) { | 626 PaymentRequestSpec::UpdateReason::SHIPPING_ADDRESS) { |
| 627 return CreateCheckingSpinnerView(); | 627 return CreateCheckingSpinnerView(); |
| 628 } |
| 629 |
| 630 autofill::AutofillProfile* profile = state()->selected_shipping_profile(); |
| 631 if (!profile) |
| 632 return base::MakeUnique<views::Label>(base::string16()); |
| 633 |
| 634 // If there is a shipping option error related to the selected address, |
| 635 // display it (without disabling the row because the user should feel like |
| 636 // they can click on it to correct the problem). Otherwise, display the |
| 637 // address possibly with the missing information to make it complete. |
| 638 if (!spec()->selected_shipping_option_error().empty()) { |
| 639 return GetShippingAddressLabelWithError( |
| 640 AddressStyleType::SUMMARY, state()->GetApplicationLocale(), *profile, |
| 641 spec()->selected_shipping_option_error(), /*disabled_state=*/false); |
| 628 } else { | 642 } else { |
| 629 auto* profile = state()->selected_shipping_profile(); | 643 return GetShippingAddressLabelWithMissingInfo( |
| 630 | 644 AddressStyleType::SUMMARY, state()->GetApplicationLocale(), *profile, |
| 631 return profile | 645 *(state()->profile_comparator())); |
| 632 ? GetShippingAddressLabel( | |
| 633 AddressStyleType::SUMMARY, state()->GetApplicationLocale(), | |
| 634 *profile, *spec(), *(state()->profile_comparator())) | |
| 635 : base::MakeUnique<views::Label>(base::string16()); | |
| 636 } | 646 } |
| 637 } | 647 } |
| 638 | 648 |
| 639 // Creates the Shipping row, which contains a "Shipping address" label, the | 649 // Creates the Shipping row, which contains a "Shipping address" label, the |
| 640 // user's selected shipping address, and a chevron. | 650 // user's selected shipping address, and a chevron. |
| 641 // +----------------------------------------------+ | 651 // +----------------------------------------------+ |
| 642 // | Shipping Address Barack Obama | | 652 // | Shipping Address Barack Obama | |
| 643 // | 1600 Pennsylvania Ave. > | | 653 // | 1600 Pennsylvania Ave. > | |
| 644 // | 1800MYPOTUS | | 654 // | 1800MYPOTUS | |
| 645 // +----------------------------------------------+ | 655 // +----------------------------------------------+ |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 } else { | 898 } else { |
| 889 return builder | 899 return builder |
| 890 .Id(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON) | 900 .Id(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON) |
| 891 .CreateWithButton( | 901 .CreateWithButton( |
| 892 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CHOOSE_AN_ADDRESS), | 902 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CHOOSE_AN_ADDRESS), |
| 893 l10n_util::GetStringUTF16(IDS_CHOOSE), /*button_enabled=*/false); | 903 l10n_util::GetStringUTF16(IDS_CHOOSE), /*button_enabled=*/false); |
| 894 } | 904 } |
| 895 } | 905 } |
| 896 | 906 |
| 897 } // namespace payments | 907 } // namespace payments |
| OLD | NEW |