| 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 class PaymentRequestItemList { | 29 class PaymentRequestItemList { |
| 30 public: | 30 public: |
| 31 // Represents an item in the item list. | 31 // Represents an item in the item list. |
| 32 class Item : public views::ButtonListener { | 32 class Item : public views::ButtonListener { |
| 33 public: | 33 public: |
| 34 // Creates an item that will be owned by |list| with the initial state set | 34 // Creates an item that will be owned by |list| with the initial state set |
| 35 // to |selected|. | 35 // to |selected|. |
| 36 Item(PaymentRequestSpec* spec, | 36 Item(PaymentRequestSpec* spec, |
| 37 PaymentRequestState* state, | 37 PaymentRequestState* state, |
| 38 PaymentRequestItemList* list, | 38 PaymentRequestItemList* list, |
| 39 bool selected); | 39 bool selected, |
| 40 bool show_edit_button); |
| 40 ~Item() override; | 41 ~Item() override; |
| 41 | 42 |
| 42 // Gets the view associated with this item. It's owned by this object so | 43 // Gets the view associated with this item. It's owned by this object so |
| 43 // that it can listen to any changes to the underlying model and update the | 44 // that it can listen to any changes to the underlying model and update the |
| 44 // view. | 45 // view. |
| 45 views::View* GetItemView(); | 46 views::View* GetItemView(); |
| 46 | 47 |
| 47 bool selected() const { return selected_; } | 48 bool selected() const { return selected_; } |
| 48 // Changes the selected state of this item to |selected|. | 49 // Changes the selected state of this item to |selected|. |
| 49 // SelectedStateChanged is called if |notify| is true. | 50 // SelectedStateChanged is called if |notify| is true. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 83 |
| 83 // Returns whether this item is complete/valid and can be selected by the | 84 // Returns whether this item is complete/valid and can be selected by the |
| 84 // user. If this returns false when the user attempts to select this item, | 85 // user. If this returns false when the user attempts to select this item, |
| 85 // PerformSelectionFallback will be called instead. | 86 // PerformSelectionFallback will be called instead. |
| 86 virtual bool CanBeSelected() = 0; | 87 virtual bool CanBeSelected() = 0; |
| 87 | 88 |
| 88 // Performs the action that replaces selection when CanBeSelected returns | 89 // Performs the action that replaces selection when CanBeSelected returns |
| 89 // false. This will usually be to display an editor. | 90 // false. This will usually be to display an editor. |
| 90 virtual void PerformSelectionFallback() = 0; | 91 virtual void PerformSelectionFallback() = 0; |
| 91 | 92 |
| 93 // Called when the edit button is pressed. Subclasses should open the editor |
| 94 // appropriate for the item they represent. |
| 95 virtual void EditButtonPressed() = 0; |
| 96 |
| 92 private: | 97 private: |
| 93 // Creates and returns the view associated with this list item. | 98 // Creates and returns the view associated with this list item. |
| 94 std::unique_ptr<views::View> CreateItemView(); | 99 std::unique_ptr<views::View> CreateItemView(); |
| 95 | 100 |
| 96 // views::ButtonListener: | 101 // views::ButtonListener: |
| 97 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 102 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 98 | 103 |
| 99 std::unique_ptr<views::View> item_view_; | 104 std::unique_ptr<views::View> item_view_; |
| 100 PaymentRequestSpec* spec_; | 105 PaymentRequestSpec* spec_; |
| 101 PaymentRequestState* state_; | 106 PaymentRequestState* state_; |
| 102 PaymentRequestItemList* list_; | 107 PaymentRequestItemList* list_; |
| 103 std::unique_ptr<views::ImageView> checkmark_; | 108 std::unique_ptr<views::ImageView> checkmark_; |
| 104 bool selected_; | 109 bool selected_; |
| 110 bool show_edit_button_; |
| 105 | 111 |
| 106 DISALLOW_COPY_AND_ASSIGN(Item); | 112 DISALLOW_COPY_AND_ASSIGN(Item); |
| 107 }; | 113 }; |
| 108 | 114 |
| 109 PaymentRequestItemList(); | 115 PaymentRequestItemList(); |
| 110 virtual ~PaymentRequestItemList(); | 116 virtual ~PaymentRequestItemList(); |
| 111 | 117 |
| 112 // Adds an item to this list. |item->list()| should return this object. | 118 // Adds an item to this list. |item->list()| should return this object. |
| 113 void AddItem(std::unique_ptr<Item> item); | 119 void AddItem(std::unique_ptr<Item> item); |
| 114 | 120 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 128 | 134 |
| 129 std::vector<std::unique_ptr<Item>> items_; | 135 std::vector<std::unique_ptr<Item>> items_; |
| 130 Item* selected_item_; | 136 Item* selected_item_; |
| 131 | 137 |
| 132 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList); | 138 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList); |
| 133 }; | 139 }; |
| 134 | 140 |
| 135 } // namespace payments | 141 } // namespace payments |
| 136 | 142 |
| 137 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ | 143 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ |
| OLD | NEW |