| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "base/task.h" |
| 12 #include "ui/base/models/menu_model.h" | 13 #include "ui/base/models/menu_model.h" |
| 13 | 14 |
| 14 namespace ui { | 15 namespace ui { |
| 15 | 16 |
| 16 class ButtonMenuItemModel; | 17 class ButtonMenuItemModel; |
| 17 | 18 |
| 18 // A simple MenuModel implementation with an imperative API for adding menu | 19 // A simple MenuModel implementation with an imperative API for adding menu |
| 19 // items. This makes it easy to construct fixed menus. Menus populated by | 20 // items. This makes it easy to construct fixed menus. Menus populated by |
| 20 // dynamic data sources may be better off implementing MenuModel directly. | 21 // dynamic data sources may be better off implementing MenuModel directly. |
| 21 // The breadth of MenuModel is not exposed through this API. | 22 // The breadth of MenuModel is not exposed through this API. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 Delegate* delegate() { return delegate_; } | 132 Delegate* delegate() { return delegate_; } |
| 132 | 133 |
| 133 private: | 134 private: |
| 134 struct Item; | 135 struct Item; |
| 135 | 136 |
| 136 // Functions for inserting items into |items_|. | 137 // Functions for inserting items into |items_|. |
| 137 void AppendItem(const Item& item); | 138 void AppendItem(const Item& item); |
| 138 void InsertItemAtIndex(const Item& item, int index); | 139 void InsertItemAtIndex(const Item& item, int index); |
| 139 void ValidateItem(const Item& item); | 140 void ValidateItem(const Item& item); |
| 140 | 141 |
| 142 // Notify the delegate that the menu is closed. |
| 143 void OnMenuClosed(); |
| 144 |
| 141 std::vector<Item> items_; | 145 std::vector<Item> items_; |
| 142 | 146 |
| 143 Delegate* delegate_; | 147 Delegate* delegate_; |
| 144 | 148 |
| 149 ScopedRunnableMethodFactory<SimpleMenuModel> method_factory_; |
| 150 |
| 145 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); | 151 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); |
| 146 }; | 152 }; |
| 147 | 153 |
| 148 } // namespace ui | 154 } // namespace ui |
| 149 | 155 |
| 150 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 156 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
| OLD | NEW |