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

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

Issue 2755493005: [Web Payments] Consolidate list code. (Closed)
Patch Set: Fix test compile. 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 // Creates the view that represents this item's content. Typically this will
72 // be a label describing the payment method, shipping adress, etc.
73 virtual std::unique_ptr<views::View> CreateContentView() = 0;
74
75 // Creates the view that should be displayed after the checkmark in the
76 // item's view, such as the credit card icon.
77 virtual std::unique_ptr<views::View> CreateExtraView();
78
79 // Returns whether this item is complete/valid and can be selected by the
80 // user. If this returns false when the user attempts to select this item,
81 // PerformSelectionFallback will be called instead.
82 virtual bool CanBeSelected() const = 0;
83
84 // Performs the action that replaces selection when CanBeSelected returns
85 // false. This will usually be to display an editor.
86 virtual void PerformSelectionFallback() = 0;
87
74 private: 88 private:
89 // Creates and returns the view associated with this list item.
90 std::unique_ptr<views::View> CreateItemView();
91
75 // views::ButtonListener: 92 // views::ButtonListener:
76 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 93 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
77 }
78 94
79 std::unique_ptr<views::View> item_view_; 95 std::unique_ptr<views::View> item_view_;
80 PaymentRequestSpec* spec_; 96 PaymentRequestSpec* spec_;
81 PaymentRequestState* state_; 97 PaymentRequestState* state_;
82 PaymentRequestItemList* list_; 98 PaymentRequestItemList* list_;
99 std::unique_ptr<views::ImageView> checkmark_;
83 bool selected_; 100 bool selected_;
84 101
85 DISALLOW_COPY_AND_ASSIGN(Item); 102 DISALLOW_COPY_AND_ASSIGN(Item);
86 }; 103 };
87 104
88 PaymentRequestItemList(); 105 PaymentRequestItemList();
89 virtual ~PaymentRequestItemList(); 106 virtual ~PaymentRequestItemList();
90 107
91 // Adds an item to this list. |item->list()| should return this object. 108 // Adds an item to this list. |item->list()| should return this object.
92 void AddItem(std::unique_ptr<Item> item); 109 void AddItem(std::unique_ptr<Item> item);
(...skipping 14 matching lines...) Expand all
107 124
108 std::vector<std::unique_ptr<Item>> items_; 125 std::vector<std::unique_ptr<Item>> items_;
109 Item* selected_item_; 126 Item* selected_item_;
110 127
111 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList); 128 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList);
112 }; 129 };
113 130
114 } // namespace payments 131 } // namespace payments
115 132
116 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ 133 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698