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

Unified Diff: chrome/browser/ui/views/payments/payment_request_item_list.h

Issue 2711973002: [Web Payments] Implement the credit card selection UI functionality. (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/payment_request_item_list.h
diff --git a/chrome/browser/ui/views/payments/payment_request_item_list.h b/chrome/browser/ui/views/payments/payment_request_item_list.h
index 71f4c04812d6eb0903b96538f6c6f5dab4fb23ab..167d38627113019774de9f69d773b78b518e6932 100644
--- a/chrome/browser/ui/views/payments/payment_request_item_list.h
+++ b/chrome/browser/ui/views/payments/payment_request_item_list.h
@@ -19,14 +19,16 @@ namespace payments {
// A control representing a list of selectable items in the PaymentRequest
// dialog. These lists enforce that only one of their elements be selectable at
// a time and that "incomplete" items (for example, a credit card with no known
-// expriration date) behave differently when selected. Most of the time, this
+// expiration date) behave differently when selected. Most of the time, this
// behavior is to show an editor screen.
class PaymentRequestItemList {
public:
// Represents an item in the item list.
class Item {
public:
- Item();
+ // Creates an item that will be owned by |list| with the initial state set
+ // to |selected|.
+ Item(PaymentRequestItemList* list, bool selected);
virtual ~Item();
// Gets the view associated with this item. It's owned by this object so
@@ -34,12 +36,27 @@ class PaymentRequestItemList {
// view.
views::View* GetItemView();
+ bool selected() const { return selected_; }
+ // Changes the selected state of this item to |selected| and calls
+ // SelectedStateChanged.
+ void set_selected(bool selected);
Mathieu 2017/02/23 21:22:53 nit: If it has side effects it probably needs to b
anthonyvd 2017/02/23 21:49:20 Good point, done.
+
+ // Returns a pointer to the PaymentRequestItemList that owns this object.
+ PaymentRequestItemList* list() { return list_; }
+
protected:
// Creates and returns the view associated with this list item.
virtual std::unique_ptr<views::View> CreateItemView() = 0;
+ // Called when the selected state of this item changes. Subclasses may
+ // assume that they are the only selected item in |list| when this is
+ // called.
+ virtual void SelectedStateChanged() = 0;
+
private:
std::unique_ptr<views::View> item_view_;
+ PaymentRequestItemList* list_;
+ bool selected_;
DISALLOW_COPY_AND_ASSIGN(Item);
};
@@ -47,7 +64,7 @@ class PaymentRequestItemList {
PaymentRequestItemList();
~PaymentRequestItemList();
- // Adds an item to this list.
+ // Adds an item to this list. |item->list()| should be equal to this object.
void AddItem(std::unique_ptr<Item> item);
// Creates and returns the UI representation of this list. It iterates over
@@ -55,6 +72,9 @@ class PaymentRequestItemList {
// hierarchy.
std::unique_ptr<views::View> CreateListView();
+ // Deselects the currently selected item and selects |item| instead.
+ void SelectItem(Item* item);
+
private:
std::vector<std::unique_ptr<Item>> items_;

Powered by Google App Engine
This is Rietveld 408576698