Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: views/controls/menu/menu_model_adapter.cc

Issue 7541002: Make NetworkMenuModel a ui::MenuModel again. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implemented reviewer suggestions. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 14 matching lines...) Expand all
25 void MenuModelAdapter::BuildMenu(MenuItemView* menu) { 25 void MenuModelAdapter::BuildMenu(MenuItemView* menu) {
26 DCHECK(menu); 26 DCHECK(menu);
27 27
28 // Clear the menu. 28 // Clear the menu.
29 if (menu->HasSubmenu()) { 29 if (menu->HasSubmenu()) {
30 const int subitem_count = menu->GetSubmenu()->child_count(); 30 const int subitem_count = menu->GetSubmenu()->child_count();
31 for (int i = 0; i < subitem_count; ++i) 31 for (int i = 0; i < subitem_count; ++i)
32 menu->RemoveMenuItemAt(0); 32 menu->RemoveMenuItemAt(0);
33 } 33 }
34 34
35 menu_map_.clear(); 35 // Leave entries in the map if the menu is being shown. This
36 // allows the map to find the menu model of submenus being closed
37 // so ui::MenuModel::MenuClosed() can be called.
38 if (!menu->GetMenuController())
39 menu_map_.clear();
36 menu_map_[menu] = menu_model_; 40 menu_map_[menu] = menu_model_;
37 41
38 // Repopulate the menu. 42 // Repopulate the menu.
39 BuildMenuImpl(menu, menu_model_); 43 BuildMenuImpl(menu, menu_model_);
40 menu->ChildrenChanged(); 44 menu->ChildrenChanged();
41 } 45 }
42 46
43 // MenuModelAdapter, MenuDelegate implementation: 47 // MenuModelAdapter, MenuDelegate implementation:
44 48
45 void MenuModelAdapter::ExecuteCommand(int id) { 49 void MenuModelAdapter::ExecuteCommand(int id) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 BuildMenuImpl(item, submodel); 188 BuildMenuImpl(item, submodel);
185 189
186 menu_map_[item] = submodel; 190 menu_map_[item] = submodel;
187 } 191 }
188 } 192 }
189 193
190 menu->set_has_icons(model->HasIcons()); 194 menu->set_has_icons(model->HasIcons());
191 } 195 }
192 196
193 } // namespace views 197 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698