Skip to content

Commit

Permalink
[PWA]: Add 'Show apps' menu entry (#26348)
Browse files Browse the repository at this point in the history
  • Loading branch information
fallaciousreasoning authored Nov 5, 2024
1 parent 0e69c40 commit 375e365
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/brave_command_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
// Adblock (user-defined cosmetic filters)
#define IDC_ADBLOCK_CONTEXT_BLOCK_ELEMENTS 56351

#define IDC_SHOW_APPS_PAGE 56352

#define IDC_BRAVE_COMMANDS_LAST 57000

#endif // BRAVE_APP_BRAVE_COMMAND_IDS_H_
6 changes: 6 additions & 0 deletions browser/ui/brave_browser_command_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ void BraveBrowserCommandController::InitBraveCommandState() {
UpdateCommandEnabled(IDC_COMMANDER, commander::IsEnabled());
#endif

UpdateCommandEnabled(IDC_SHOW_APPS_PAGE,
!browser_->profile()->IsPrimaryOTRProfile());

UpdateCommandEnabled(IDC_BRAVE_BOOKMARK_BAR_SUBMENU, true);

UpdateCommandEnabled(IDC_TOGGLE_VERTICAL_TABS, true);
Expand Down Expand Up @@ -656,6 +659,9 @@ bool BraveBrowserCommandController::ExecuteBraveCommandWithDisposition(
brave::ToggleCommander(base::to_address(browser_));
#endif
break;
case IDC_SHOW_APPS_PAGE:
brave::ShowAppsPage(&*browser_);
break;
case IDC_WINDOW_GROUP_UNGROUPED_TABS:
brave::GroupUngroupedTabs(&*browser_);
break;
Expand Down
4 changes: 4 additions & 0 deletions browser/ui/brave_pages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ void ShowWalletSettings(Browser* browser) {
ShowSingletonTabOverwritingNTP(browser, GURL(kWalletSettingsURL));
}

void ShowAppsPage(Browser* browser) {
ShowSingletonTabOverwritingNTP(browser, GURL(chrome::kChromeUIAppsURL));
}

} // namespace brave
2 changes: 2 additions & 0 deletions browser/ui/brave_pages.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void ShowShortcutsPage(Browser* browser);
void ShowBraveTalk(Browser* browser);
void ShowFullpageChat(Browser* browser);

void ShowAppsPage(Browser* browser);

} // namespace brave

#endif // BRAVE_BROWSER_UI_BRAVE_PAGES_H_
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 @@ -106,6 +106,7 @@ const std::map<int, const gfx::VectorIcon&>& GetCommandIcons() {
{IDC_OPEN_GUEST_PROFILE, kLeoUserCircleIcon},
{IDC_NAME_WINDOW, kLeoEditBoxIcon},
{IDC_COMMANDER, kLeoArrowSmallRightIcon},
{IDC_SHOW_APPS_PAGE, kLeoGrid04Icon},
{IDC_PERFORMANCE, kLeoNetworkSpeedFastIcon},
{IDC_DEV_TOOLS, kLeoCodeIcon},
{IDC_TASK_MANAGER, kLeoWindowBinaryCodeIcon},
Expand Down
12 changes: 9 additions & 3 deletions browser/ui/toolbar/brave_app_menu_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ BraveAppMenuModel::BraveAppMenuModel(
Browser* browser,
AppMenuIconController* app_menu_icon_controller,
AlertMenuItem alert_item)
: AppMenuModel(provider, browser, app_menu_icon_controller, alert_item)
{
}
: AppMenuModel(provider, browser, app_menu_icon_controller, alert_item) {}

BraveAppMenuModel::~BraveAppMenuModel() = default;

Expand Down Expand Up @@ -287,6 +285,14 @@ void BraveAppMenuModel::BuildMoreToolsSubMenu() {
need_separator = false;
}

if (!browser()->profile()->IsOffTheRecord()) {
if (auto index =
more_tools_menu_model->GetIndexOfCommandId(IDC_NAME_WINDOW)) {
more_tools_menu_model->InsertItemWithStringIdAt(
*index + 1, IDC_SHOW_APPS_PAGE, IDS_IDC_SHOW_APPS_PAGE);
}
}

#if BUILDFLAG(ENABLE_COMMANDER)
if (auto index =
more_tools_menu_model->GetIndexOfCommandId(IDC_NAME_WINDOW)) {
Expand Down
8 changes: 7 additions & 1 deletion browser/ui/toolbar/brave_app_menu_model_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuModelBrowserTest, MenuOrderTest) {

std::vector<int> more_tools_in_order = {
IDC_ADD_NEW_PROFILE, IDC_OPEN_GUEST_PROFILE, IDC_SHOW_BRAVE_SYNC,
IDC_DEV_TOOLS, IDC_TASK_MANAGER,
IDC_SHOW_APPS_PAGE, IDC_DEV_TOOLS, IDC_TASK_MANAGER,
};

if (!syncer::IsSyncAllowedByFlag()) {
Expand Down Expand Up @@ -259,6 +259,12 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuModelBrowserTest, MenuOrderTest) {
commands_disabled_for_private_profile);
CheckHelpCommandsAreInOrderInMenuModel(private_browser,
help_commands_in_order);

// SHOW_APPS_PAGE isn't available in incognito
more_tools_in_order.erase(
std::remove(more_tools_in_order.begin(), more_tools_in_order.end(),
IDC_SHOW_APPS_PAGE),
more_tools_in_order.end());
CheckMoreToolsCommandsAreInOrderInMenuModel(private_browser,
more_tools_in_order);

Expand Down
6 changes: 6 additions & 0 deletions components/resources/commands.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@
<message name="IDS_IDC_SWAP_SPLIT_VIEW" desc="The label of the 'Swap split view' tab context menu item">
Swap Tab Positions
</message>
<message name="IDS_IDC_SHOW_APPS_PAGE" desc="The label of the 'Show Apps' menu item">
Show Apps
</message>
</if>
<if expr="not use_titlecase">
<message name="IDS_IDC_COMMANDER">
Expand All @@ -533,5 +536,8 @@
<message name="IDS_IDC_SWAP_SPLIT_VIEW" desc="The label of the 'Swap split view' tab context menu item">
Swap tab positions
</message>
<message name="IDS_IDC_SHOW_APPS_PAGE" desc="The label of the 'Show Apps' menu item">
Show apps
</message>
</if>
</grit-part>
1 change: 1 addition & 0 deletions components/vector_icons/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ aggregate_vector_icons("brave_components_vector_icons") {
"leo_folder_exchange.icon",
"leo_folder.icon",
"leo_fullscreen_on.icon",
"leo_grid04.icon",
"leo_heart_filled.icon",
"leo_heart_outline.icon",
"leo_help_outline.icon",
Expand Down

0 comments on commit 375e365

Please sign in to comment.