blob: cbce22857a82bc954ccd099990f6f97033474bde (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/menus/menu_model.h"
namespace menus {
bool MenuModel::IsVisibleAt(int index) const {
return true;
}
bool MenuModel::GetModelAndIndexForCommandId(int command_id,
MenuModel** model, int* index) {
int item_count = (*model)->GetItemCount();
for (int i = 0; i < item_count; ++i) {
if ((*model)->GetTypeAt(i) == TYPE_SUBMENU) {
MenuModel* submenu_model = (*model)->GetSubmenuModelAt(i);
if (GetModelAndIndexForCommandId(command_id, &submenu_model, index)) {
*model = submenu_model;
return true;
}
}
if ((*model)->GetCommandIdAt(i) == command_id) {
*index = i;
return true;
}
}
return false;
}
} // namespace
|