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 3 // found in the LICENSE file. 4 5 #include "ui/base/models/menu_model.h" 6 7 namespace ui { 8 9 bool MenuModel::IsVisibleAt(int index) const { 10 return true; 11 } 12 13 // static 14 bool MenuModel::GetModelAndIndexForCommandId(int command_id, 15 MenuModel** model, 16 int* index) { 17 const int item_count = (*model)->GetItemCount(); 18 for (int i = 0; i < item_count; ++i) { 19 const int candidate_index = i; 20 if ((*model)->GetTypeAt(candidate_index) == TYPE_SUBMENU) { 21 MenuModel* submenu_model = (*model)->GetSubmenuModelAt(candidate_index); 22 if (GetModelAndIndexForCommandId(command_id, &submenu_model, index)) { 23 *model = submenu_model; 24 return true; 25 } 26 } 27 if ((*model)->GetCommandIdAt(candidate_index) == command_id) { 28 *index = candidate_index; 29 return true; 30 } 31 } 32 return false; 33 } 34 35 base::string16 MenuModel::GetSublabelAt(int index) const { 36 return base::string16(); 37 } 38 39 base::string16 MenuModel::GetMinorTextAt(int index) const { 40 return base::string16(); 41 } 42 43 const gfx::Font* MenuModel::GetLabelFontAt(int index) const { 44 return NULL; 45 } 46 47 // Default implementation ignores the event flags. 48 void MenuModel::ActivatedAt(int index, int event_flags) { 49 ActivatedAt(index); 50 } 51 52 } // namespace ui 53