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

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

Issue 2747943004: [Web Payments] Add the shipping options sheet. (Closed)
Patch Set: Address comments. Created 3 years, 9 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/shipping_option_view_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_option_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 mojom::PaymentShippingOption* shipping_option_;
35
36 DISALLOW_COPY_AND_ASSIGN(ShippingOptionItem);
37 };
38
39 } // namespace
40
41 ShippingOptionViewController::ShippingOptionViewController(
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 ShippingOptionViewController::~ShippingOptionViewController() {}
53
54 std::unique_ptr<views::View> ShippingOptionViewController::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 ShippingOptionViewController::CreateExtraFooterView() {
67 return nullptr;
68 }
69
70 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/shipping_option_view_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698