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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_item_list.h

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 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 // Returns a pointer to the PaymentRequestItemList that owns this object. 52 // Returns a pointer to the PaymentRequestItemList that owns this object.
53 PaymentRequestItemList* list() { return list_; } 53 PaymentRequestItemList* list() { return list_; }
54 54
55 // Returns a pointer to the PaymentRequestSpec/State objects associated with 55 // Returns a pointer to the PaymentRequestSpec/State objects associated with
56 // this instance of the UI. 56 // this instance of the UI.
57 PaymentRequestSpec* spec() { return spec_; } 57 PaymentRequestSpec* spec() { return spec_; }
58 PaymentRequestState* state() { return state_; } 58 PaymentRequestState* state() { return state_; }
59 59
60 protected: 60 protected:
61 // Creates and returns the view associated with this list item.
62 virtual std::unique_ptr<views::View> CreateItemView() = 0;
63
64 // Called when the selected state of this item changes. Subclasses may 61 // Called when the selected state of this item changes. Subclasses may
65 // assume that they are the only selected item in |list| when this is 62 // assume that they are the only selected item in |list| when this is
66 // called. This could be called before CreateItemView so subclasses should 63 // called. This could be called before CreateItemView so subclasses should
67 // be aware that their views might not exist yet. 64 // be aware that their views might not exist yet.
68 virtual void SelectedStateChanged() = 0; 65 virtual void SelectedStateChanged() = 0;
69 66
70 // Creates an image of a large checkmark, used to indicate that an option is 67 // Creates an image of a large checkmark, used to indicate that an option is
71 // selected. 68 // selected.
72 std::unique_ptr<views::ImageView> CreateCheckmark(bool selected); 69 std::unique_ptr<views::ImageView> CreateCheckmark(bool selected);
73 70
71 virtual std::unique_ptr<views::View> CreateContentView() = 0;
72 virtual std::unique_ptr<views::View> CreateExtraView();
73
74 virtual bool CanBeSelected() const = 0;
75 virtual void PerformSelectionFallback() = 0;
76
74 private: 77 private:
78 // Creates and returns the view associated with this list item.
79 std::unique_ptr<views::View> CreateItemView();
80
75 // views::ButtonListener: 81 // views::ButtonListener:
76 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 82 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
77 }
78 83
79 std::unique_ptr<views::View> item_view_; 84 std::unique_ptr<views::View> item_view_;
80 PaymentRequestSpec* spec_; 85 PaymentRequestSpec* spec_;
81 PaymentRequestState* state_; 86 PaymentRequestState* state_;
82 PaymentRequestItemList* list_; 87 PaymentRequestItemList* list_;
88 std::unique_ptr<views::ImageView> checkmark_;
83 bool selected_; 89 bool selected_;
84 90
85 DISALLOW_COPY_AND_ASSIGN(Item); 91 DISALLOW_COPY_AND_ASSIGN(Item);
86 }; 92 };
87 93
88 PaymentRequestItemList(); 94 PaymentRequestItemList();
89 virtual ~PaymentRequestItemList(); 95 virtual ~PaymentRequestItemList();
90 96
91 // Adds an item to this list. |item->list()| should return this object. 97 // Adds an item to this list. |item->list()| should return this object.
92 void AddItem(std::unique_ptr<Item> item); 98 void AddItem(std::unique_ptr<Item> item);
(...skipping 14 matching lines...) Expand all
107 113
108 std::vector<std::unique_ptr<Item>> items_; 114 std::vector<std::unique_ptr<Item>> items_;
109 Item* selected_item_; 115 Item* selected_item_;
110 116
111 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList); 117 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList);
112 }; 118 };
113 119
114 } // namespace payments 120 } // namespace payments
115 121
116 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ 122 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698