Commit 01ef913d authored by Ghazale Hosseinabadi's avatar Ghazale Hosseinabadi Committed by Commit Bot

[Extensions] Call HasVisibleItems only if submenu_model is not null

In this CL, we add a check in IsCommandIdVisible in order to call
HasVisibleItems only if submenu_model is not null.

Bug: 1101726
Change-Id: I248daaeca3ac67777c00020c81d7f08e2433fae1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2285388Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Ghazale Hosseinabadi <ghazale@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786086}
parent ed0c1c64
......@@ -205,16 +205,17 @@ bool ContextMenuMatcher::IsCommandIdVisible(int command_id) const {
// extension's name, that is a container of an extension's menu items. This
// top-level menu item is not added to the context menu, so checking its
// visibility is a special case handled below. This top-level menu item should
// always be displayed.
// be displayed only if it has an invisible submenu item.
if (!item && ContextMenuMatcher::IsExtensionsCustomCommandId(command_id)) {
ui::MenuModel* model = menu_model_;
int index = 0;
if (ui::MenuModel::GetModelAndIndexForCommandId(command_id, &model,
&index)) {
ui::MenuModel* submenu_model = model->GetSubmenuModelAt(index);
// The only way for this to be an extensions command ID without an
// associated menu item is for it to be the generated menu.
DCHECK(submenu_model);
// TODO(ghazale): Find out why submenu_model might be null. In other
// words, in which circumstance it can be an extensions custom command ID
// which does not have an associated item, but it's submenu_model is null.
if (submenu_model)
return HasVisibleItems(submenu_model);
}
return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment