| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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/shipping_option_view_controller.h" | 5 #include "chrome/browser/ui/views/payments/shipping_option_view_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
| 8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | 8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| 9 #include "components/payments/content/payment_request_spec.h" | 9 #include "components/payments/content/payment_request_spec.h" |
| 10 #include "components/payments/content/payment_request_state.h" | 10 #include "components/payments/content/payment_request_state.h" |
| 11 #include "components/payments/core/strings_util.h" | 11 #include "components/payments/core/strings_util.h" |
| 12 #include "ui/views/layout/fill_layout.h" | 12 #include "ui/views/layout/fill_layout.h" |
| 13 | 13 |
| 14 namespace payments { | 14 namespace payments { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 class ShippingOptionItem : public PaymentRequestItemList::Item { | 18 class ShippingOptionItem : public PaymentRequestItemList::Item { |
| 19 public: | 19 public: |
| 20 ShippingOptionItem(mojom::PaymentShippingOption* shipping_option, | 20 ShippingOptionItem(mojom::PaymentShippingOption* shipping_option, |
| 21 PaymentRequestSpec* spec, | 21 PaymentRequestSpec* spec, |
| 22 PaymentRequestState* state, | 22 PaymentRequestState* state, |
| 23 PaymentRequestItemList* parent_list, | 23 PaymentRequestItemList* parent_list, |
| 24 PaymentRequestDialogView* dialog, | 24 PaymentRequestDialogView* dialog, |
| 25 bool selected) | 25 bool selected) |
| 26 : PaymentRequestItemList::Item(spec, state, parent_list, selected), | 26 : PaymentRequestItemList::Item(spec, |
| 27 state, |
| 28 parent_list, |
| 29 selected, |
| 30 /*show_edit_button=*/false), |
| 27 shipping_option_(shipping_option), | 31 shipping_option_(shipping_option), |
| 28 dialog_(dialog) {} | 32 dialog_(dialog) {} |
| 29 ~ShippingOptionItem() override {} | 33 ~ShippingOptionItem() override {} |
| 30 | 34 |
| 31 private: | 35 private: |
| 32 // payments::PaymentRequestItemList::Item: | 36 // payments::PaymentRequestItemList::Item: |
| 33 std::unique_ptr<views::View> CreateContentView() override { | 37 std::unique_ptr<views::View> CreateContentView() override { |
| 34 return CreateShippingOptionLabel( | 38 return CreateShippingOptionLabel( |
| 35 shipping_option_, | 39 shipping_option_, |
| 36 spec()->GetFormattedCurrencyAmount(shipping_option_->amount), | 40 spec()->GetFormattedCurrencyAmount(shipping_option_->amount), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 52 bool CanBeSelected() override { | 56 bool CanBeSelected() override { |
| 53 // Shipping options are vetted by the website; they're all OK to select. | 57 // Shipping options are vetted by the website; they're all OK to select. |
| 54 return true; | 58 return true; |
| 55 } | 59 } |
| 56 | 60 |
| 57 void PerformSelectionFallback() override { | 61 void PerformSelectionFallback() override { |
| 58 // Since CanBeSelected() is always true, this should never be called. | 62 // Since CanBeSelected() is always true, this should never be called. |
| 59 NOTREACHED(); | 63 NOTREACHED(); |
| 60 } | 64 } |
| 61 | 65 |
| 66 void EditButtonPressed() override { |
| 67 // This subclass doesn't display the edit button. |
| 68 NOTREACHED(); |
| 69 } |
| 70 |
| 62 mojom::PaymentShippingOption* shipping_option_; | 71 mojom::PaymentShippingOption* shipping_option_; |
| 63 PaymentRequestDialogView* dialog_; | 72 PaymentRequestDialogView* dialog_; |
| 64 | 73 |
| 65 DISALLOW_COPY_AND_ASSIGN(ShippingOptionItem); | 74 DISALLOW_COPY_AND_ASSIGN(ShippingOptionItem); |
| 66 }; | 75 }; |
| 67 | 76 |
| 68 } // namespace | 77 } // namespace |
| 69 | 78 |
| 70 ShippingOptionViewController::ShippingOptionViewController( | 79 ShippingOptionViewController::ShippingOptionViewController( |
| 71 PaymentRequestSpec* spec, | 80 PaymentRequestSpec* spec, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 96 content_view->SetLayoutManager(new views::FillLayout); | 105 content_view->SetLayoutManager(new views::FillLayout); |
| 97 content_view->AddChildView(shipping_option_list_.CreateListView().release()); | 106 content_view->AddChildView(shipping_option_list_.CreateListView().release()); |
| 98 } | 107 } |
| 99 | 108 |
| 100 std::unique_ptr<views::View> | 109 std::unique_ptr<views::View> |
| 101 ShippingOptionViewController::CreateExtraFooterView() { | 110 ShippingOptionViewController::CreateExtraFooterView() { |
| 102 return nullptr; | 111 return nullptr; |
| 103 } | 112 } |
| 104 | 113 |
| 105 } // namespace payments | 114 } // namespace payments |
| OLD | NEW |