helium/ui/app-menu: remove row bg, fix separators, refactor

also fixed related padding & colors
This commit is contained in:
wukko
2025-08-16 17:22:30 +06:00
parent 31bdefc2de
commit 475fd063f3
3 changed files with 137 additions and 28 deletions

View File

@@ -34,7 +34,32 @@
AddSeparator(ui::NORMAL_SEPARATOR);
AddItemWithStringIdAndVectorIcon(this, IDC_PERFORMANCE, IDS_SHOW_PERFORMANCE,
@@ -1778,32 +1760,6 @@ void AppMenuModel::Build() {
@@ -1736,22 +1718,8 @@ void AppMenuModel::Build() {
// Build (and, by extension, Init) should only be called once.
DCHECK_EQ(0u, GetItemCount());
- if (app_menu_icon_controller_ &&
- app_menu_icon_controller_->GetTypeAndSeverity().type ==
- AppMenuIconController::IconType::UPGRADE_NOTIFICATION) {
- AddSeparator(ui::SPACING_SEPARATOR);
- const auto update_icon = ui::ImageModel::FromVectorIcon(
- kBrowserToolsUpdateChromeRefreshIcon,
- ui::kColorMenuIconOnEmphasizedBackground, kDefaultIconSize);
- if (browser_defaults::kShowUpgradeMenuItem) {
- AddItemWithIcon(IDC_UPGRADE_DIALOG, GetUpgradeDialogTitleText(),
- update_icon);
- AddSeparator(ui::SPACING_SEPARATOR);
- }
- }
-
- if (AddSafetyHubMenuItem() || AddGlobalErrorMenuItems() ||
- AddDefaultBrowserMenuItems()) {
+ if (AddGlobalErrorMenuItems() || AddDefaultBrowserMenuItems() ||
+ AddUpgradeMenuItem()) {
AddSeparator(ui::NORMAL_SEPARATOR);
}
@@ -1778,32 +1746,6 @@ void AppMenuModel::Build() {
AddSeparator(ui::NORMAL_SEPARATOR);
@@ -67,7 +92,7 @@
if (!browser_->profile()->IsOffTheRecord()) {
auto recent_tabs_sub_menu =
std::make_unique<RecentTabsSubMenuModel>(provider_, browser_);
@@ -1825,7 +1781,7 @@ void AppMenuModel::Build() {
@@ -1825,7 +1767,7 @@ void AppMenuModel::Build() {
std::make_unique<BookmarkSubMenuModel>(this, browser_);
AddSubMenuWithStringIdAndVectorIcon(
@@ -76,7 +101,7 @@
bookmark_sub_menu_model_.get(), kBookmarksListsMenuIcon);
SetElementIdentifierAt(GetIndexOfCommandId(IDC_BOOKMARKS_MENU).value(),
kBookmarksMenuItem);
@@ -1842,23 +1798,10 @@ void AppMenuModel::Build() {
@@ -1842,23 +1784,10 @@ void AppMenuModel::Build() {
kTabGroupsMenuItem);
}
@@ -104,7 +129,7 @@
AddItemWithStringIdAndVectorIcon(this, IDC_CLEAR_BROWSING_DATA,
IDS_CLEAR_BROWSING_DATA,
@@ -1902,9 +1845,6 @@ void AppMenuModel::Build() {
@@ -1902,9 +1831,6 @@ void AppMenuModel::Build() {
lens::features::kLensOverlay));
}
@@ -114,7 +139,7 @@
CreateFindAndEditSubMenu();
sub_menus_.push_back(
@@ -1953,6 +1893,12 @@ void AppMenuModel::Build() {
@@ -1953,6 +1879,12 @@ void AppMenuModel::Build() {
#endif
#endif
@@ -127,11 +152,65 @@
AddItemWithStringIdAndVectorIcon(this, IDC_OPTIONS, IDS_SETTINGS,
kSettingsMenuIcon);
@@ -2052,6 +1998,7 @@ bool AppMenuModel::AddDefaultBrowserMenu
@@ -2051,35 +1983,22 @@ bool AppMenuModel::AddDefaultBrowserMenu
return false;
}
bool AppMenuModel::AddSafetyHubMenuItem() {
-bool AppMenuModel::AddSafetyHubMenuItem() {
- auto* safety_hub_menu_notification_service =
- SafetyHubMenuNotificationServiceFactory::GetForProfile(
- browser_->profile());
- if (!safety_hub_menu_notification_service) {
- return false;
- }
- safety_hub_menu_notification_service->MaybeTriggerControlSurvey();
+bool AppMenuModel::AddUpgradeMenuItem() {
+ if (app_menu_icon_controller_ &&
+ app_menu_icon_controller_->GetTypeAndSeverity().type ==
+ AppMenuIconController::IconType::UPGRADE_NOTIFICATION &&
+ browser_defaults::kShowUpgradeMenuItem) {
+ const auto update_icon = ui::ImageModel::FromVectorIcon(
+ kBrowserToolsUpdateChromeRefreshIcon,
+ ui::kColorMenuIcon, kDefaultIconSize);
- std::optional<MenuNotificationEntry> notification =
- safety_hub_menu_notification_service->GetNotificationToShow();
- if (!notification.has_value()) {
- return false;
+ AddItemWithIcon(IDC_UPGRADE_DIALOG, GetUpgradeDialogTitleText(),
+ update_icon);
+
+ return true;
}
- base::UmaHistogramEnumeration("Settings.SafetyHub.Impression",
- safety_hub::SafetyHubSurfaces::kThreeDotMenu);
- base::UmaHistogramEnumeration(
- "Settings.SafetyHub.EntryPointImpression",
- safety_hub::SafetyHubEntryPoint::kMenuNotifications);
- base::UmaHistogramEnumeration("Settings.SafetyHub.MenuNotificationImpression",
- notification->module);
- const auto safety_hub_icon = ui::ImageModel::FromVectorIcon(
- kSecurityIcon, ui::kColorMenuIcon, kDefaultIconSize);
- AddItemWithIcon(notification->command, notification->label, safety_hub_icon);
- SetExecuteCallbackAt(
- GetIndexOfCommandId(notification->command).value(),
- base::BindRepeating(&AppMenuModel::LogSafetyHubInteractionMetrics,
- base::Unretained(this), notification->module));
- return true;
+
+ return false;
auto* safety_hub_menu_notification_service =
SafetyHubMenuNotificationServiceFactory::GetForProfile(
browser_->profile());
}
#if BUILDFLAG(IS_CHROMEOS)
--- a/chrome/browser/ui/toolbar/app_menu_model.h
+++ b/chrome/browser/ui/toolbar/app_menu_model.h
@@ -283,6 +283,9 @@ class AppMenuModel : public ui::SimpleMe
// boolean indicating whether any menu items were added.
bool AddDefaultBrowserMenuItems();
+ // Adds a nag to relaunch the browser after an update
+ bool AddUpgradeMenuItem();
+
// Adds the Safety Hub menu notifications to the menu. Returns a boolean
// indicating whether any menu items were added.
[[nodiscard]] bool AddSafetyHubMenuItem();

View File

@@ -9,21 +9,51 @@
}
const auto* const color_provider = view->GetColorProvider();
cc::PaintFlags flags;
@@ -1433,7 +1433,7 @@ void AppMenu::PopulateMenu(MenuItemView*
// Helper method that adds a background to a menu item.
auto add_menu_row_background = [item](int vertical_margin,
ui::ColorId background_color_id) {
@@ -1430,21 +1430,8 @@ void AppMenu::PopulateMenu(MenuItemView*
PopulateMenu(item, model->GetSubmenuModelAt(i));
}
- // Helper method that adds a background to a menu item.
- auto add_menu_row_background = [item](int vertical_margin,
- ui::ColorId background_color_id) {
- constexpr int kBackgroundCornerRadius = 12;
+ constexpr int kBackgroundCornerRadius = 8;
item->set_vertical_margin(vertical_margin);
item->SetMenuItemBackground(MenuItemView::MenuItemBackground(
background_color_id, kBackgroundCornerRadius));
@@ -1480,7 +1480,7 @@ void AppMenu::PopulateMenu(MenuItemView*
case IDC_SET_BROWSER_AS_DEFAULT: {
// Only highlight the default browser item when it is first in the
// AppMenu.
- item->set_vertical_margin(vertical_margin);
- item->SetMenuItemBackground(MenuItemView::MenuItemBackground(
- background_color_id, kBackgroundCornerRadius));
- item->SetSelectedColorId(ui::kColorAppMenuRowBackgroundHovered);
- };
-
switch (model->GetCommandIdAt(i)) {
case IDC_PROFILE_MENU_IN_APP_MENU: {
- add_menu_row_background(ChromeLayoutProvider::Get()->GetDistanceMetric(
- DISTANCE_CONTENT_LIST_VERTICAL_MULTI),
- ui::kColorAppMenuProfileRowBackground);
ProfileAttributesEntry* profile_attributes =
GetProfileAttributesFromProfile(browser_->profile());
if (profile_attributes &&
@@ -1458,7 +1445,6 @@ void AppMenu::PopulateMenu(MenuItemView*
break;
}
case IDC_UPGRADE_DIALOG: {
- add_menu_row_background(12, ui::kColorAppMenuUpgradeRowBackground);
if (const auto upgrade_substring_text = GetUpgradeDialogSubstringText();
!upgrade_substring_text.empty()) {
item->AddChildView(
@@ -1477,17 +1463,6 @@ void AppMenu::PopulateMenu(MenuItemView*
}
break;
}
- case IDC_SET_BROWSER_AS_DEFAULT: {
- // Only highlight the default browser item when it is first in the
- // AppMenu.
- if (i == 0) {
+ if ((false)) {
add_menu_row_background(
views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_CONTROL_VERTICAL_TEXT_PADDING),
- add_menu_row_background(
- views::LayoutProvider::Get()->GetDistanceMetric(
- views::DISTANCE_CONTROL_VERTICAL_TEXT_PADDING),
- ui::kColorAppMenuUpgradeRowBackground);
- }
- break;
- }
case IDC_EDIT_MENU: {
ui::ButtonMenuItemModel* submodel = model->GetButtonMenuItemAt(i);
DCHECK_EQ(IDC_CUT, submodel->GetCommandIdAt(0));

View File

@@ -180,11 +180,12 @@ helium/ui/tab-strip-controls.patch
helium/ui/toolbar.patch
helium/ui/omnibox.patch
helium/ui/app-menu-style.patch
helium/ui/app-menu-model.patch
helium/ui/remove-reading-list-from-app-menu.patch
helium/ui/fix-customize-side-panel.patch
helium/ui/immersive-padding.patch
helium/ui/side-panel.patch
helium/ui/layout-provider.patch
helium/ui/app-menu-model.patch
helium/ui/remove-dead-toolbar-actions.patch
helium/ui/remove-dead-profile-actions.patch
helium/ui/clean-up-installed-extension-bubble.patch
@@ -198,7 +199,6 @@ helium/ui/square-ntp-monograms.patch
helium/ui/set-gray-as-default-theme.patch
helium/ui/improve-toast.patch
helium/ui/square-interstitial-buttons.patch
helium/ui/remove-reading-list-from-app-menu.patch
helium/ui/center-window-on-launch.patch
helium/ui/remove-devtools-annoyances.patch
helium/ui/bookmarks-bar-padding.patch