Skip to content

Commit

Permalink
Restores upstream's extensions submenu in app menu. (#27574)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarolin committed Feb 7, 2025
1 parent 9bce3a1 commit 22dc12e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 35 deletions.
1 change: 1 addition & 0 deletions browser/ui/toolbar/app_menu_icons.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const std::map<int, const gfx::VectorIcon&>& GetCommandIcons() {
{IDC_SHOW_DOWNLOADS, kLeoDownloadIcon},
{IDC_MANAGE_EXTENSIONS, kLeoBrowserExtensionsIcon},
{IDC_EXTENSIONS_SUBMENU_MANAGE_EXTENSIONS, kLeoBrowserExtensionsIcon},
{IDC_EXTENSIONS_SUBMENU_VISIT_CHROME_WEB_STORE, kLeoShoppingBagIcon},
{IDC_ZOOM_MENU, kLeoSearchZoomInIcon},
{IDC_PRINT, kLeoPrintIcon},
{IDC_FIND_AND_EDIT_MENU, kLeoFileSearchIcon},
Expand Down
31 changes: 0 additions & 31 deletions browser/ui/toolbar/brave_app_menu_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,24 +238,6 @@ void BraveAppMenuModel::BuildBrowserSection() {
InsertItemWithStringIdAt(bookmark_item_index.value(), IDC_SHOW_DOWNLOADS,
IDS_SHOW_DOWNLOADS);
}

// Use this command's enabled state to not having it in guest window.
// It's disabled in guest window. Upstream's guest window has extensions
// menu in app menu, but we hide it.
if (IsCommandIdEnabled(IDC_MANAGE_EXTENSIONS)) {
// Upstream enabled extensions submenu by default.
CHECK(features::IsExtensionMenuInRootAppMenu());

// Use IDC_EXTENSIONS_SUBMENU_MANAGE_EXTENSIONS instead of
// IDC_MANAGE_EXTENSIONS because executing it from private(tor) window
// causes crash as LogSafetyHubInteractionMetrics() tries to refer
// SafetyHubMenuNotificationService. But it's not instantiated in private
// window. Upstream also has this crash if ExtensionsMenuInAppMenu feature
// is disabled.
InsertItemWithStringIdAt(
GetIndexOfCommandId(IDC_SHOW_DOWNLOADS).value() + 1,
IDC_EXTENSIONS_SUBMENU_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS);
}
}

void BraveAppMenuModel::BuildMoreToolsSubMenu() {
Expand Down Expand Up @@ -339,13 +321,6 @@ void BraveAppMenuModel::RemoveUpstreamMenus() {
GetSubmenuModelAt(GetIndexOfCommandId(IDC_MORE_TOOLS_MENU).value()));
DCHECK(more_tools_model);

// Remove upstream's extensions item. It'll be added into top level third
// section. Upstream enabled extensions submenu by default.
CHECK(features::IsExtensionMenuInRootAppMenu());
// Hide extensions sub menu.
DCHECK(GetIndexOfCommandId(IDC_EXTENSIONS_SUBMENU).has_value());
RemoveItemAt(GetIndexOfCommandId(IDC_EXTENSIONS_SUBMENU).value());

{
// Remove upstream's profile menu. "Add new profile" will be added into more
// tools sub menu.
Expand Down Expand Up @@ -422,12 +397,6 @@ void BraveAppMenuModel::ExecuteCommand(int id, int event_flags) {
}

bool BraveAppMenuModel::IsCommandIdEnabled(int id) const {
if (id == IDC_EXTENSIONS_SUBMENU_MANAGE_EXTENSIONS) {
// Always returns true as this command id is only added when it could be
// used.
return true;
}

#if defined(TOOLKIT_VIEWS)
if (id == IDC_SIDEBAR_SHOW_OPTION_ALWAYS ||
id == IDC_SIDEBAR_SHOW_OPTION_MOUSEOVER ||
Expand Down
7 changes: 3 additions & 4 deletions browser/ui/toolbar/brave_app_menu_model_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuModelBrowserTest, MenuOrderTest) {
IDC_RECENT_TABS_MENU,
IDC_BOOKMARKS_MENU,
IDC_SHOW_DOWNLOADS,
IDC_EXTENSIONS_SUBMENU_MANAGE_EXTENSIONS,
IDC_EXTENSIONS_SUBMENU,
IDC_CLEAR_BROWSING_DATA,
IDC_ZOOM_MENU,
IDC_PRINT,
Expand Down Expand Up @@ -236,7 +236,7 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuModelBrowserTest, MenuOrderTest) {
#endif
IDC_BOOKMARKS_MENU,
IDC_SHOW_DOWNLOADS,
IDC_EXTENSIONS_SUBMENU_MANAGE_EXTENSIONS,
IDC_EXTENSIONS_SUBMENU,
IDC_ZOOM_MENU,
IDC_PRINT,
IDC_FIND_AND_EDIT_MENU,
Expand Down Expand Up @@ -303,7 +303,6 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuModelBrowserTest, MenuOrderTest) {
#endif
IDC_RECENT_TABS_MENU,
IDC_BOOKMARKS_MENU,
IDC_EXTENSIONS_SUBMENU_MANAGE_EXTENSIONS,
};

CheckCommandsAreDisabledInMenuModel(guest_browser,
Expand Down Expand Up @@ -341,7 +340,7 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuModelBrowserTest, MenuOrderTest) {
IDC_SHOW_BRAVE_WALLET,
IDC_BOOKMARKS_MENU,
IDC_SHOW_DOWNLOADS,
IDC_EXTENSIONS_SUBMENU_MANAGE_EXTENSIONS,
IDC_EXTENSIONS_SUBMENU,
IDC_ZOOM_MENU,
IDC_PRINT,
IDC_FIND_AND_EDIT_MENU,
Expand Down
1 change: 1 addition & 0 deletions components/vector_icons/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ aggregate_vector_icons("brave_components_vector_icons") {
"leo_search.icon",
"leo_settings.icon",
"leo_share_windows.icon",
"leo_shopping_bag.icon",
"leo_shred_data.icon",
"leo_smartphone_laptop.icon",
"leo_swap_horizontal.icon",
Expand Down

0 comments on commit 22dc12e

Please sign in to comment.