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 #include "views/controls/menu/menu_model_adapter.h" | 5 #include "views/controls/menu/menu_model_adapter.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/l10n/l10n_util.h" | 8 #include "ui/base/l10n/l10n_util.h" |
9 #include "ui/base/models/menu_model.h" | 9 #include "ui/base/models/menu_model.h" |
10 #include "views/controls/menu/submenu_view.h" | 10 #include "views/controls/menu/submenu_view.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // so ui::MenuModel::MenuClosed() can be called. | 37 // so ui::MenuModel::MenuClosed() can be called. |
38 if (!menu->GetMenuController()) | 38 if (!menu->GetMenuController()) |
39 menu_map_.clear(); | 39 menu_map_.clear(); |
40 menu_map_[menu] = menu_model_; | 40 menu_map_[menu] = menu_model_; |
41 | 41 |
42 // Repopulate the menu. | 42 // Repopulate the menu. |
43 BuildMenuImpl(menu, menu_model_); | 43 BuildMenuImpl(menu, menu_model_); |
44 menu->ChildrenChanged(); | 44 menu->ChildrenChanged(); |
45 } | 45 } |
46 | 46 |
| 47 MenuItemView* MenuModelAdapter::CreateMenu() { |
| 48 MenuItemView* item = new MenuItemView(this); |
| 49 BuildMenu(item); |
| 50 return item; |
| 51 } |
| 52 |
47 // MenuModelAdapter, MenuDelegate implementation: | 53 // MenuModelAdapter, MenuDelegate implementation: |
48 | 54 |
49 void MenuModelAdapter::ExecuteCommand(int id) { | 55 void MenuModelAdapter::ExecuteCommand(int id) { |
50 ui::MenuModel* model = menu_model_; | 56 ui::MenuModel* model = menu_model_; |
51 int index = 0; | 57 int index = 0; |
52 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) { | 58 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) { |
53 model->ActivatedAt(index); | 59 model->ActivatedAt(index); |
54 return; | 60 return; |
55 } | 61 } |
56 | 62 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 BuildMenuImpl(item, submodel); | 194 BuildMenuImpl(item, submodel); |
189 | 195 |
190 menu_map_[item] = submodel; | 196 menu_map_[item] = submodel; |
191 } | 197 } |
192 } | 198 } |
193 | 199 |
194 menu->set_has_icons(model->HasIcons()); | 200 menu->set_has_icons(model->HasIcons()); |
195 } | 201 } |
196 | 202 |
197 } // namespace views | 203 } // namespace views |
OLD | NEW |