Chromium Code Reviews| 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_views_util.h" | 7 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| 8 #include "components/payments/content/payment_request_spec.h" | 8 #include "components/payments/content/payment_request_spec.h" |
| 9 #include "components/payments/content/payment_request_state.h" | 9 #include "components/payments/content/payment_request_state.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 ~ShippingOptionItem() override {} | 24 ~ShippingOptionItem() override {} |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 // payments::PaymentRequestItemList::Item: | 27 // payments::PaymentRequestItemList::Item: |
| 28 std::unique_ptr<views::View> CreateContentView() override { | 28 std::unique_ptr<views::View> CreateContentView() override { |
| 29 return CreateShippingOptionLabel( | 29 return CreateShippingOptionLabel( |
| 30 shipping_option_, | 30 shipping_option_, |
| 31 spec()->GetFormattedCurrencyAmount(shipping_option_->amount->value)); | 31 spec()->GetFormattedCurrencyAmount(shipping_option_->amount->value)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void SelectedStateChanged() override {} | 34 void SelectedStateChanged() override { |
|
Mathieu
2017/03/21 13:56:59
We always seem to use SelectedStateChanged + selec
anthonyvd
2017/03/21 14:56:06
Yeah I thought about this too. I think it just hap
| |
| 35 if (selected()) | |
| 36 state()->SetSelectedShippingOption(shipping_option_); | |
| 37 } | |
| 35 | 38 |
| 36 bool CanBeSelected() const override { | 39 bool CanBeSelected() const override { |
| 37 // Shipping options are vetted by the website; they're all OK to select. | 40 // Shipping options are vetted by the website; they're all OK to select. |
| 38 return true; | 41 return true; |
| 39 } | 42 } |
| 40 | 43 |
| 41 void PerformSelectionFallback() override { | 44 void PerformSelectionFallback() override { |
| 42 // Since CanBeSelected() is always true, this should never be called. | 45 // Since CanBeSelected() is always true, this should never be called. |
| 43 NOTREACHED(); | 46 NOTREACHED(); |
| 44 } | 47 } |
| 45 | 48 |
| 46 mojom::PaymentShippingOption* shipping_option_; | 49 mojom::PaymentShippingOption* shipping_option_; |
| 47 | 50 |
| 48 DISALLOW_COPY_AND_ASSIGN(ShippingOptionItem); | 51 DISALLOW_COPY_AND_ASSIGN(ShippingOptionItem); |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 } // namespace | 54 } // namespace |
| 52 | 55 |
| 53 ShippingOptionViewController::ShippingOptionViewController( | 56 ShippingOptionViewController::ShippingOptionViewController( |
| 54 PaymentRequestSpec* spec, | 57 PaymentRequestSpec* spec, |
| 55 PaymentRequestState* state, | 58 PaymentRequestState* state, |
| 56 PaymentRequestDialogView* dialog) | 59 PaymentRequestDialogView* dialog) |
| 57 : PaymentRequestSheetController(spec, state, dialog) { | 60 : PaymentRequestSheetController(spec, state, dialog), |
| 61 shipping_option_list_(dialog) { | |
| 58 for (const auto& option : spec->details().shipping_options) { | 62 for (const auto& option : spec->details().shipping_options) { |
| 59 shipping_option_list_.AddItem(base::MakeUnique<ShippingOptionItem>( | 63 shipping_option_list_.AddItem(base::MakeUnique<ShippingOptionItem>( |
| 60 option.get(), spec, state, &shipping_option_list_, | 64 option.get(), spec, state, &shipping_option_list_, |
| 61 option.get() == state->selected_shipping_option())); | 65 option.get() == state->selected_shipping_option())); |
| 62 } | 66 } |
| 63 } | 67 } |
| 64 | 68 |
| 65 ShippingOptionViewController::~ShippingOptionViewController() {} | 69 ShippingOptionViewController::~ShippingOptionViewController() {} |
| 66 | 70 |
| 67 std::unique_ptr<views::View> ShippingOptionViewController::CreateView() { | 71 std::unique_ptr<views::View> ShippingOptionViewController::CreateView() { |
| 68 std::unique_ptr<views::View> list_view = | 72 std::unique_ptr<views::View> list_view = |
| 69 shipping_option_list_.CreateListView(); | 73 shipping_option_list_.CreateListView(); |
| 70 return CreatePaymentView( | 74 return CreatePaymentView( |
| 71 CreateSheetHeaderView( | 75 CreateSheetHeaderView( |
| 72 true, GetShippingOptionSectionString(spec()->options().shipping_type), | 76 true, GetShippingOptionSectionString(spec()->options().shipping_type), |
| 73 this), | 77 this), |
| 74 std::move(list_view)); | 78 std::move(list_view)); |
| 75 } | 79 } |
| 76 | 80 |
| 77 std::unique_ptr<views::View> | 81 std::unique_ptr<views::View> |
| 78 ShippingOptionViewController::CreateExtraFooterView() { | 82 ShippingOptionViewController::CreateExtraFooterView() { |
| 79 return nullptr; | 83 return nullptr; |
| 80 } | 84 } |
| 81 | 85 |
| 82 } // namespace payments | 86 } // namespace payments |
| OLD | NEW |