Skip to content

Commit

Permalink
use BASE_FEATURE for Th24 flag parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex313031 committed Aug 20, 2024
1 parent 2345822 commit c7f42c0
Show file tree
Hide file tree
Showing 4 changed files with 297 additions and 26 deletions.
42 changes: 21 additions & 21 deletions other/thorium-2024-ui.patch
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ index bba403a7e5068..e6cba4e30c0a0 100644
// to the white space above and below.
- const int bookmark_bar_attached_vertical_margin =
- features::IsChromeRefresh2023() ? 6 : 4;
+ const int bookmark_bar_attached_vertical_margin = Th24State() ? 2 : 6;
+ const int bookmark_bar_attached_vertical_margin = IsThorium2024() ? 2 : 6;
return GetLayoutConstant(BOOKMARK_BAR_BUTTON_HEIGHT) +
bookmark_bar_attached_vertical_margin;
}
Expand All @@ -33,13 +33,13 @@ index bba403a7e5068..e6cba4e30c0a0 100644
GetLayoutConstant(TAB_STRIP_PADDING);
case TAB_STRIP_PADDING:
- return features::IsChromeRefresh2023() ? 6 : 0;
+ return Th24State() ? 0 : 6;
+ return IsThorium2024() ? 0 : 6;
+ case TAB_MARGIN:
+ return Th24State() ? 6 : GetLayoutConstant(TAB_STRIP_PADDING);
+ return IsThorium2024() ? 6 : GetLayoutConstant(TAB_STRIP_PADDING);
+ case TAB_INACTIVE_PADDING:
+ return Th24State() ? 3 : 6;
+ return IsThorium2024() ? 3 : 6;
+ case TAB_SEARCH_PADDING:
+ return Th24State() ? 4 : 0;
+ return IsThorium2024() ? 4 : 0;
case TAB_SEPARATOR_HEIGHT:
// TODO (crbug.com/1451400): ChromeRefresh2023 needs different values for
// this constant.
Expand All @@ -48,14 +48,14 @@ index bba403a7e5068..e6cba4e30c0a0 100644
return 1;
case TOOLBAR_DIVIDER_HEIGHT:
- return touch_ui ? 20 : 16;
+ if (Th24State()) {
+ if (IsThorium2024()) {
+ return 20;
+ } else {
+ return touch_ui ? 20 : 16;
+ }
case TOOLBAR_DIVIDER_SPACING:
- return 9;
+ return Th24State() ? 8 : 9;
+ return IsThorium2024() ? 8 : 9;
case TOOLBAR_DIVIDER_WIDTH:
return 2;
case TOOLBAR_ELEMENT_PADDING:
Expand All @@ -64,7 +64,7 @@ index bba403a7e5068..e6cba4e30c0a0 100644
}
case TOOLBAR_STANDARD_SPACING:
- if (features::IsChromeRefresh2023()) {
+ if (features::IsChromeRefresh2023() && !Th24State()) {
+ if (features::IsChromeRefresh2023() && !IsThorium2024()) {
return touch_ui ? 12 : 9;
} else {
return touch_ui ? 12 : 8;
Expand All @@ -73,7 +73,7 @@ index bba403a7e5068..e6cba4e30c0a0 100644
return features::IsChromeRefresh2023() ? 20 : 16;
case TOOLBAR_CORNER_RADIUS:
- return 8;
+ return Th24State() ? 0 : 2;
+ return IsThorium2024() ? 0 : 2;
default:
break;
}
Expand Down Expand Up @@ -152,9 +152,9 @@ index aa9cd30374311..5d5a40f92f922 100644
- return 10;
+ static const bool rectangular_tabs =
+ base::CommandLine::ForCurrentProcess()->HasSwitch("rectangular-tabs");
+ if (Th24State() && !rectangular_tabs) {
+ if (IsThorium2024() && !rectangular_tabs) {
+ return 8;
+ } else if ((rectangular_tabs && Th24State()) || (rectangular_tabs && !Th24State())) {
+ } else if ((rectangular_tabs && IsThorium2024()) || (rectangular_tabs && !IsThorium2024())) {
+ return 3;
+ } else {
+ return 10;
Expand All @@ -165,9 +165,9 @@ index aa9cd30374311..5d5a40f92f922 100644
- return 12;
+ static const bool rectangular_tabs =
+ base::CommandLine::ForCurrentProcess()->HasSwitch("rectangular-tabs");
+ if (Th24State() && !rectangular_tabs) {
+ if (IsThorium2024() && !rectangular_tabs) {
+ return 10;
+ } else if ((rectangular_tabs && Th24State()) || (rectangular_tabs && !Th24State())) {
+ } else if ((rectangular_tabs && IsThorium2024()) || (rectangular_tabs && !IsThorium2024())) {
+ return 3;
+ } else {
+ return 12;
Expand All @@ -181,7 +181,7 @@ index aa9cd30374311..5d5a40f92f922 100644
gfx::Size ChromeRefresh2023TabStyle::GetSeparatorSize() const {
- return gfx::Size(kChromeRefreshSeparatorThickness,
- kChromeRefreshSeparatorHeight);
+ if (Th24State()) {
+ if (IsThorium2024()) {
+ return gfx::Size(kThoriumSeparatorThickness,
+ kThoriumSeparatorHeight);
+ } else {
Expand All @@ -196,7 +196,7 @@ index aa9cd30374311..5d5a40f92f922 100644
- GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding,
- kChromeRefreshTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING),
- GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding);
+ if (Th24State()) {
+ if (IsThorium2024()) {
+ return gfx::Insets::TLBR(
+ kThoriumTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING),
+ GetBottomCornerRadius() + kThoriumTabHorizontalPadding,
Expand All @@ -216,7 +216,7 @@ index aa9cd30374311..5d5a40f92f922 100644
- kChromeRefreshSeparatorHorizontalMargin,
- GetLayoutConstant(TAB_STRIP_PADDING),
- kChromeRefreshSeparatorHorizontalMargin);
+ if (Th24State()) {
+ if (IsThorium2024()) {
+ return gfx::Insets::TLBR(GetLayoutConstant(TAB_INACTIVE_PADDING),
+ kThoriumSeparatorHorizontalMargin,
+ GetLayoutConstant(TAB_INACTIVE_PADDING),
Expand Down Expand Up @@ -341,15 +341,15 @@ index 83c7f06f1b236..576150ff56af4 100644
menu_horizontal_border_size = 0;
submenu_horizontal_overlap = 0;
- item_vertical_margin = 6;
+ item_vertical_margin = Th24State() ? 4 : 6;
+ item_vertical_margin = IsThorium2024() ? 4 : 6;
item_horizontal_border_padding = 12;
arrow_size = 16;
- separator_height = 17;
- separator_spacing_height = 4;
- use_outer_border = false;
+ separator_height = Th24State() ? 11 : 17;
+ separator_spacing_height = Th24State() ? 3 : 4;
+ use_outer_border = Th24State() ? true : false;
+ separator_height = IsThorium2024() ? 11 : 17;
+ separator_spacing_height = IsThorium2024() ? 3 : 4;
+ use_outer_border = IsThorium2024() ? true : false;
}

// static
Expand All @@ -376,7 +376,7 @@ index 3684e27766834..d62fe3f96ab62 100644
int LayoutProvider::GetCornerRadiusMetric(ShapeContextTokens id,
const gfx::Size& size) const {
+
+ if (Th24State()) {
+ if (IsThorium2024()) {
+ switch (id) {
+ case ShapeContextTokens::kBadgeRadius:
+ return 4;
Expand Down
6 changes: 1 addition & 5 deletions src/chrome/browser/ui/thorium_2024.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
#include "base/command_line.h"
#include "ui/base/ui_base_features.h"

static bool Th24State() {
static const bool chrome_2024 = features::IsChromeRefresh2023();
static const bool thorium_2024 = base::CommandLine::ForCurrentProcess()->HasSwitch("thorium-2024");
return thorium_2024 && chrome_2024;
}
static const bool thor24 = features::IsThorium2024();

#endif // CHROME_BROWSER_UI_THORIUM_2024_UI_H_
9 changes: 9 additions & 0 deletions src/ui/base/ui_base_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,15 @@ bool IsChromeWebuiRefresh2023() {
base::FeatureList::IsEnabled(kChromeRefreshSecondary2023);
}

BASE_FEATURE(kThorium2024
"Thorium2024",
base::FEATURE_DISABLED_BY_DEFAULT);

bool IsThorium2024() {
return IsChromeRefresh2023() &&
base::FeatureList::IsEnabled(kThorium2024);
}

BASE_FEATURE(kBubbleMetricsApi,
"BubbleMetricsApi",
base::FEATURE_DISABLED_BY_DEFAULT);
Expand Down
Loading

0 comments on commit c7f42c0

Please sign in to comment.