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

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

Issue 2755493005: [Web Payments] Consolidate list code. (Closed)
Patch Set: Move selection logic to base. 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
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_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
11 namespace payments { 11 namespace payments {
12 12
13 namespace { 13 namespace {
14 14
15 class ShippingOptionItem : public PaymentRequestItemList::Item { 15 class ShippingOptionItem : public PaymentRequestItemList::Item {
16 public: 16 public:
17 ShippingOptionItem(payments::mojom::PaymentShippingOption* shipping_option, 17 ShippingOptionItem(payments::mojom::PaymentShippingOption* shipping_option,
18 PaymentRequestSpec* spec, 18 PaymentRequestSpec* spec,
19 PaymentRequestState* state, 19 PaymentRequestState* state,
20 PaymentRequestItemList* parent_list, 20 PaymentRequestItemList* parent_list,
21 bool selected) 21 bool selected)
22 : PaymentRequestItemList::Item(spec, state, parent_list, selected), 22 : PaymentRequestItemList::Item(spec, state, parent_list, selected),
23 shipping_option_(shipping_option) {} 23 shipping_option_(shipping_option) {}
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> CreateItemView() 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 {}
35 35
36 bool CanBeSelected() const override {
37 // Shipping options are vetted by the website, they're all OK to select.
tmartino 2017/03/16 17:42:01 Omega nit: this should be a semicolon, not a comma
anthonyvd 2017/03/20 13:24:59 Done!
38 return true;
39 }
40
41 void PerformSelectionFallback() override {
42 // Since CanBeSelected() is always true, this should never be called.
43 NOTREACHED();
44 }
45
36 mojom::PaymentShippingOption* shipping_option_; 46 mojom::PaymentShippingOption* shipping_option_;
37 47
38 DISALLOW_COPY_AND_ASSIGN(ShippingOptionItem); 48 DISALLOW_COPY_AND_ASSIGN(ShippingOptionItem);
39 }; 49 };
40 50
41 } // namespace 51 } // namespace
42 52
43 ShippingOptionViewController::ShippingOptionViewController( 53 ShippingOptionViewController::ShippingOptionViewController(
44 PaymentRequestSpec* spec, 54 PaymentRequestSpec* spec,
45 PaymentRequestState* state, 55 PaymentRequestState* state,
(...skipping 17 matching lines...) Expand all
63 this), 73 this),
64 std::move(list_view)); 74 std::move(list_view));
65 } 75 }
66 76
67 std::unique_ptr<views::View> 77 std::unique_ptr<views::View>
68 ShippingOptionViewController::CreateExtraFooterView() { 78 ShippingOptionViewController::CreateExtraFooterView() {
69 return nullptr; 79 return nullptr;
70 } 80 }
71 81
72 } // namespace payments 82 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698