Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/payments/shipping_options_view_controller.h" | |
| 6 | |
| 7 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | |
| 8 #include "components/payments/content/payment_request.h" | |
| 9 | |
| 10 namespace payments { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 class ShippingOptionItem : public PaymentRequestItemList::Item { | |
| 15 public: | |
| 16 ShippingOptionItem(payments::mojom::PaymentShippingOption* shipping_option, | |
| 17 PaymentRequest* request, | |
| 18 PaymentRequestItemList* parent_list, | |
| 19 bool selected) | |
| 20 : PaymentRequestItemList::Item(request, parent_list, selected), | |
| 21 shipping_option_(shipping_option) {} | |
| 22 ~ShippingOptionItem() override {} | |
| 23 | |
| 24 private: | |
| 25 // payments::PaymentRequestItemList::Item: | |
| 26 std::unique_ptr<views::View> CreateItemView() override { | |
| 27 return CreateShippingOptionLabel( | |
| 28 shipping_option_, | |
| 29 request()->GetFormattedCurrencyAmount(shipping_option_->amount->value)); | |
| 30 } | |
| 31 | |
| 32 void SelectedStateChanged() override {} | |
| 33 | |
| 34 payments::mojom::PaymentShippingOption* shipping_option_; | |
|
Mathieu
2017/03/14 20:17:12
No need for payments::
anthonyvd
2017/03/14 20:26:16
Done.
| |
| 35 | |
| 36 DISALLOW_COPY_AND_ASSIGN(ShippingOptionItem); | |
| 37 }; | |
| 38 | |
| 39 } // namespace | |
| 40 | |
| 41 ShippingOptionsViewController::ShippingOptionsViewController( | |
| 42 PaymentRequest* request, | |
| 43 PaymentRequestDialogView* dialog) | |
| 44 : PaymentRequestSheetController(request, dialog) { | |
| 45 for (const auto& option : request->details()->shipping_options) { | |
| 46 shipping_option_list_.AddItem(base::MakeUnique<ShippingOptionItem>( | |
| 47 option.get(), request, &shipping_option_list_, | |
| 48 option.get() == request->selected_shipping_option())); | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 ShippingOptionsViewController::~ShippingOptionsViewController() {} | |
| 53 | |
| 54 std::unique_ptr<views::View> ShippingOptionsViewController::CreateView() { | |
| 55 std::unique_ptr<views::View> list_view = | |
| 56 shipping_option_list_.CreateListView(); | |
| 57 return CreatePaymentView( | |
| 58 CreateSheetHeaderView( | |
| 59 true, | |
| 60 GetShippingOptionSectionString(request()->options()->shipping_type), | |
| 61 this), | |
| 62 std::move(list_view)); | |
| 63 } | |
| 64 | |
| 65 std::unique_ptr<views::View> | |
| 66 ShippingOptionsViewController::CreateExtraFooterView() { | |
| 67 return nullptr; | |
| 68 } | |
| 69 | |
| 70 void ShippingOptionsViewController::ButtonPressed(views::Button* sender, | |
| 71 const ui::Event& event) { | |
| 72 PaymentRequestSheetController::ButtonPressed(sender, event); | |
| 73 } | |
| 74 | |
| 75 } // namespace payments | |
| OLD | NEW |