OLD | NEW |
---|---|
(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 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ | |
7 | |
8 #include <memory> | |
9 #include <vector> | |
10 | |
11 #include "base/macros.h" | |
12 | |
13 namespace views { | |
14 class View; | |
15 } | |
16 | |
17 namespace payments { | |
18 | |
19 // A control representing a list of selectable items in the PaymentRequest | |
20 // dialog. These lists enforce that only one of their elements be selectable at | |
21 // a time and that "incomplete" items (for example, a credit card with no known | |
22 // expriration date) behave differently when selected. Most of the time, this | |
23 // behavior is to show an editor screen. | |
24 class PaymentRequestItemList { | |
25 public: | |
26 // Represents an item in the item list. | |
27 class Item { | |
28 public: | |
29 Item(); | |
30 virtual ~Item(); | |
31 | |
32 // Gets the view associated with this item. It's owned by this object so | |
33 // that it can listen to any changes to the underlying model and update the | |
34 // view. | |
please use gerrit instead
2017/02/14 00:29:14
Excellent comment!
anthonyvd
2017/02/22 20:15:21
Thanks!
| |
35 views::View* GetItemView(); | |
36 | |
37 protected: | |
38 // Creates and returns the view associated with this list item. | |
39 virtual std::unique_ptr<views::View> CreateItemView() = 0; | |
40 | |
41 private: | |
42 std::unique_ptr<views::View> item_view_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(Item); | |
45 }; | |
46 | |
47 PaymentRequestItemList(); | |
48 ~PaymentRequestItemList(); | |
49 | |
50 // Adds an item to this list. | |
51 void AddItem(std::unique_ptr<Item> item); | |
52 | |
53 // Creates and returns the UI representation of this list. It iterates over | |
54 // the items it contains, creates their associated views, and adds them to the | |
55 // hierarchy. | |
56 std::unique_ptr<views::View> CreateListView(); | |
57 | |
58 private: | |
59 std::vector<std::unique_ptr<Item>> items_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList); | |
62 }; | |
63 | |
64 } // namespace payments | |
65 | |
66 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ | |
OLD | NEW |