| 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 22 matching lines...) Expand all Loading... |
| 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 bool show_edit_button); |
| 41 ~Item() override; | 41 ~Item() override; |
| 42 | 42 |
| 43 // Gets the view associated with this item. It's owned by this object so | |
| 44 // that it can listen to any changes to the underlying model and update the | |
| 45 // view. | |
| 46 views::View* GetItemView(); | |
| 47 | |
| 48 bool selected() const { return selected_; } | 43 bool selected() const { return selected_; } |
| 49 // Changes the selected state of this item to |selected|. | 44 // Changes the selected state of this item to |selected|. |
| 50 // SelectedStateChanged is called if |notify| is true. | 45 // SelectedStateChanged is called if |notify| is true. |
| 51 void SetSelected(bool selected, bool notify); | 46 void SetSelected(bool selected, bool notify); |
| 52 | 47 |
| 48 // Creates and returns the view associated with this list item. |
| 49 std::unique_ptr<views::View> CreateItemView(); |
| 50 |
| 53 // Returns a pointer to the PaymentRequestItemList that owns this object. | 51 // Returns a pointer to the PaymentRequestItemList that owns this object. |
| 54 PaymentRequestItemList* list() { return list_; } | 52 PaymentRequestItemList* list() { return list_; } |
| 55 | 53 |
| 56 // Returns a pointer to the PaymentRequestSpec/State objects associated with | 54 // Returns a pointer to the PaymentRequestSpec/State objects associated with |
| 57 // this instance of the UI. | 55 // this instance of the UI. |
| 58 PaymentRequestSpec* spec() { return spec_; } | 56 PaymentRequestSpec* spec() { return spec_; } |
| 59 PaymentRequestState* state() { return state_; } | 57 PaymentRequestState* state() { return state_; } |
| 60 | 58 |
| 61 protected: | 59 protected: |
| 62 // Called when the selected state of this item changes. Subclasses may | 60 // Called when the selected state of this item changes. Subclasses may |
| (...skipping 25 matching lines...) Expand all Loading... |
| 88 | 86 |
| 89 // Performs the action that replaces selection when CanBeSelected returns | 87 // Performs the action that replaces selection when CanBeSelected returns |
| 90 // false. This will usually be to display an editor. | 88 // false. This will usually be to display an editor. |
| 91 virtual void PerformSelectionFallback() = 0; | 89 virtual void PerformSelectionFallback() = 0; |
| 92 | 90 |
| 93 // Called when the edit button is pressed. Subclasses should open the editor | 91 // Called when the edit button is pressed. Subclasses should open the editor |
| 94 // appropriate for the item they represent. | 92 // appropriate for the item they represent. |
| 95 virtual void EditButtonPressed() = 0; | 93 virtual void EditButtonPressed() = 0; |
| 96 | 94 |
| 97 private: | 95 private: |
| 98 // Creates and returns the view associated with this list item. | |
| 99 std::unique_ptr<views::View> CreateItemView(); | |
| 100 | |
| 101 // views::ButtonListener: | 96 // views::ButtonListener: |
| 102 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 97 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 103 | 98 |
| 104 std::unique_ptr<views::View> item_view_; | |
| 105 PaymentRequestSpec* spec_; | 99 PaymentRequestSpec* spec_; |
| 106 PaymentRequestState* state_; | 100 PaymentRequestState* state_; |
| 107 PaymentRequestItemList* list_; | 101 PaymentRequestItemList* list_; |
| 108 std::unique_ptr<views::ImageView> checkmark_; | 102 std::unique_ptr<views::ImageView> checkmark_; |
| 109 bool selected_; | 103 bool selected_; |
| 110 bool show_edit_button_; | 104 bool show_edit_button_; |
| 111 | 105 |
| 112 DISALLOW_COPY_AND_ASSIGN(Item); | 106 DISALLOW_COPY_AND_ASSIGN(Item); |
| 113 }; | 107 }; |
| 114 | 108 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 134 | 128 |
| 135 std::vector<std::unique_ptr<Item>> items_; | 129 std::vector<std::unique_ptr<Item>> items_; |
| 136 Item* selected_item_; | 130 Item* selected_item_; |
| 137 | 131 |
| 138 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList); | 132 DISALLOW_COPY_AND_ASSIGN(PaymentRequestItemList); |
| 139 }; | 133 }; |
| 140 | 134 |
| 141 } // namespace payments | 135 } // namespace payments |
| 142 | 136 |
| 143 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ | 137 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_ITEM_LIST_H_ |
| OLD | NEW |