| OLD | NEW |
| 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 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "ui/views/controls/button/button.h" | 12 #include "ui/views/controls/button/button.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 class ImageView; | 15 class ImageView; |
| 16 class View; | 16 class View; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace payments { | 19 namespace payments { |
| 20 | 20 |
| 21 class PaymentRequestDialogView; |
| 21 class PaymentRequestSpec; | 22 class PaymentRequestSpec; |
| 22 class PaymentRequestState; | 23 class PaymentRequestState; |
| 23 | 24 |
| 24 // A control representing a list of selectable items in the PaymentRequest | 25 // A control representing a list of selectable items in the PaymentRequest |
| 25 // dialog. These lists enforce that only one of their elements be selectable at | 26 // dialog. These lists enforce that only one of their elements be selectable at |
| 26 // a time and that "incomplete" items (for example, a credit card with no known | 27 // a time and that "incomplete" items (for example, a credit card with no known |
| 27 // expiration date) behave differently when selected. Most of the time, this | 28 // expiration date) behave differently when selected. Most of the time, this |
| 28 // behavior is to show an editor screen. | 29 // behavior is to show an editor screen. |
| 29 class PaymentRequestItemList { | 30 class PaymentRequestItemList { |
| 30 public: | 31 public: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 std::unique_ptr<views::View> item_view_; | 96 std::unique_ptr<views::View> item_view_; |
| 96 PaymentRequestSpec* spec_; | 97 PaymentRequestSpec* spec_; |
| 97 PaymentRequestState* state_; | 98 PaymentRequestState* state_; |
| 98 PaymentRequestItemList* list_; | 99 PaymentRequestItemList* list_; |
| 99 std::unique_ptr<views::ImageView> checkmark_; | 100 std::unique_ptr<views::ImageView> checkmark_; |
| 100 bool selected_; | 101 bool selected_; |
| 101 | 102 |
| 102 DISALLOW_COPY_AND_ASSIGN(Item); | 103 DISALLOW_COPY_AND_ASSIGN(Item); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 PaymentRequestItemList(); | 106 explicit PaymentRequestItemList(PaymentRequestDialogView* dialog); |
| 106 virtual ~PaymentRequestItemList(); | 107 virtual ~PaymentRequestItemList(); |
| 107 | 108 |
| 108 // Adds an item to this list. |item->list()| should return this object. | 109 // Adds an item to this list. |item->list()| should return this object. |
| 109 void AddItem(std::unique_ptr<Item> item); | 110 void AddItem(std::unique_ptr<Item> item); |
| 110 | 111 |
| 111 // Creates and returns the UI representation of this list. It iterates over | 112 // Creates and returns the UI representation of this list. It iterates over |
| 112 // the items it contains, creates their associated views, and adds them to the | 113 // the items it contains, creates their associated views, and adds them to the |
| 113 // hierarchy. | 114 // hierarchy. |
| 114 std::unique_ptr<views::View> CreateListView(); | 115 std::unique_ptr<views::View> CreateListView(); |
| 115 | 116 |
| 116 // Deselects the currently selected item and selects |item| instead. | 117 // Deselects the currently selected item and selects |item| instead. If |
| 117 void SelectItem(Item* item); | 118 // |go_back| is true, also navigates the dialog back to the previous screen. |
| 119 void SelectItem(Item* item, bool go_back); |
| 118 | 120 |
| 119 private: | 121 private: |
| 120 // Unselects the currently selected item. This is private so that the list can | 122 // Unselects the currently selected item. This is private so that the list can |
| 121 // use it when selecting a new item while avoiding consumers of this class | 123 // use it when selecting a new item while avoiding consumers of this class |
| 122 // putting the list in a state where no item is selected. | 124 // putting the list in a state where no item is selected. |
| 123 void UnselectSelectedItem(); | 125 void UnselectSelectedItem(); |
| 124 | 126 |
| 125 std::vector<std::unique_ptr<Item>> items_; | 127 std::vector<std::unique_ptr<Item>> items_; |
| 126 Item* selected_item_; | 128 Item* selected_item_; |
| 129 PaymentRequestDialogView* dialog_; |
| 127 | 130 |
| 128 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList); | 131 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList); |
| 129 }; | 132 }; |
| 130 | 133 |
| 131 } // namespace payments | 134 } // namespace payments |
| 132 | 135 |
| 133 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ | 136 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ |
| OLD | NEW |