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" |
11 #include "views/views_delegate.h" | 11 #include "views/views_delegate.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 | 14 |
15 MenuModelAdapter::MenuModelAdapter(ui::MenuModel* menu_model) | 15 MenuModelAdapter::MenuModelAdapter(ui::MenuModel* menu_model) |
16 : menu_model_(menu_model) { | 16 : menu_model_(menu_model) { |
17 DCHECK(menu_model); | 17 DCHECK(menu_model); |
18 } | 18 } |
19 | 19 |
| 20 MenuModelAdapter::~MenuModelAdapter() { |
| 21 } |
| 22 |
20 void MenuModelAdapter::BuildMenu(MenuItemView* menu) { | 23 void MenuModelAdapter::BuildMenu(MenuItemView* menu) { |
21 DCHECK(menu); | 24 DCHECK(menu); |
22 | 25 |
23 // Clear the menu. | 26 // Clear the menu. |
24 if (menu->HasSubmenu()) { | 27 if (menu->HasSubmenu()) { |
25 const int subitem_count = menu->GetSubmenu()->child_count(); | 28 const int subitem_count = menu->GetSubmenu()->child_count(); |
26 for (int i = 0; i < subitem_count; ++i) | 29 for (int i = 0; i < subitem_count; ++i) |
27 menu->RemoveMenuItemAt(0); | 30 menu->RemoveMenuItemAt(0); |
28 } | 31 } |
29 | 32 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 BuildMenuImpl(item, submodel); | 161 BuildMenuImpl(item, submodel); |
159 | 162 |
160 menu_map_[item] = submodel; | 163 menu_map_[item] = submodel; |
161 } | 164 } |
162 } | 165 } |
163 | 166 |
164 menu->set_has_icons(model->HasIcons()); | 167 menu->set_has_icons(model->HasIcons()); |
165 } | 168 } |
166 | 169 |
167 } // views | 170 } // views |
OLD | NEW |