OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 5 #ifndef UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
6 #define UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 6 #define UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 148 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
149 Delegate* delegate() { return delegate_; } | 149 Delegate* delegate() { return delegate_; } |
150 | 150 |
151 MenuModelDelegate* menu_model_delegate() { return menu_model_delegate_; } | 151 MenuModelDelegate* menu_model_delegate() { return menu_model_delegate_; } |
152 | 152 |
153 private: | 153 private: |
154 struct Item; | 154 struct Item; |
155 | 155 |
156 typedef std::vector<Item> ItemVector; | 156 typedef std::vector<Item> ItemVector; |
157 | 157 |
| 158 // Caller needs to call FlipIndex() if necessary. Returns |index|. |
| 159 int ValidateItemIndex(int index) const; |
| 160 |
158 // Functions for inserting items into |items_|. | 161 // Functions for inserting items into |items_|. |
159 void AppendItem(const Item& item); | 162 void AppendItem(const Item& item); |
160 void InsertItemAtIndex(const Item& item, int index); | 163 void InsertItemAtIndex(const Item& item, int index); |
161 void ValidateItem(const Item& item); | 164 void ValidateItem(const Item& item); |
162 | 165 |
163 // Notify the delegate that the menu is closed. | 166 // Notify the delegate that the menu is closed. |
164 void OnMenuClosed(); | 167 void OnMenuClosed(); |
165 | 168 |
166 ItemVector items_; | 169 ItemVector items_; |
167 | 170 |
168 Delegate* delegate_; | 171 Delegate* delegate_; |
169 | 172 |
170 MenuModelDelegate* menu_model_delegate_; | 173 MenuModelDelegate* menu_model_delegate_; |
171 | 174 |
172 base::WeakPtrFactory<SimpleMenuModel> method_factory_; | 175 base::WeakPtrFactory<SimpleMenuModel> method_factory_; |
173 | 176 |
174 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); | 177 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); |
175 }; | 178 }; |
176 | 179 |
177 } // namespace ui | 180 } // namespace ui |
178 | 181 |
179 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 182 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
OLD | NEW |