Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: chrome/browser/ui/views/payments/shipping_option_view_controller.cc

Issue 2789093002: [Payments] Desktop: implement shipping address/option change (Closed)
Patch Set: compile fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/payments/profile_list_view_controller.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/views/layout/fill_layout.h" 11 #include "ui/views/layout/fill_layout.h"
12 12
13 namespace payments { 13 namespace payments {
14 14
15 namespace { 15 namespace {
16 16
17 class ShippingOptionItem : public PaymentRequestItemList::Item { 17 class ShippingOptionItem : public PaymentRequestItemList::Item {
18 public: 18 public:
19 ShippingOptionItem(payments::mojom::PaymentShippingOption* shipping_option, 19 ShippingOptionItem(mojom::PaymentShippingOption* shipping_option,
20 PaymentRequestSpec* spec, 20 PaymentRequestSpec* spec,
21 PaymentRequestState* state, 21 PaymentRequestState* state,
22 PaymentRequestItemList* parent_list, 22 PaymentRequestItemList* parent_list,
23 PaymentRequestDialogView* dialog, 23 PaymentRequestDialogView* dialog,
24 bool selected) 24 bool selected)
25 : PaymentRequestItemList::Item(spec, state, parent_list, selected), 25 : PaymentRequestItemList::Item(spec, state, parent_list, selected),
26 shipping_option_(shipping_option), 26 shipping_option_(shipping_option),
27 dialog_(dialog) {} 27 dialog_(dialog) {}
28 ~ShippingOptionItem() override {} 28 ~ShippingOptionItem() override {}
29 29
30 private: 30 private:
31 // payments::PaymentRequestItemList::Item: 31 // payments::PaymentRequestItemList::Item:
32 std::unique_ptr<views::View> CreateContentView() override { 32 std::unique_ptr<views::View> CreateContentView() override {
33 return CreateShippingOptionLabel( 33 return CreateShippingOptionLabel(
34 shipping_option_, 34 shipping_option_,
35 spec()->GetFormattedCurrencyAmount(shipping_option_->amount->value)); 35 spec()->GetFormattedCurrencyAmount(shipping_option_->amount->value));
36 } 36 }
37 37
38 void SelectedStateChanged() override { 38 void SelectedStateChanged() override {
39 if (selected()) { 39 if (selected()) {
40 state()->SetSelectedShippingOption(shipping_option_); 40 state()->SetSelectedShippingOption(shipping_option_->id);
41 dialog_->GoBack(); 41 dialog_->GoBack();
42 } 42 }
43 } 43 }
44 44
45 bool CanBeSelected() const override { 45 bool CanBeSelected() const override {
46 // Shipping options are vetted by the website; they're all OK to select. 46 // Shipping options are vetted by the website; they're all OK to select.
47 return true; 47 return true;
48 } 48 }
49 49
50 void PerformSelectionFallback() override { 50 void PerformSelectionFallback() override {
(...skipping 10 matching lines...) Expand all
61 } // namespace 61 } // namespace
62 62
63 ShippingOptionViewController::ShippingOptionViewController( 63 ShippingOptionViewController::ShippingOptionViewController(
64 PaymentRequestSpec* spec, 64 PaymentRequestSpec* spec,
65 PaymentRequestState* state, 65 PaymentRequestState* state,
66 PaymentRequestDialogView* dialog) 66 PaymentRequestDialogView* dialog)
67 : PaymentRequestSheetController(spec, state, dialog) { 67 : PaymentRequestSheetController(spec, state, dialog) {
68 for (const auto& option : spec->details().shipping_options) { 68 for (const auto& option : spec->details().shipping_options) {
69 shipping_option_list_.AddItem(base::MakeUnique<ShippingOptionItem>( 69 shipping_option_list_.AddItem(base::MakeUnique<ShippingOptionItem>(
70 option.get(), spec, state, &shipping_option_list_, dialog, 70 option.get(), spec, state, &shipping_option_list_, dialog,
71 option.get() == state->selected_shipping_option())); 71 option.get() == spec->selected_shipping_option()));
72 } 72 }
73 } 73 }
74 74
75 ShippingOptionViewController::~ShippingOptionViewController() {} 75 ShippingOptionViewController::~ShippingOptionViewController() {}
76 76
77 base::string16 ShippingOptionViewController::GetSheetTitle() { 77 base::string16 ShippingOptionViewController::GetSheetTitle() {
78 return GetShippingOptionSectionString(spec()->shipping_type()); 78 return GetShippingOptionSectionString(spec()->shipping_type());
79 } 79 }
80 80
81 void ShippingOptionViewController::FillContentView(views::View* content_view) { 81 void ShippingOptionViewController::FillContentView(views::View* content_view) {
82 content_view->SetLayoutManager(new views::FillLayout); 82 content_view->SetLayoutManager(new views::FillLayout);
83 content_view->AddChildView(shipping_option_list_.CreateListView().release()); 83 content_view->AddChildView(shipping_option_list_.CreateListView().release());
84 } 84 }
85 85
86 std::unique_ptr<views::View> 86 std::unique_ptr<views::View>
87 ShippingOptionViewController::CreateExtraFooterView() { 87 ShippingOptionViewController::CreateExtraFooterView() {
88 return nullptr; 88 return nullptr;
89 } 89 }
90 90
91 } // namespace payments 91 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/profile_list_view_controller.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698