diff --git a/chrome/browser/resources/downloads/item.html b/chrome/browser/resources/downloads/item.html index eb515155212c9..1bc09f08c8717 100644 --- a/chrome/browser/resources/downloads/item.html +++ b/chrome/browser/resources/downloads/item.html @@ -427,6 +427,14 @@ -->
+
+ + +
GetDefaultSearchProvider(); - } - } - return nullptr; -} - bool IsMatchingServiceWorker(const GURL& my_url, const GURL& document_url) { // The origin should match. if (!MatchesOrigin(my_url, document_url)) { @@ -142,21 +131,6 @@ bool IsNTPOrRelatedURLHelper(const GURL& url, Profile* profile) { IsMatchingServiceWorker(url, new_tab_url)); } -bool IsURLAllowedForSupervisedUser(const GURL& url, Profile& profile) { - if (!supervised_user::IsSubjectToParentalControls(*profile.GetPrefs())) { - return true; - } - supervised_user::SupervisedUserService* supervised_user_service = - SupervisedUserServiceFactory::GetForProfile(&profile); - supervised_user::SupervisedUserURLFilter* url_filter = - supervised_user_service->GetURLFilter(); - if (url_filter->GetFilteringBehaviorForURL(url) == - supervised_user::FilteringBehavior::kBlock) { - return false; - } - return true; -} - // Used to look up the URL to use for the New Tab page. Also tracks how we // arrived at that URL so it can be logged with UMA. struct NewTabURLDetails { @@ -179,33 +153,9 @@ struct NewTabURLDetails { const GURL local_url(default_is_google ? chrome::kChromeUINewTabPageURL : chrome::kChromeUINewTabPageThirdPartyURL); - if (default_is_google) { - return NewTabURLDetails(local_url, NEW_TAB_URL_VALID); - } #endif - const TemplateURL* template_url = - GetDefaultSearchProviderTemplateURL(profile); - if (!profile || !template_url) { - return NewTabURLDetails(local_url, NEW_TAB_URL_BAD); - } - - GURL search_provider_url(template_url->new_tab_url_ref().ReplaceSearchTerms( - TemplateURLRef::SearchTermsArgs(std::u16string()), - UIThreadSearchTermsData())); - - if (!search_provider_url.is_valid()) { - return NewTabURLDetails(local_url, NEW_TAB_URL_NOT_SET); - } - if (!search_provider_url.SchemeIsCryptographic()) { - return NewTabURLDetails(local_url, NEW_TAB_URL_INSECURE); - } - if (!IsURLAllowedForSupervisedUser(search_provider_url, - CHECK_DEREF(profile))) { - return NewTabURLDetails(local_url, NEW_TAB_URL_BLOCKED); - } - - return NewTabURLDetails(search_provider_url, NEW_TAB_URL_VALID); + return NewTabURLDetails(local_url, NEW_TAB_URL_VALID); } const GURL url; diff --git a/chrome/browser/ui/bookmarks/bookmark_utils.cc b/chrome/browser/ui/bookmarks/bookmark_utils.cc index e7858be996ca8..c0b2695b6e00b 100644 --- a/chrome/browser/ui/bookmarks/bookmark_utils.cc +++ b/chrome/browser/ui/bookmarks/bookmark_utils.cc @@ -318,8 +318,35 @@ ui::ImageModel GetBookmarkFolderIcon( absl::variant color, const ui::ColorProvider* color_provider) { gfx::ImageSkia folder; - folder = - GetBookmarkFolderImageFromVectorIcon(icon_type, color, color_provider); + if (features::IsThorium2024()) { +#if BUILDFLAG(IS_WIN) + // TODO(bsep): vectorize the Windows versions: crbug.com/564112 + folder = *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( + default_id); +#elif BUILDFLAG(IS_MAC) + SkColor sk_color; + if (absl::holds_alternative(color)) { + sk_color = absl::get(color); + } else { + DCHECK(color_provider); + sk_color = color_provider->GetColor(absl::get(color)); + } + const int white_id = (icon_type == BookmarkFolderIconType::kNormal) + ? IDR_FOLDER_CLOSED_WHITE + : IDR_BOOKMARK_BAR_FOLDER_MANAGED_WHITE; + const int resource_id = + color_utils::IsDark(sk_color) ? default_id : white_id; + folder = *ui::ResourceBundle::GetSharedInstance() + .GetNativeImageNamed(resource_id) + .ToImageSkia(); +#else + folder = GetBookmarkFolderImageFromVectorIcon(icon_type, color, + color_provider); +#endif + } else { + folder = + GetBookmarkFolderImageFromVectorIcon(icon_type, color, color_provider); + } return gfx::ImageSkia(std::make_unique(folder), folder.size()); }; diff --git a/chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc b/chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc index 64948595a4bc6..a568c893736ca 100644 --- a/chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc +++ b/chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc @@ -47,7 +47,7 @@ using bookmarks::BookmarkNode; namespace chrome { -size_t kNumBookmarkUrlsBeforePrompting = 15; +size_t kNumBookmarkUrlsBeforePrompting = 50; static BookmarkNavigationWrapper* g_nav_wrapper_test_instance = nullptr; diff --git a/chrome/browser/ui/bookmarks/recently_used_folders_combo_model.cc b/chrome/browser/ui/bookmarks/recently_used_folders_combo_model.cc index 71f9d6ad07da0..246532a09797a 100644 --- a/chrome/browser/ui/bookmarks/recently_used_folders_combo_model.cc +++ b/chrome/browser/ui/bookmarks/recently_used_folders_combo_model.cc @@ -133,10 +133,6 @@ std::optional RecentlyUsedFoldersComboModel::GetDefaultIndex() const { // TODO(pbos): Look at returning -1 here if there's no default index. Right // now a lot of code in Combobox assumes an index within `items_` bounds. auto it = base::ranges::find(items_, Item(parent_node_, Item::TYPE_NODE)); - if (it == items_.end()) { - it = base::ranges::find(items_, - Item(parent_node_, Item::TYPE_ALL_BOOKMARKS_NODE)); - } return it == items_.end() ? 0 : static_cast(it - items_.begin()); } diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc index 8837e8baf3025..1d95a1a3ddf46 100644 --- a/chrome/browser/ui/browser_command_controller.cc +++ b/chrome/browser/ui/browser_command_controller.cc @@ -1433,7 +1433,8 @@ void BrowserCommandController::InitCommandState() { command_updater_.UpdateCommandEnabled(IDC_WINDOW_CLOSE_OTHER_TABS, normal_window); - const bool enable_tab_search_commands = browser_->is_type_normal(); + const bool enable_tab_search_commands = browser_->is_type_normal() && + !base::CommandLine::ForCurrentProcess()->HasSwitch("remove-tabsearch-button"); command_updater_.UpdateCommandEnabled(IDC_TAB_SEARCH, enable_tab_search_commands); command_updater_.UpdateCommandEnabled(IDC_TAB_SEARCH_CLOSE, diff --git a/chrome/browser/ui/layout_constants.cc b/chrome/browser/ui/layout_constants.cc index ea5c2c05f5fa9..5db2dac1b2fa2 100644 --- a/chrome/browser/ui/layout_constants.cc +++ b/chrome/browser/ui/layout_constants.cc @@ -7,6 +7,7 @@ #include "base/feature_list.h" #include "base/notreached.h" #include "build/build_config.h" +#include "chrome/browser/ui/thorium_2024.h" #include "chrome/browser/ui/tabs/features.h" #include "chrome/browser/ui/ui_features.h" #include "components/omnibox/common/omnibox_features.h" @@ -22,20 +23,25 @@ int GetLayoutConstant(LayoutConstant constant) { const bool touch_ui = ui::TouchUiController::Get()->touch_ui(); switch (constant) { case APP_MENU_PROFILE_ROW_AVATAR_ICON_SIZE: - return 24; + return features::IsThorium2024() ? 18 : 24; case APP_MENU_MAXIMUM_CHARACTER_LENGTH: return 30; case BOOKMARK_BAR_HEIGHT: { // The fixed margin ensures the bookmark buttons appear centered relative // to the white space above and below. - const int bookmark_bar_attached_vertical_margin = 6; + const int bookmark_bar_attached_vertical_margin = features::IsThorium2024() ? 3 : 6; return GetLayoutConstant(BOOKMARK_BAR_BUTTON_HEIGHT) + bookmark_bar_attached_vertical_margin; } - case BOOKMARK_BAR_BUTTON_HEIGHT: - return touch_ui ? 36 : 28; + case BOOKMARK_BAR_BUTTON_HEIGHT: { + if (features::IsThorium2024()) { + return touch_ui ? 34 : 26; + } else { + return touch_ui ? 36 : 28; + } + } case BOOKMARK_BAR_BUTTON_PADDING: - return GetLayoutConstant(TOOLBAR_ELEMENT_PADDING); + return features::IsThorium2024() ? 2 : GetLayoutConstant(TOOLBAR_ELEMENT_PADDING); case BOOKMARK_BAR_BUTTON_IMAGE_LABEL_PADDING: return 6; case WEB_APP_MENU_BUTTON_SIZE: @@ -85,6 +91,8 @@ int GetLayoutConstant(LayoutConstant constant) { return 16; case TAB_ALERT_INDICATOR_ICON_WIDTH: return touch_ui ? 12 : 16; + case TAB_BUTTON_OFFSET: + return features::IsThorium2024() ? -1 : 0; case TAB_CLOSE_BUTTON_SIZE: return touch_ui ? 24 : 16; case TAB_HEIGHT: @@ -93,7 +101,13 @@ int GetLayoutConstant(LayoutConstant constant) { return GetLayoutConstant(TAB_HEIGHT) + GetLayoutConstant(TAB_STRIP_PADDING); case TAB_STRIP_PADDING: - return 6; + return features::IsThorium2024() ? 0 : 6; + case TAB_MARGIN: + return features::IsThorium2024() ? 6 : 6; + case TAB_INACTIVE_PADDING: + return features::IsThorium2024() ? 3 : 6; + case TAB_SEARCH_PADDING: + return features::IsThorium2024() ? 3 : 6; case TAB_SEPARATOR_HEIGHT: return touch_ui ? 24 : 20; case TAB_PRE_TITLE_PADDING: @@ -112,9 +126,13 @@ int GetLayoutConstant(LayoutConstant constant) { case TOOLBAR_DIVIDER_CORNER_RADIUS: return 1; case TOOLBAR_DIVIDER_HEIGHT: - return touch_ui ? 20 : 16; + if (features::IsThorium2024()) { + return 18; + } else { + return touch_ui ? 20 : 16; + } case TOOLBAR_DIVIDER_SPACING: - return 9; + return features::IsThorium2024() ? 6 : 9; case TOOLBAR_DIVIDER_WIDTH: return 2; case TOOLBAR_ELEMENT_PADDING: @@ -122,13 +140,17 @@ int GetLayoutConstant(LayoutConstant constant) { case TOOLBAR_ICON_DEFAULT_MARGIN: return touch_ui ? 0 : 2; case TOOLBAR_STANDARD_SPACING: - return touch_ui ? 12 : 9; + if (features::IsThorium2024()) { + return touch_ui ? 12 : 6; + } else { + return touch_ui ? 12 : 9; + } case PAGE_INFO_ICON_SIZE: return 20; case DOWNLOAD_ICON_SIZE: return 20; case TOOLBAR_CORNER_RADIUS: - return 8; + return 0; default: break; } @@ -146,7 +168,11 @@ gfx::Insets GetLayoutInsets(LayoutInset inset) { return gfx::Insets::VH(8, 20); case LOCATION_BAR_ICON_INTERIOR_PADDING: - return gfx::Insets::VH(2, 2); + if (features::IsThorium2024()) { + return touch_ui ? gfx::Insets::VH(5, 10) : gfx::Insets::VH(4, 8); + } else { + return gfx::Insets::VH(2, 2); + } case LOCATION_BAR_PAGE_INFO_ICON_PADDING: return touch_ui ? gfx::Insets::VH(5, 10) : gfx::Insets::VH(4, 4); @@ -161,7 +187,8 @@ gfx::Insets GetLayoutInsets(LayoutInset inset) { } case TOOLBAR_BUTTON: - return gfx::Insets(touch_ui ? 12 : 7); + return gfx::Insets(touch_ui ? 12 + : (features::IsThorium2024() ? 6 : 7)); case BROWSER_APP_MENU_CHIP_PADDING: if (touch_ui) { @@ -178,10 +205,18 @@ gfx::Insets GetLayoutInsets(LayoutInset inset) { } case TOOLBAR_INTERIOR_MARGIN: - return touch_ui ? gfx::Insets() : gfx::Insets::VH(6, 5); + if (features::IsThorium2024()) { + return touch_ui ? gfx::Insets() : gfx::Insets::VH(4, 6); + } else { + return touch_ui ? gfx::Insets() : gfx::Insets::VH(6, 5); + } case WEBUI_TAB_STRIP_TOOLBAR_INTERIOR_MARGIN: - return gfx::Insets::VH(4, 0); + if (features::IsThorium2024()) { + return gfx::Insets::VH(4, 6); + } else { + return gfx::Insets::VH(4, 0); + } } NOTREACHED_IN_MIGRATION(); return gfx::Insets(); diff --git a/chrome/browser/ui/layout_constants.h b/chrome/browser/ui/layout_constants.h index a35795ee8cc11..60577ba01a5fd 100644 --- a/chrome/browser/ui/layout_constants.h +++ b/chrome/browser/ui/layout_constants.h @@ -123,9 +123,21 @@ enum LayoutConstant { // detached tab, and on all sides of the controls padding. TAB_STRIP_PADDING, + // For the tab margins + TAB_MARGIN, + + // For inactive tab padding + TAB_INACTIVE_PADDING, + // The height of a separator in the tabstrip. TAB_SEPARATOR_HEIGHT, + // Padding for the tab search button + TAB_SEARCH_PADDING, + + // Offset y for new tab button + TAB_BUTTON_OFFSET, + // Padding before the tab title. TAB_PRE_TITLE_PADDING, diff --git a/chrome/browser/ui/status_bubble.h b/chrome/browser/ui/status_bubble.h index 74a00df155806..00945e93c0afa 100644 --- a/chrome/browser/ui/status_bubble.h +++ b/chrome/browser/ui/status_bubble.h @@ -18,7 +18,7 @@ class GURL; class StatusBubble { public: // On hover, expand status bubble to fit long URL after this delay. - static const int kExpandHoverDelayMS = 1600; + static const int kExpandHoverDelayMS = 0; virtual ~StatusBubble() {} diff --git a/chrome/browser/ui/tabs/tab_menu_model.cc b/chrome/browser/ui/tabs/tab_menu_model.cc index d2aae6af7306b..da6152848c9e4 100644 --- a/chrome/browser/ui/tabs/tab_menu_model.cc +++ b/chrome/browser/ui/tabs/tab_menu_model.cc @@ -105,6 +105,10 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) { AddItemWithStringId(TabStripModel::CommandNewTabToRight, base::i18n::IsRTL() ? IDS_TAB_CXMENU_NEWTABTOLEFT : IDS_TAB_CXMENU_NEWTABTORIGHT); + AddItemWithStringId(TabStripModel::CommandNewTabToLeft, + base::i18n::IsRTL() ? IDS_TAB_CXMENU_NEWTABTORIGHT + : IDS_TAB_CXMENU_NEWTABTOLEFT); + //AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); if (tab_strip->delegate()->SupportsReadLater()) { AddItem( TabStripModel::CommandAddToReadLater, diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc index 89df9a7f7a805..d52782a295e31 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.cc +++ b/chrome/browser/ui/tabs/tab_strip_model.cc @@ -1296,6 +1296,7 @@ bool TabStripModel::IsContextMenuCommandEnabled( ContextMenuCommand command_id) const { DCHECK(command_id > CommandFirst && command_id < CommandLast); switch (command_id) { + case CommandNewTabToLeft: case CommandNewTabToRight: case CommandCloseTab: return true; @@ -1397,6 +1398,16 @@ void TabStripModel::ExecuteContextMenuCommand(int context_index, if (!ContainsIndex(context_index)) return; switch (command_id) { + + case CommandNewTabToLeft: { + base::RecordAction(UserMetricsAction("TabContextMenu_NewTab")); + UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", NewTabTypes::NEW_TAB_CONTEXT_MENU, + NewTabTypes::NEW_TAB_ENUM_COUNT); + delegate()->AddTabAt(GURL(), context_index, true, + GetTabGroupForTab(context_index)); + break; + } + case CommandNewTabToRight: { base::RecordAction(UserMetricsAction("TabContextMenu_NewTab")); UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", NewTabTypes::NEW_TAB_CONTEXT_MENU, diff --git a/chrome/browser/ui/tabs/tab_strip_model.h b/chrome/browser/ui/tabs/tab_strip_model.h index 7f2f57facf152..3638494eb0dbf 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.h +++ b/chrome/browser/ui/tabs/tab_strip_model.h @@ -547,6 +547,7 @@ class TabStripModel : public TabGroupController { // for entries in the 'Add to existing group' submenu. enum ContextMenuCommand { CommandFirst, + CommandNewTabToLeft, CommandNewTabToRight, CommandReload, CommandDuplicate, diff --git a/chrome/browser/ui/tabs/tab_style.cc b/chrome/browser/ui/tabs/tab_style.cc index b32265fa04597..35e5182f22671 100644 --- a/chrome/browser/ui/tabs/tab_style.cc +++ b/chrome/browser/ui/tabs/tab_style.cc @@ -6,6 +6,7 @@ #include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/tabs/features.h" +#include "chrome/browser/ui/thorium_2024.h" #include "chrome/browser/ui/ui_features.h" #include "ui/base/ui_base_features.h" #include "ui/color/color_provider.h" @@ -16,13 +17,18 @@ namespace { // Thickness in DIPs of the separator painted on the left and right edges of // the tab. +constexpr int kThoriumSeparatorThickness = 2; constexpr int kChromeRefreshSeparatorThickness = 2; +constexpr float kThoriumSeparatorHorizontalMargin = 0.0f; constexpr int kChromeRefreshSeparatorHorizontalMargin = 2; // TODO (crbug.com/1451400): This constant should be in LayoutConstants. +constexpr int kThoriumSeparatorHeight = 20; constexpr int kChromeRefreshSeparatorHeight = 16; // The padding from the top of the tab to the content area. +constexpr int kThoriumTabVerticalPadding = 9; constexpr int kChromeRefreshTabVerticalPadding = 6; +constexpr int kThoriumTabHorizontalPadding = 6; constexpr int kChromeRefreshTabHorizontalPadding = 8; class ChromeRefresh2023TabStyle : public TabStyle { @@ -54,8 +60,28 @@ class ChromeRefresh2023TabStyle : public TabStyle { TabStyle::~TabStyle() = default; int ChromeRefresh2023TabStyle::GetStandardWidth() const { + + const std::string custom_tab_width = base::CommandLine::ForCurrentProcess()-> + GetSwitchValueASCII("custom-tab-width"); + int kTabWidthValue; + if (custom_tab_width == "60") { + kTabWidthValue = 60; + } else if (custom_tab_width == "120") { + kTabWidthValue = 120; + } else if (custom_tab_width == "180") { + kTabWidthValue = 180; + } else if (custom_tab_width == "240") { + kTabWidthValue = 240; + } else if (custom_tab_width == "300") { + kTabWidthValue = 300; + } else if (custom_tab_width == "400") { + kTabWidthValue = 400; + } else { + kTabWidthValue = 240; + } + // The standard tab width is 240 DIP including both separators. - constexpr int kTabWidth = 240; + const int kTabWidth = kTabWidthValue; // The overlap includes one separator, so subtract it here. return kTabWidth + GetTabOverlap() - GetSeparatorSize().width(); } @@ -102,19 +128,42 @@ int ChromeRefresh2023TabStyle::GetMinimumInactiveWidth() const { } int ChromeRefresh2023TabStyle::GetTopCornerRadius() const { - return 10; + static const bool rectangular_tabs = + base::CommandLine::ForCurrentProcess()->HasSwitch("rectangular-tabs"); + if (features::IsThorium2024() && !rectangular_tabs) { + return 8; + } else if ((rectangular_tabs && features::IsThorium2024()) || (rectangular_tabs && !features::IsThorium2024())) { + return 4; + } else { + return 10; + } } int ChromeRefresh2023TabStyle::GetBottomCornerRadius() const { - return 12; + static const bool rectangular_tabs = + base::CommandLine::ForCurrentProcess()->HasSwitch("rectangular-tabs"); + if (features::IsThorium2024() && !rectangular_tabs) { + return 10; + } else if ((rectangular_tabs && features::IsThorium2024()) || (rectangular_tabs && !features::IsThorium2024())) { + return 4; + } else { + return 12; + } } int ChromeRefresh2023TabStyle::GetTabOverlap() const { // The overlap removes the width and the margins of the separator. - const float total_separator_width = GetSeparatorMargins().left() + - GetSeparatorSize().width() + - GetSeparatorMargins().right(); - return 2 * GetBottomCornerRadius() - total_separator_width; + if (features::IsThorium2024()) { + const float total_separator_width = GetSeparatorMargins().left() + + GetSeparatorSize().width() + + GetSeparatorMargins().right(); + return 2 * GetBottomCornerRadius() - total_separator_width; + } else { + const float total_separator_width = GetSeparatorMargins().left() + + GetSeparatorSize().width() + + GetSeparatorMargins().right(); + return 2 * GetBottomCornerRadius() - total_separator_width; + } } gfx::Size ChromeRefresh2023TabStyle::GetPreviewImageSize() const { @@ -124,23 +173,43 @@ gfx::Size ChromeRefresh2023TabStyle::GetPreviewImageSize() const { } gfx::Size ChromeRefresh2023TabStyle::GetSeparatorSize() const { - return gfx::Size(kChromeRefreshSeparatorThickness, - kChromeRefreshSeparatorHeight); + if (features::IsThorium2024()) { + return gfx::Size(kThoriumSeparatorThickness, + kThoriumSeparatorHeight); + } else { + return gfx::Size(kChromeRefreshSeparatorThickness, + kChromeRefreshSeparatorHeight); + } } gfx::Insets ChromeRefresh2023TabStyle::GetSeparatorMargins() const { - return gfx::Insets::TLBR(GetLayoutConstant(TAB_STRIP_PADDING), - kChromeRefreshSeparatorHorizontalMargin, - GetLayoutConstant(TAB_STRIP_PADDING), - kChromeRefreshSeparatorHorizontalMargin); + if (features::IsThorium2024()) { + return gfx::Insets::TLBR(GetLayoutConstant(TAB_INACTIVE_PADDING), + kThoriumSeparatorHorizontalMargin, + GetLayoutConstant(TAB_INACTIVE_PADDING), + kThoriumSeparatorHorizontalMargin); + } else { + return gfx::Insets::TLBR(GetLayoutConstant(TAB_STRIP_PADDING), + kChromeRefreshSeparatorHorizontalMargin, + GetLayoutConstant(TAB_STRIP_PADDING), + kChromeRefreshSeparatorHorizontalMargin); + } } int ChromeRefresh2023TabStyle::GetSeparatorCornerRadius() const { - return GetSeparatorSize().width() / 2; + if (features::IsThorium2024()) { + return 0; + } else { + return GetSeparatorSize().width() / 2; + } } int ChromeRefresh2023TabStyle::GetDragHandleExtension(int height) const { - return 6; + if (features::IsThorium2024()) { + return (height - GetSeparatorSize().height()) / 2 - 1; + } else { + return 6; + } } SkColor ChromeRefresh2023TabStyle::GetTabBackgroundColor( @@ -177,11 +246,19 @@ SkColor ChromeRefresh2023TabStyle::GetTabBackgroundColor( } gfx::Insets ChromeRefresh2023TabStyle::GetContentsInsets() const { - return gfx::Insets::TLBR( - kChromeRefreshTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING), - GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding, - kChromeRefreshTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING), - GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding); + if (features::IsThorium2024()) { + return gfx::Insets::TLBR( + kThoriumTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING), + GetBottomCornerRadius() + kThoriumTabHorizontalPadding, + kThoriumTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING), + GetBottomCornerRadius() + kThoriumTabHorizontalPadding); + } else { + return gfx::Insets::TLBR( + kChromeRefreshTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING), + GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding, + kChromeRefreshTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING), + GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding); + } } float ChromeRefresh2023TabStyle::GetSelectedTabOpacity() const { diff --git a/chrome/browser/ui/thorium_2024.h b/chrome/browser/ui/thorium_2024.h new file mode 100644 index 0000000000000..de40b42fcc722 --- /dev/null +++ b/chrome/browser/ui/thorium_2024.h @@ -0,0 +1,14 @@ +// Copyright 2024 Alex313031 +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_THORIUM_2024_UI_H_ +#define CHROME_BROWSER_UI_THORIUM_2024_UI_H_ + +#include "base/command_line.h" +#include "ui/base/ui_base_features.h" + +// Blanking out until moving file to //ui/base +//static const bool thor24 = features::IsThorium2024(); + +#endif // CHROME_BROWSER_UI_THORIUM_2024_UI_H_ diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index fd011f8983a1d..8000a05951f9b 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -54,6 +54,7 @@ #include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_service_factory.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/ui/thorium_2024.h" #include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view_observer.h" @@ -343,8 +344,8 @@ class BookmarkBarView::ButtonSeparatorView : public views::Separator { public: ButtonSeparatorView() { - const int leading_padding = 8; - const int trailing_padding = 8; + const int leading_padding = features::IsThorium2024() ? 4 : 8; + const int trailing_padding = features::IsThorium2024() ? 3 : 8; separator_thickness_ = kBookmarkBarSeparatorThickness; const gfx::Insets border_insets = gfx::Insets::TLBR(0, leading_padding, 0, trailing_padding); @@ -694,7 +695,7 @@ void BookmarkBarView::Layout(PassKey) { } int x = GetLeadingMargin(); - static constexpr int kBookmarkBarTrailingMargin = 8; + static const int kBookmarkBarTrailingMargin = features::IsThorium2024() ? 0 : 8; int width = View::width() - x - kBookmarkBarTrailingMargin; const int button_height = GetLayoutConstant(BOOKMARK_BAR_BUTTON_HEIGHT); diff --git a/chrome/browser/ui/views/chrome_layout_provider.cc b/chrome/browser/ui/views/chrome_layout_provider.cc index 5291d09d2154f..c8cf8e0ad6037 100644 --- a/chrome/browser/ui/views/chrome_layout_provider.cc +++ b/chrome/browser/ui/views/chrome_layout_provider.cc @@ -7,6 +7,7 @@ #include #include "base/feature_list.h" +#include "chrome/browser/ui/thorium_2024.h" #include "chrome/browser/ui/views/chrome_typography.h" #include "components/omnibox/common/omnibox_features.h" #include "ui/base/pointer/touch_ui_controller.h" @@ -161,7 +162,7 @@ int ChromeLayoutProvider::GetDistanceMetric(int metric) const { case DISTANCE_INFOBAR_HEIGHT: // Spec says height of button should be 36dp, vertical padding on both // top and bottom should be 8dp. - return 36 + 2 * 8; + return features::IsThorium2024() ? 42 : 36 + 2 * 8; case DISTANCE_PERMISSION_PROMPT_HORIZONTAL_ICON_LABEL_PADDING: return 8; case DISTANCE_RICH_HOVER_BUTTON_ICON_HORIZONTAL: diff --git a/chrome/browser/ui/views/frame/browser_frame_view_layout_linux.cc b/chrome/browser/ui/views/frame/browser_frame_view_layout_linux.cc index af21424e93618..7ab9cd6819469 100644 --- a/chrome/browser/ui/views/frame/browser_frame_view_layout_linux.cc +++ b/chrome/browser/ui/views/frame/browser_frame_view_layout_linux.cc @@ -73,5 +73,5 @@ gfx::Insets BrowserFrameViewLayoutLinux::RestoredFrameEdgeInsets() const { } int BrowserFrameViewLayoutLinux::NonClientExtraTopThickness() const { - return delegate_->IsTabStripVisible() ? 0 : kExtraTopBorder; + return (!features::IsThorium2024() && delegate_->IsTabStripVisible()) ? 0 : kExtraTopBorder; } diff --git a/chrome/browser/ui/views/frame/browser_frame_view_win.cc b/chrome/browser/ui/views/frame/browser_frame_view_win.cc index b57fb5baa52a7..4fc9467f16b6c 100644 --- a/chrome/browser/ui/views/frame/browser_frame_view_win.cc +++ b/chrome/browser/ui/views/frame/browser_frame_view_win.cc @@ -315,7 +315,9 @@ int BrowserFrameViewWin::NonClientHitTest(const gfx::Point& point) { // pixels at the end of the top and bottom edges trigger diagonal resizing. constexpr int kResizeCornerWidth = 16; - const int top_border_thickness = GetLayoutConstant(TAB_STRIP_PADDING); + const int top_border_thickness = features::IsThorium2024() + ? GetLayoutConstant(TAB_INACTIVE_PADDING) + : GetLayoutConstant(TAB_STRIP_PADDING); const int window_component = GetHTComponentForFrame( point, gfx::Insets::TLBR(top_border_thickness, 0, 0, 0), @@ -495,7 +497,7 @@ int BrowserFrameViewWin::FrameTopBorderThickness(bool restored) const { // default. When maximized, the OS sizes the window such that the border // extends beyond the screen edges. In that case, we must return the // default value. - const int kTopResizeFrameArea = 0; + const int kTopResizeFrameArea = features::IsThorium2024() ? 7 : 0; return kTopResizeFrameArea; } @@ -555,6 +557,22 @@ int BrowserFrameViewWin::TopAreaHeight(bool restored) const { return top; } + // In maximized mode, we do not add any additional thickness to the grab + // handle above the tabs; just return the frame thickness. + if (maximized) { + return top; + } + + // Besides the frame border, there's empty space atop the window in restored + // mode, to use to drag the window around. + constexpr int kNonClientRestoredExtraThickness = 6; + int thickness = kNonClientRestoredExtraThickness; + if (EverHasVisibleBackgroundTabShapes() && features::IsThorium2024()) { + thickness = + std::max(thickness, BrowserNonClientFrameView::kMinimumDragHeight); + return top + thickness; + } + // The tabstrip controls its own top padding. return top; } @@ -803,17 +821,30 @@ void BrowserFrameViewWin::LayoutCaptionButtons() { const gfx::Size preferred_size = caption_button_container_->GetPreferredSize(); + int height = preferred_size.height(); + // We use the standard caption bar height when maximized in tablet mode, which + // is smaller than our preferred button size. + if (IsWebUITabStrip() && IsMaximized()) { + height = std::min(height, TitlebarMaximizedVisualHeight()); + } + if (!browser_view()->GetWebAppFrameToolbarPreferredSize().IsEmpty()) { + height = IsMaximized() ? TitlebarMaximizedVisualHeight() + : TitlebarHeight(false) - WindowTopY(); + } const int system_caption_buttons_width = ShouldBrowserCustomDrawTitlebar(browser_view()) ? 0 : width() - frame()->GetMinimizeButtonOffset(); + height = features::IsThorium2024() ? std::min(GetFrameHeight(), height) + : GetFrameHeight(); + caption_button_container_->SetBounds( CaptionButtonsOnLeadingEdge() ? system_caption_buttons_width : width() - system_caption_buttons_width - preferred_size.width(), - WindowTopY(), preferred_size.width(), GetFrameHeight()); + WindowTopY(), preferred_size.width(), height); } void BrowserFrameViewWin::LayoutClientView() { diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc index 480b5be6b3f5e..de3c389d5bdf9 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc @@ -280,7 +280,11 @@ int BrowserNonClientFrameViewChromeOS::GetTopInset(bool restored) const { } if (browser_view()->GetTabStripVisible()) { - return 0; + if (features::IsThorium2024()) { + return header_height - browser_view()->GetTabStripHeight(); + } else { + return 0; + } } Browser* browser = browser_view()->browser(); diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h index 263261b1c8204..93335609f27da 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h @@ -105,6 +105,8 @@ class BrowserNonClientFrameViewMac : public BrowserNonClientFrameView, const gfx::Rect& frame, const gfx::Insets& caption_button_insets); + CGFloat FullscreenBackingBarHeight() const; + // Calculate the y offset the top UI needs to shift down due to showing the // slide down menu bar at the very top in full screen. int TopUIFullscreenYOffset() const; diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.mm b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.mm index 73592431e1d6c..e55efc19bfd88 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.mm +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.mm @@ -50,6 +50,8 @@ namespace { // Keep in sync with web_app_frame_toolbar_browsertest.cc constexpr double kTitlePaddingWidthFraction = 0.1; +constexpr int kResizeHandleHeight = 1; + // Empirical measurements of the traffic lights. constexpr int kCaptionButtonsWidth = 52; constexpr int kCaptionButtonsInsetsCatalinaOrOlder = 70; @@ -225,7 +227,46 @@ void BrowserNonClientFrameViewMac::LayoutWebAppWindowTitle( } int BrowserNonClientFrameViewMac::GetTopInset(bool restored) const { - return 0; + if (features::IsThorium2024()) { + if (!browser_view()->ShouldDrawTabStrip()) { + return 0; + } + + // Mac seems to reserve 1 DIP of the top inset as a resize handle. + const int kTabstripTopInset = 8; + int top_inset = kTabstripTopInset; + if (EverHasVisibleBackgroundTabShapes()) { + top_inset = + std::max(top_inset, BrowserNonClientFrameView::kMinimumDragHeight + + kResizeHandleHeight); + } + + // Immersive fullscreen attaches the tab strip to the title bar, no need to + // calculate the y_offset below. + if (browser_view()->UsesImmersiveFullscreenMode()) { + return top_inset; + } + + // Calculate the y offset for the tab strip because in fullscreen mode the tab + // strip may need to move under the slide down menu bar. + CGFloat y_offset = TopUIFullscreenYOffset(); + if (y_offset > 0) { + // When menubar shows up, we need to update mouse tracking area. + NSWindow* window = GetWidget()->GetNativeWindow().GetNativeNSWindow(); + NSRect content_bounds = [[window contentView] bounds]; + // Backing bar tracking area uses native coordinates. + CGFloat tracking_height = + FullscreenBackingBarHeight() + top_inset + y_offset; + NSRect backing_bar_area = + NSMakeRect(0, NSMaxY(content_bounds) - tracking_height, + NSWidth(content_bounds), tracking_height); + [fullscreen_toolbar_controller_ updateToolbarFrame:backing_bar_area]; + } + + return y_offset + top_inset; + } else { + return 0; + } } void BrowserNonClientFrameViewMac::UpdateFullscreenTopUI() { @@ -488,6 +529,21 @@ void BrowserNonClientFrameViewMac::PaintThemedFrame(gfx::Canvas* canvas) { canvas->DrawImageInt(overlay, 0, 0); } +CGFloat BrowserNonClientFrameViewMac::FullscreenBackingBarHeight() const { + BrowserView* browser_view = this->browser_view(); + DCHECK(browser_view->IsFullscreen()); + + CGFloat total_height = 0; + if (browser_view->ShouldDrawTabStrip()) { + total_height += browser_view->GetTabStripHeight(); + } + + if (browser_view->IsToolbarVisible()) + total_height += browser_view->toolbar()->bounds().height(); + + return total_height; +} + int BrowserNonClientFrameViewMac::TopUIFullscreenYOffset() const { if (!browser_view()->GetTabStripVisible() || !browser_view()->IsFullscreen() || diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index ba129325c8700..fbfa68c2e71b1 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -254,7 +254,9 @@ void OpaqueBrowserFrameView::LayoutWebAppWindowTitle( } int OpaqueBrowserFrameView::GetTopInset(bool restored) const { - return layout_->NonClientTopHeight(restored); + return browser_view()->ShouldDrawTabStrip() && features::IsThorium2024() + ? layout_->GetTabStripInsetsTop(restored) + : layout_->NonClientTopHeight(restored); } void OpaqueBrowserFrameView::UpdateThrobber(bool running) { diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc index 67b69d18a802e..f2189d01b206f 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc @@ -78,7 +78,7 @@ gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStripRegion( int total_width) const { const int x = available_space_leading_x_; const int available_width = available_space_trailing_x_ - x; - return gfx::Rect(x, NonClientTopHeight(false), std::max(0, available_width), + return gfx::Rect(x, GetTabStripInsetsTop(false), std::max(0, available_width), tabstrip_minimum_size.height()); } @@ -181,6 +181,15 @@ int OpaqueBrowserFrameViewLayout::NonClientTopHeight(bool restored) const { kContentEdgeShadowThickness; } +int OpaqueBrowserFrameViewLayout::GetTabStripInsetsTop(bool restored) const { + const int top = NonClientTopHeight(restored); + const bool start_at_top_of_frame = !restored && + delegate_->IsFrameCondensed() && + features::IsThorium2024(); + return start_at_top_of_frame ? top + : (top + GetNonClientRestoredExtraThickness()); +} + gfx::Insets OpaqueBrowserFrameViewLayout::FrameEdgeInsets(bool restored) const { return IsFrameEdgeVisible(restored) ? RestoredFrameEdgeInsets() : gfx::Insets(); @@ -190,7 +199,12 @@ int OpaqueBrowserFrameViewLayout::DefaultCaptionButtonY(bool restored) const { // Maximized buttons start at window top, since the window has no border. This // offset is for the image (the actual clickable bounds extend all the way to // the top to take Fitts' Law into account). - return views::NonClientFrameView::kFrameShadowThickness; + const bool start_at_top_of_frame = !restored && + delegate_->IsFrameCondensed() && + features::IsThorium2024(); + return start_at_top_of_frame + ? FrameBorderInsets(false).top() + : views::NonClientFrameView::kFrameShadowThickness; } int OpaqueBrowserFrameViewLayout::CaptionButtonY(views::FrameButton button_id, @@ -236,6 +250,21 @@ int OpaqueBrowserFrameViewLayout::GetWindowCaptionSpacing( return 0; } +int OpaqueBrowserFrameViewLayout::GetNonClientRestoredExtraThickness() const { + // In Refresh, the tabstrip controls its own top padding. + if (!features::IsThorium2024()) { + return 0; + } + // Besides the frame border, there's empty space atop the window in restored + // mode, to use to drag the window around. + int thickness = 6; + if (delegate_->EverHasVisibleBackgroundTabShapes()) { + thickness = + std::max(thickness, BrowserNonClientFrameView::kMinimumDragHeight); + } + return thickness; +} + void OpaqueBrowserFrameViewLayout::SetWindowControlsOverlayEnabled( bool enabled, views::View* host) { diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h index 707226e0e8c70..5e1a2b4dd9921 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h @@ -89,6 +89,8 @@ class OpaqueBrowserFrameViewLayout : public views::LayoutManager { // if the window was restored, regardless of its current state. int NonClientTopHeight(bool restored) const; + int GetTabStripInsetsTop(bool restored) const; + // Returns the y-coordinate of the caption button when native frame buttons // are disabled. If |restored| is true, acts as if the window is restored // regardless of the real mode. @@ -125,6 +127,9 @@ class OpaqueBrowserFrameViewLayout : public views::LayoutManager { const gfx::Rect& client_view_bounds() const { return client_view_bounds_; } + // Returns the extra thickness of the area above the tabs. + int GetNonClientRestoredExtraThickness() const; + // Enables or disables WCO and updates child views accordingly. void SetWindowControlsOverlayEnabled(bool enabled, views::View* host); diff --git a/chrome/browser/ui/views/frame/tab_strip_region_view.cc b/chrome/browser/ui/views/frame/tab_strip_region_view.cc index 17cbbb1eb7f63..f965d02b1c583 100644 --- a/chrome/browser/ui/views/frame/tab_strip_region_view.cc +++ b/chrome/browser/ui/views/frame/tab_strip_region_view.cc @@ -112,7 +112,8 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr tab_strip) // Add and configure the TabSearchContainer. std::unique_ptr tab_search_container; - if (browser && browser->is_type_normal()) { + if (browser && browser->is_type_normal() && + !base::CommandLine::ForCurrentProcess()->HasSwitch("remove-tabsearch-button")) { tab_search_container = std::make_unique( tab_strip_->controller(), browser->tab_strip_model(), render_tab_search_before_tab_strip_, this); @@ -201,12 +202,10 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr tab_strip) // TODO(crbug.com/40118868): Revisit the macro expression once build flag // switch of lacros-chrome is complete. -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) // The New Tab Button can be middle-clicked on Linux. new_tab_button_->SetTriggerableEventFlags( new_tab_button_->GetTriggerableEventFlags() | ui::EF_MIDDLE_MOUSE_BUTTON); -#endif } reserved_grab_handle_space_ = @@ -227,7 +226,7 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr tab_strip) tab_search_container_ = AddChildView(std::move(tab_search_container)); tab_search_container_->SetProperty( views::kMarginsKey, - gfx::Insets::TLBR(0, 0, 0, GetLayoutConstant(TAB_STRIP_PADDING))); + gfx::Insets::TLBR(0, 0, 0, GetLayoutConstant(TAB_SEARCH_PADDING))); } UpdateTabStripMargin(); @@ -365,14 +364,20 @@ void TabStripRegionView::Layout(PassKey) { // The NTB needs to be layered on top of the tabstrip to achieve negative // margins. gfx::Size new_tab_button_size = new_tab_button_->GetPreferredSize(); + int Th24XOffset; + if (features::IsThorium2024()) { + Th24XOffset = 4; + } else { + Th24XOffset = GetLayoutConstant(TAB_MARGIN); + } // The y position is measured from the bottom of the tabstrip, and then - // pading and button height are removed. + // padding and button height are removed. gfx::Point new_tab_button_new_position = gfx::Point(tab_strip_container_->bounds().right() - TabStyle::Get()->GetBottomCornerRadius() + - GetLayoutConstant(TAB_STRIP_PADDING), - 0); + Th24XOffset, + GetLayoutConstant(TAB_BUTTON_OFFSET)); gfx::Rect new_tab_button_new_bounds = gfx::Rect(new_tab_button_new_position, new_tab_button_size); @@ -504,7 +509,7 @@ void TabStripRegionView::UpdateTabStripMargin() { new_tab_button_->SetProperty(views::kViewIgnoredByLayoutKey, true); tab_strip_right_margin = new_tab_button_->GetPreferredSize().width() + - GetLayoutConstant(TAB_STRIP_PADDING); + GetLayoutConstant(TAB_MARGIN); } // If the tab search button is before the tab strip, it also overlaps the @@ -530,8 +535,8 @@ void TabStripRegionView::UpdateTabStripMargin() { // should have 6 px of padding between it and the tab_search button (not // including the corner radius). tab_strip_left_margin = tab_strip_left_margin.value() + - GetLayoutConstant(TAB_STRIP_PADDING) + - GetLayoutConstant(TAB_STRIP_PADDING) - + GetLayoutConstant(TAB_INACTIVE_PADDING) + + GetLayoutConstant(TAB_INACTIVE_PADDING) - TabStyle::Get()->GetBottomCornerRadius(); } @@ -549,7 +554,7 @@ void TabStripRegionView::AdjustViewBoundsRect(View* view, int offset) { const gfx::Size view_size = view->GetPreferredSize(); const int x = tab_strip_container_->x() + TabStyle::Get()->GetBottomCornerRadius() - - GetLayoutConstant(TAB_STRIP_PADDING) - view_size.width() - offset; + GetLayoutConstant(TAB_SEARCH_PADDING) - view_size.width() - offset; const gfx::Rect new_bounds = gfx::Rect(gfx::Point(x, 0), view_size); view->SetBoundsRect(new_bounds); } diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 8ad0bd147a4c2..017a8d3422806 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -209,7 +209,10 @@ LocationBarView::LocationBarView(Browser* browser, !v->GetOmniboxPopupView()->IsOpen(); })); views::FocusRing::Get(this)->SetOutsetFocusRingDisabled(true); - views::InstallPillHighlightPathGenerator(this); + static const bool classic_omnibox = base::CommandLine::ForCurrentProcess()->HasSwitch("classic-omnibox"); + if (!classic_omnibox) { + views::InstallPillHighlightPathGenerator(this); + } #if BUILDFLAG(OS_LEVEL_GEOLOCATION_PERMISSION_SUPPORTED) if (features::IsOsLevelGeolocationPermissionSupportEnabled()) { @@ -436,8 +439,13 @@ bool LocationBarView::IsInitialized() const { } int LocationBarView::GetBorderRadius() const { - return ChromeLayoutProvider::Get()->GetCornerRadiusMetric( - views::Emphasis::kMaximum, size()); + static const bool classic_omnibox = base::CommandLine::ForCurrentProcess()->HasSwitch("classic-omnibox"); + if (classic_omnibox) { + return 4; + } else { + return ChromeLayoutProvider::Get()->GetCornerRadiusMetric( + views::Emphasis::kMaximum, size()); + } } std::unique_ptr LocationBarView::CreateRoundRectBackground( @@ -1158,6 +1166,12 @@ void LocationBarView::RefreshBackground() { } SkColor border_color = SK_ColorTRANSPARENT; + + static const bool classic_omnibox = base::CommandLine::ForCurrentProcess()->HasSwitch("classic-omnibox"); + if (classic_omnibox && !is_caret_visible) { + border_color = color_provider->GetColor(kColorLocationBarBorderOnMismatch); + } + if (high_contrast) { // High contrast schemes get a border stroke even on a rounded omnibox. border_color = diff --git a/chrome/browser/ui/views/omnibox/omnibox_suggestion_button_row_view.cc b/chrome/browser/ui/views/omnibox/omnibox_suggestion_button_row_view.cc index a7072a79d61e9..7234aaeae4b56 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_suggestion_button_row_view.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_suggestion_button_row_view.cc @@ -139,7 +139,7 @@ class OmniboxSuggestionRowButton : public views::MdTextButton { SetImageLabelSpacing(8); SetCustomPadding(ChromeLayoutProvider::Get()->GetInsetsMetric( INSETS_OMNIBOX_PILL_BUTTON)); - SetCornerRadius(GetLayoutConstant(TOOLBAR_CORNER_RADIUS)); + SetCornerRadius(4); auto* const ink_drop = views::InkDrop::Get(this); SetAnimationDuration(base::TimeDelta()); diff --git a/chrome/browser/ui/views/omnibox/rounded_omnibox_results_frame.cc b/chrome/browser/ui/views/omnibox/rounded_omnibox_results_frame.cc index 4bc8f9177f416..4deaee638a5c7 100644 --- a/chrome/browser/ui/views/omnibox/rounded_omnibox_results_frame.cc +++ b/chrome/browser/ui/views/omnibox/rounded_omnibox_results_frame.cc @@ -244,6 +244,7 @@ RoundedOmniboxResultsFrame::RoundedOmniboxResultsFrame( views::BubbleBorder::Shadow::STANDARD_SHADOW); border->SetCornerRadius(corner_radius); border->set_md_shadow_elevation(kElevation); + border->set_draw_border_stroke(true); SetBorder(std::move(border)); AddChildView(contents_host_.get()); @@ -275,11 +276,22 @@ void RoundedOmniboxResultsFrame::OnBeforeWidgetInit( // static int RoundedOmniboxResultsFrame::GetNonResultSectionHeight() { return GetLayoutConstant(LOCATION_BAR_HEIGHT) + - GetLocationBarAlignmentInsets().height(); + GetNonResultSectionInsets().height(); } // static gfx::Insets RoundedOmniboxResultsFrame::GetLocationBarAlignmentInsets() { + if (ui::TouchUiController::Get()->touch_ui()) { + return gfx::Insets::TLBR(6, 1, 5, 1); + } + if (features::IsThorium2024()) { + return gfx::Insets::VH(2, 3); + } + return gfx::Insets::VH(5, 6); +} + +// static +gfx::Insets RoundedOmniboxResultsFrame::GetNonResultSectionInsets() { if (ui::TouchUiController::Get()->touch_ui()) { return gfx::Insets::TLBR(6, 1, 5, 1); } diff --git a/chrome/browser/ui/views/omnibox/rounded_omnibox_results_frame.h b/chrome/browser/ui/views/omnibox/rounded_omnibox_results_frame.h index d134918c8538e..7262833fbb715 100644 --- a/chrome/browser/ui/views/omnibox/rounded_omnibox_results_frame.h +++ b/chrome/browser/ui/views/omnibox/rounded_omnibox_results_frame.h @@ -35,6 +35,9 @@ class RoundedOmniboxResultsFrame : public views::View { // How the Widget is aligned relative to the location bar. static gfx::Insets GetLocationBarAlignmentInsets(); + // How the text area of the Widget is aligned relative to the location bar. + static gfx::Insets GetNonResultSectionInsets(); + // Returns the blur region taken up by the Omnibox popup shadows. static gfx::Insets GetShadowInsets(); diff --git a/chrome/browser/ui/views/side_panel/side_panel_resize_area.cc b/chrome/browser/ui/views/side_panel/side_panel_resize_area.cc index 2ca8611118a21..e360e3afcdc9f 100644 --- a/chrome/browser/ui/views/side_panel/side_panel_resize_area.cc +++ b/chrome/browser/ui/views/side_panel/side_panel_resize_area.cc @@ -12,6 +12,7 @@ #include "ui/accessibility/mojom/ax_node_data.mojom.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/metadata/metadata_impl_macros.h" +#include "ui/base/ui_base_features.h" #include "ui/color/color_provider.h" #include "ui/compositor/layer.h" #include "ui/gfx/geometry/size.h" @@ -32,7 +33,7 @@ SidePanelResizeHandle::SidePanelResizeHandle(SidePanel* side_panel) SetCanProcessEventsWithinSubtree(false); SetFocusBehavior(FocusBehavior::ALWAYS); FocusRing::Install(this); - if (lens::features::IsLensOverlayEnabled()) { + if (lens::features::IsLensOverlayEnabled() && !features::IsThorium2024()) { const int resize_handle_left_margin = 2; SetProperty(views::kMarginsKey, gfx::Insets().set_left(resize_handle_left_margin)); diff --git a/chrome/browser/ui/views/tab_search_bubble_host.cc b/chrome/browser/ui/views/tab_search_bubble_host.cc index fa14797259775..6031b27d539e6 100644 --- a/chrome/browser/ui/views/tab_search_bubble_host.cc +++ b/chrome/browser/ui/views/tab_search_bubble_host.cc @@ -202,7 +202,7 @@ bool TabSearchBubbleHost::ShowTabSearchBubble( // Place the anchor similar to where the button would be in non-fullscreen // mode. const gfx::Rect bounds = button_->GetWidget()->GetWorkAreaBoundsInScreen(); - const int offset = GetLayoutConstant(TAB_STRIP_PADDING); + const int offset = GetLayoutConstant(TAB_INACTIVE_PADDING); const int x = tabs::GetTabSearchTrailingTabstrip(profile_) ? bounds.right() - offset diff --git a/chrome/browser/ui/views/tabs/tab_search_button.cc b/chrome/browser/ui/views/tabs/tab_search_button.cc index a42855ead9dbe..7cfeea92e9efb 100644 --- a/chrome/browser/ui/views/tabs/tab_search_button.cc +++ b/chrome/browser/ui/views/tabs/tab_search_button.cc @@ -21,6 +21,7 @@ #include "ui/views/view_class_properties.h" namespace { +constexpr int kTh24CRTabSearchCornerRadius = 8; constexpr int kCRTabSearchCornerRadius = 10; constexpr int kCRTabSearchFlatCornerRadius = 4; } // namespace @@ -29,7 +30,9 @@ TabSearchButton::TabSearchButton(TabStripController* tab_strip_controller, Edge flat_edge) : TabStripControlButton(tab_strip_controller, PressedCallback(), - vector_icons::kExpandMoreIcon, + features::IsThorium2024() + ? vector_icons::kCaretDownIcon + : vector_icons::kExpandMoreIcon, flat_edge), tab_search_bubble_host_(std::make_unique( this, @@ -61,7 +64,15 @@ void TabSearchButton::NotifyClick(const ui::Event& event) { } int TabSearchButton::GetCornerRadius() const { - return kCRTabSearchCornerRadius; + static const bool rectangular_tabs = + base::CommandLine::ForCurrentProcess()->HasSwitch("rectangular-tabs"); + if (rectangular_tabs) { + return kCRTabSearchFlatCornerRadius; + } else { + return features::IsThorium2024() + ? kTh24CRTabSearchCornerRadius + : kCRTabSearchCornerRadius; + } } int TabSearchButton::GetFlatCornerRadius() const { diff --git a/chrome/browser/ui/views/tabs/tab_style_views.cc b/chrome/browser/ui/views/tabs/tab_style_views.cc index 65676013fece9..8041d18f35745 100644 --- a/chrome/browser/ui/views/tabs/tab_style_views.cc +++ b/chrome/browser/ui/views/tabs/tab_style_views.cc @@ -19,6 +19,7 @@ #include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/tabs/tab_style.h" #include "chrome/browser/ui/tabs/tab_types.h" +#include "chrome/browser/ui/thorium_2024.h" #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/top_container_background.h" @@ -254,7 +255,8 @@ SkPath TabStyleViewsImpl::GetPath(TabStyle::PathType path_type, // this. Detached tab shapes do not need to respect this. if (path_type != TabStyle::PathType::kInteriorClip && path_type != TabStyle::PathType::kHitTest) { - tab_height -= GetLayoutConstant(TAB_STRIP_PADDING) * scale; + // Keep this in Thorium + tab_height -= GetLayoutConstant(TAB_MARGIN) * scale; tab_height -= GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP) * scale; } @@ -264,16 +266,19 @@ SkPath TabStyleViewsImpl::GetPath(TabStyle::PathType path_type, } int left = aligned_bounds.x() + extension_corner_radius; - int top = aligned_bounds.y() + GetLayoutConstant(TAB_STRIP_PADDING) * scale; + // Keep this in Thorium + int top = aligned_bounds.y() + GetLayoutConstant(TAB_INACTIVE_PADDING) * scale; int right = aligned_bounds.right() - extension_corner_radius; - const int bottom = top + tab_height; + // Keep this in Thorium + int bottom = top + tab_height; // For maximized and full screen windows, extend the tab hit test to the top // of the tab, encompassing the top padding. This makes it easy to click on // tabs by moving the mouse to the top of the screen. if (path_type == TabStyle::PathType::kHitTest && tab()->controller()->IsFrameCondensed()) { - top -= GetLayoutConstant(TAB_STRIP_PADDING) * scale; + // Keep this in Thorium + top -= GetLayoutConstant(TAB_MARGIN) * scale; // Don't round the top corners to avoid creating dead space between tabs. top_content_corner_radius = 0; } @@ -308,6 +313,12 @@ SkPath TabStyleViewsImpl::GetPath(TabStyle::PathType path_type, } } + if (features::IsThorium2024()) { + constexpr int Th24StrokeOffset = 1; + top -= Th24StrokeOffset; + //bottom -= Th24StrokeOffset; + } + // Radii are clockwise from top left. const SkVector radii[4] = { SkVector(top_content_corner_radius, top_content_corner_radius), @@ -753,6 +764,11 @@ float TabStyleViewsImpl::GetSeparatorOpacity(bool for_layout, const Tab* const adjacent_tab = tab()->controller()->GetAdjacentTab(tab(), leading ? -1 : 1); + // The separator should never appear at the end of the tab strip. + //if (!adjacent_tab && !leading) { + //return 1.0f; + //} + const Tab* const left_tab = leading ? adjacent_tab : tab(); const Tab* const right_tab = leading ? tab() : adjacent_tab; const bool adjacent_to_header = @@ -978,6 +1003,9 @@ void TabStyleViewsImpl::PaintTabBackgroundFill( cc::PaintFlags flags; flags.setAntiAlias(true); flags.setColor(GetCurrentTabBackgroundColor(selection_state, hovered)); + if (base::CommandLine::ForCurrentProcess()->HasSwitch("transparent-tabs") && + selection_state != TabStyle::TabSelectionState::kActive) + flags.setAlphaf(0.7f); canvas->DrawRect(gfx::ScaleToEnclosingRect(tab_->GetLocalBounds(), scale), flags); } diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 39e7681c0c708..c73c08f328607 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -56,6 +56,7 @@ #include "chrome/browser/ui/webui/signin_internals_ui.h" #include "chrome/browser/ui/webui/suggest_internals/suggest_internals_ui.h" #include "chrome/browser/ui/webui/sync_internals/sync_internals_ui.h" +#include "chrome/browser/ui/webui/thorium_webui.h" #include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h" #include "chrome/browser/ui/webui/usb_internals/usb_internals_ui.h" #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" @@ -777,6 +778,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, return &NewWebUI; } + if (url.host_piece() == chrome::kChromeUIEggsHost) { + return &NewWebUI; + } + return nullptr; } diff --git a/chrome/browser/ui/webui/thorium_webui.h b/chrome/browser/ui/webui/thorium_webui.h new file mode 100644 index 0000000000000..23fe24f51e93e --- /dev/null +++ b/chrome/browser/ui/webui/thorium_webui.h @@ -0,0 +1,78 @@ +// Copyright 2024 Alex313031 +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THORIUM_WEBUI_H_ +#define THORIUM_WEBUI_H_ + +#include "base/memory/ref_counted_memory.h" +#include "chrome/browser/profiles/profile.h" +#include "content/public/browser/url_data_source.h" +#include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_controller.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" + +class ThoriumDataSource : public content::URLDataSource { + public: + ThoriumDataSource() {} + ThoriumDataSource(const ThoriumDataSource&) = delete; + ThoriumDataSource& operator=(const ThoriumDataSource&) = delete; + std::string GetSource() override; + std::string GetMimeType(const GURL& url) override; + std::string GetContentSecurityPolicy(network::mojom::CSPDirectiveName directive) override; + void StartDataRequest(const GURL& url, + const content::WebContents::Getter& wc_getter, + GotDataCallback callback) override; +}; + +std::string ThoriumDataSource::GetSource() { return "eggs"; } +std::string ThoriumDataSource::GetMimeType(const GURL& url) { return "text/html"; } +std::string ThoriumDataSource::GetContentSecurityPolicy(network::mojom::CSPDirectiveName directive) { + if (directive == network::mojom::CSPDirectiveName::ScriptSrc) + return "script-src 'unsafe-inline'"; + return std::string(); +} +void ThoriumDataSource::StartDataRequest(const GURL& url, + const content::WebContents::Getter& wc_getter, + GotDataCallback callback) { + std::string source = R"( + + + Thorium Easter Eggs + + + + + + +

Thorium Easter Eggs WebUI Page

+
+

+ +


+ + + + + +

+ + + )"; + std::move(callback).Run(base::MakeRefCounted(std::move(source))); +} + +class ThoriumWebUILoad : public content::WebUIController { + public: + ThoriumWebUILoad(content::WebUI* web_ui) : content::WebUIController(web_ui) { + content::URLDataSource::Add(Profile::FromWebUI(web_ui), std::make_unique()); + } + ThoriumWebUILoad(const ThoriumWebUILoad&) = delete; + ThoriumWebUILoad& operator=(const ThoriumWebUILoad&) = delete; +}; + +#endif // THORIUM_WEBUI_H_ diff --git a/chrome/common/webui_url_constants.cc b/chrome/common/webui_url_constants.cc index 248b6795e8cbe..488bade160e37 100644 --- a/chrome/common/webui_url_constants.cc +++ b/chrome/common/webui_url_constants.cc @@ -75,6 +75,7 @@ bool IsSystemWebUIHost(std::string_view host) { // These hosts will also be suggested by BuiltinProvider. base::span ChromeURLHosts() { static constexpr auto kChromeURLHosts = std::to_array({ + kChromeUIEggsHost, kChromeUIAboutHost, kChromeUIAccessibilityHost, #if !BUILDFLAG(IS_ANDROID) diff --git a/chrome/common/webui_url_constants.h b/chrome/common/webui_url_constants.h index 70e366e816db5..a727ed4aa725f 100644 --- a/chrome/common/webui_url_constants.h +++ b/chrome/common/webui_url_constants.h @@ -31,6 +31,8 @@ namespace chrome { // Not all components have corresponding URLs and vice versa. Only add as // needed. // Please keep in alphabetical order, with OS/feature specific sections below. +inline constexpr char kChromeUIEggsHost[] = "eggs"; +inline constexpr char kChromeUIEggsURL[] = "chrome://eggs/"; inline constexpr char kChromeUIAboutHost[] = "about"; inline constexpr char kChromeUIAboutURL[] = "chrome://about/"; inline constexpr char kChromeUIAccessCodeCastHost[] = "access-code-cast"; diff --git a/components/resources/search_engine_choice_scaled_resources.grdp b/components/resources/search_engine_choice_scaled_resources.grdp index 87d186a04e66c..01beccd365540 100644 --- a/components/resources/search_engine_choice_scaled_resources.grdp +++ b/components/resources/search_engine_choice_scaled_resources.grdp @@ -6,6 +6,7 @@ + diff --git a/ui/base/ui_base_features.cc b/ui/base/ui_base_features.cc index ed801f34141da..bc24e8c7dfbe9 100644 --- a/ui/base/ui_base_features.cc +++ b/ui/base/ui_base_features.cc @@ -511,6 +511,14 @@ bool IsLacrosColorManagementEnabled() { return base::FeatureList::IsEnabled(kLacrosColorManagement); } +BASE_FEATURE(kThorium2024, + "Thorium2024", + base::FEATURE_DISABLED_BY_DEFAULT); + +bool IsThorium2024() { + return base::FeatureList::IsEnabled(kThorium2024); +} + BASE_FEATURE(kBubbleMetricsApi, "BubbleMetricsApi", base::FEATURE_DISABLED_BY_DEFAULT); diff --git a/ui/base/ui_base_features.h b/ui/base/ui_base_features.h index 2232cc983adbc..1a2888799934e 100644 --- a/ui/base/ui_base_features.h +++ b/ui/base/ui_base_features.h @@ -228,6 +228,10 @@ COMPONENT_EXPORT(UI_BASE_FEATURES) BASE_DECLARE_FEATURE(kLacrosColorManagement); COMPONENT_EXPORT(UI_BASE_FEATURES) bool IsLacrosColorManagementEnabled(); +// Used to revert some stupid UI decisions for Cr23 +COMPONENT_EXPORT(UI_BASE_FEATURES) BASE_DECLARE_FEATURE(kThorium2024); +COMPONENT_EXPORT(UI_BASE_FEATURES) bool IsThorium2024(); + COMPONENT_EXPORT(UI_BASE_FEATURES) BASE_DECLARE_FEATURE(kBubbleMetricsApi); diff --git a/ui/linux/linux_ui_factory.cc b/ui/linux/linux_ui_factory.cc index d21456ab73faa..de14c868fcc26 100644 --- a/ui/linux/linux_ui_factory.cc +++ b/ui/linux/linux_ui_factory.cc @@ -175,7 +175,7 @@ SystemTheme GetDefaultSystemTheme() { case base::nix::DESKTOP_ENVIRONMENT_PANTHEON: case base::nix::DESKTOP_ENVIRONMENT_UNITY: case base::nix::DESKTOP_ENVIRONMENT_XFCE: - return SystemTheme::kGtk; + return SystemTheme::kDefault; case base::nix::DESKTOP_ENVIRONMENT_KDE3: case base::nix::DESKTOP_ENVIRONMENT_KDE4: case base::nix::DESKTOP_ENVIRONMENT_KDE5: @@ -183,7 +183,7 @@ SystemTheme GetDefaultSystemTheme() { case base::nix::DESKTOP_ENVIRONMENT_UKUI: case base::nix::DESKTOP_ENVIRONMENT_DEEPIN: case base::nix::DESKTOP_ENVIRONMENT_LXQT: - return SystemTheme::kQt; + return SystemTheme::kDefault; case base::nix::DESKTOP_ENVIRONMENT_OTHER: return SystemTheme::kDefault; } diff --git a/ui/views/controls/menu/menu_config.cc b/ui/views/controls/menu/menu_config.cc index 2f1525c8880d4..c7b6d0822ba32 100644 --- a/ui/views/controls/menu/menu_config.cc +++ b/ui/views/controls/menu/menu_config.cc @@ -5,6 +5,7 @@ #include "ui/views/controls/menu/menu_config.h" #include "base/no_destructor.h" +#include "chrome/browser/ui/thorium_2024.h" #include "ui/base/ui_base_features.h" #include "ui/views/controls/menu/menu_controller.h" #include "ui/views/controls/menu/menu_item_view.h" @@ -64,12 +65,12 @@ void MenuConfig::InitCommon() { reserve_dedicated_arrow_column = false; menu_horizontal_border_size = 0; submenu_horizontal_overlap = 0; - item_vertical_margin = 6; + item_vertical_margin = features::IsThorium2024() ? 4 : 6; item_horizontal_border_padding = 12; arrow_size = 16; - separator_height = 17; - separator_spacing_height = 4; - use_outer_border = false; + separator_height = features::IsThorium2024() ? 11 : 17; + separator_spacing_height = features::IsThorium2024() ? 3 : 4; + use_outer_border = features::IsThorium2024() ? true : false; } // static diff --git a/ui/views/controls/menu/menu_config_linux.cc b/ui/views/controls/menu/menu_config_linux.cc index 09c03d1e87011..cf6722ff8314a 100644 --- a/ui/views/controls/menu/menu_config_linux.cc +++ b/ui/views/controls/menu/menu_config_linux.cc @@ -4,12 +4,16 @@ #include "ui/views/controls/menu/menu_config.h" +#include "chrome/browser/ui/thorium_2024.h" +#include "ui/base/ui_base_features.h" #include "ui/ozone/public/ozone_platform.h" namespace views { void MenuConfig::InitPlatform() { - use_bubble_border = true; + use_bubble_border = features::IsThorium2024() ? false : corner_radius > 0; + arrow_to_edge_padding = features::IsThorium2024() ? 2 : 8; + separator_height = features::IsThorium2024() ? 6 : 17; } } // namespace views diff --git a/ui/views/controls/menu/menu_config_mac.mm b/ui/views/controls/menu/menu_config_mac.mm index eabfb364890d3..2374c18b0f3d7 100644 --- a/ui/views/controls/menu/menu_config_mac.mm +++ b/ui/views/controls/menu/menu_config_mac.mm @@ -1,17 +1,55 @@ -// Copyright 2014 The Chromium Authors +// Copyright 2024 The Chromium Authors and Alex313031 // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#import + +#include "base/mac/mac_util.h" +#include "chrome/browser/ui/thorium_2024.h" +#include "ui/base/ui_base_features.h" #include "ui/views/controls/menu/menu_config.h" +#include "ui/gfx/platform_font_mac.h" + +namespace { + +void InitMaterialMenuConfig(views::MenuConfig* config) { + // These config parameters are from https://crbug.com/829347 and the spec + // images linked from that bug. + config->submenu_horizontal_overlap = 0; + config->minimum_text_item_height = 28; + config->minimum_container_item_height = 40; + config->arrow_to_edge_padding = 16; + config->separator_height = 9; + config->separator_lower_height = 4; + config->separator_upper_height = 4; + config->separator_spacing_height = 5; + config->separator_thickness = 1; + config->reserve_dedicated_arrow_column = false; + config->icons_in_label = true; + config->icon_label_spacing = 8; + config->corner_radius = 8; + config->auxiliary_corner_radius = 4; + config->item_horizontal_border_padding = 0; +} + +} // namespace + namespace views { void MenuConfig::InitPlatform() { check_selected_combobox_item = true; - arrow_key_selection_wraps = false; + arrow_key_selection_wraps = true; use_mnemonics = false; - show_context_menu_accelerators = false; + show_context_menu_accelerators = features::IsThorium2024() ? true : false; all_menus_use_prefix_selection = true; + if (features::IsThorium2024()) { + menu_horizontal_border_size = 0; + } + use_outer_border = features::IsThorium2024() ? true : false; + if (features::IsThorium2024()) { + InitMaterialMenuConfig(this); + } } } // namespace views diff --git a/ui/views/controls/menu/menu_config_win.cc b/ui/views/controls/menu/menu_config_win.cc index a2dae078ccbd3..41e3452b95f5c 100644 --- a/ui/views/controls/menu/menu_config_win.cc +++ b/ui/views/controls/menu/menu_config_win.cc @@ -8,6 +8,8 @@ #include +#include "base/win/windows_version.h" +#include "ui/base/ui_base_features.h" #include "ui/gfx/system_fonts_win.h" namespace views { @@ -22,9 +24,40 @@ void MenuConfig::InitPlatform() { show_cues == TRUE); SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &show_delay, 0); - separator_upper_height = 5; - separator_lower_height = 7; + bool is_win11 = base::win::GetVersion() >= base::win::Version::WIN11; + use_outer_border = features::IsThorium2024() ? true : false; + + if (features::IsThorium2024()) { + if (is_win11) { + corner_radius = 8; + menu_horizontal_border_size = 4; + submenu_horizontal_overlap = 1; + rounded_menu_vertical_border_size = 4; + item_horizontal_padding = 1; + between_item_vertical_padding = 2; + separator_height = 1; + separator_upper_height = 1; + separator_lower_height = 1; + item_corner_radius = 4; + use_outer_border = true; + } else { + corner_radius = 0; + menu_horizontal_border_size = 3; + nonrounded_menu_vertical_border_size = 3; + item_vertical_margin = 3; + item_horizontal_border_padding = -2; + icon_label_spacing = 10; + always_reserve_check_region = true; + separator_height = 7; + separator_upper_height = 5; + separator_lower_height = 5; + use_outer_border = true; + } + } else { + separator_upper_height = 5; + separator_lower_height = 7; + } use_bubble_border = corner_radius > 0; } diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc index 3ed4ba49f5b4d..7a9b2a96f7c9a 100644 --- a/ui/views/controls/tree/tree_view.cc +++ b/ui/views/controls/tree/tree_view.cc @@ -19,6 +19,7 @@ #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/base/models/image_model.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_features.h" #include "ui/color/color_id.h" #include "ui/color/color_provider.h" #include "ui/events/event.h" @@ -96,12 +97,33 @@ TreeView::TreeView() drawing_provider_(std::make_unique()) { // Always focusable, even on Mac (consistent with NSOutlineView). SetFocusBehavior(FocusBehavior::ALWAYS); +#if BUILDFLAG(IS_MAC) + constexpr bool kUseMdIcons = true; +#else + constexpr bool kUseMdIcons = false; +#endif + if (features::IsThorium2024()) { + if (kUseMdIcons) { + closed_icon_ = open_icon_ = ui::ImageModel::FromVectorIcon( + vector_icons::kFolderIcon, ui::kColorIcon); + } else { + // TODO(ellyjones): if the pre-Harmony codepath goes away, merge + // closed_icon_ and open_icon_. + closed_icon_ = ui::ImageModel::FromImage( + ui::ResourceBundle::GetSharedInstance().GetImageNamed( + IDR_FOLDER_CLOSED)); + open_icon_ = ui::ImageModel::FromImage( + ui::ResourceBundle::GetSharedInstance().GetImageNamed(IDR_FOLDER_OPEN)); + } + text_offset_ = closed_icon_.Size().width() + kImagePadding + kImagePadding + + kArrowRegionSize; + } else { + folder_icon_ = ui::ImageModel::FromVectorIcon( + vector_icons::kFolderChromeRefreshIcon, ui::kColorIcon); - folder_icon_ = ui::ImageModel::FromVectorIcon( - vector_icons::kFolderChromeRefreshIcon, ui::kColorIcon); - - text_offset_ = folder_icon_.Size().width() + kImagePadding + kImagePadding + - kArrowRegionSize; + text_offset_ = folder_icon_.Size().width() + kImagePadding + kImagePadding + + kArrowRegionSize; + } } TreeView::~TreeView() { @@ -1174,21 +1196,43 @@ void TreeView::PaintNodeIcon(gfx::Canvas* canvas, const gfx::Rect& bounds) { std::optional icon_index = model_->GetIconIndex(node->model_node()); int icon_x = kArrowRegionSize + kImagePadding; - if (!icon_index.has_value()) { - // Flip just the |bounds| region of |canvas|. - gfx::ScopedCanvas scoped_canvas(canvas); - canvas->Translate(gfx::Vector2d(bounds.x(), 0)); - scoped_canvas.FlipIfRTL(bounds.width()); - // Now paint the icon local to that flipped region. - PaintRowIcon(canvas, folder_icon_.Rasterize(GetColorProvider()), icon_x, - gfx::Rect(0, bounds.y(), bounds.width(), bounds.height())); + if (features::IsThorium2024()) { + if (!icon_index.has_value()) { + // Flip just the |bounds| region of |canvas|. + gfx::ScopedCanvas scoped_canvas(canvas); + canvas->Translate(gfx::Vector2d(bounds.x(), 0)); + scoped_canvas.FlipIfRTL(bounds.width()); + // Now paint the icon local to that flipped region. + PaintRowIcon(canvas, + (node->is_expanded() ? open_icon_ : closed_icon_) + .Rasterize(GetColorProvider()), + icon_x, + gfx::Rect(0, bounds.y(), bounds.width(), bounds.height())); + } else { + const gfx::ImageSkia& icon = + icons_[icon_index.value()].Rasterize(GetColorProvider()); + icon_x += (open_icon_.Size().width() - icon.width()) / 2; + if (base::i18n::IsRTL()) + icon_x = bounds.width() - icon_x - icon.width(); + PaintRowIcon(canvas, icon, icon_x, bounds); + } } else { - const gfx::ImageSkia& icon = - icons_[icon_index.value()].Rasterize(GetColorProvider()); - icon_x += (folder_icon_.Size().width() - icon.width()) / 2; - if (base::i18n::IsRTL()) - icon_x = bounds.width() - icon_x - icon.width(); - PaintRowIcon(canvas, icon, icon_x, bounds); + if (!icon_index.has_value()) { + // Flip just the |bounds| region of |canvas|. + gfx::ScopedCanvas scoped_canvas(canvas); + canvas->Translate(gfx::Vector2d(bounds.x(), 0)); + scoped_canvas.FlipIfRTL(bounds.width()); + // Now paint the icon local to that flipped region. + PaintRowIcon(canvas, folder_icon_.Rasterize(GetColorProvider()), icon_x, + gfx::Rect(0, bounds.y(), bounds.width(), bounds.height())); + } else { + const gfx::ImageSkia& icon = + icons_[icon_index.value()].Rasterize(GetColorProvider()); + icon_x += (folder_icon_.Size().width() - icon.width()) / 2; + if (base::i18n::IsRTL()) + icon_x = bounds.width() - icon_x - icon.width(); + PaintRowIcon(canvas, icon, icon_x, bounds); + } } } diff --git a/ui/views/controls/tree/tree_view.h b/ui/views/controls/tree/tree_view.h index 3a8a79eb69c32..f29814a4fc4b9 100644 --- a/ui/views/controls/tree/tree_view.h +++ b/ui/views/controls/tree/tree_view.h @@ -461,6 +461,10 @@ class VIEWS_EXPORT TreeView : public View, // Default folder icon. ui::ImageModel folder_icon_; + // Default icons for closed/open. + ui::ImageModel closed_icon_; + ui::ImageModel open_icon_; + // Icons from the model. std::vector icons_; diff --git a/ui/views/layout/layout_provider.cc b/ui/views/layout/layout_provider.cc index 01301096ca466..e4854f99dad64 100644 --- a/ui/views/layout/layout_provider.cc +++ b/ui/views/layout/layout_provider.cc @@ -8,6 +8,7 @@ #include "base/containers/fixed_flat_map.h" #include "base/logging.h" +#include "chrome/browser/ui/thorium_2024.h" #include "ui/base/ui_base_features.h" #include "ui/gfx/font_list.h" #include "ui/views/controls/focus_ring.h" @@ -208,6 +209,48 @@ ShapeSysTokens GetShapeSysToken(ShapeContextTokens id) { int LayoutProvider::GetCornerRadiusMetric(ShapeContextTokens id, const gfx::Size& size) const { + + static const bool classic_omnibox = base::CommandLine::ForCurrentProcess()->HasSwitch("classic-omnibox"); + if (features::IsThorium2024()) { + switch (id) { + case ShapeContextTokens::kBadgeRadius: + return 4; + case ShapeContextTokens::kButtonRadius: + return 4; + case ShapeContextTokens::kComboboxRadius: + return 4; + case ShapeContextTokens::kDialogRadius: + return 4; + case ShapeContextTokens::kFindBarViewRadius: + return 4; + case ShapeContextTokens::kMenuRadius: + case ShapeContextTokens::kMenuAuxRadius: + return 0; + case ShapeContextTokens::kMenuTouchRadius: + return 8; + case ShapeContextTokens::kOmniboxExpandedRadius: { + if (classic_omnibox) { + return 4; + } else { + return 16; + } + } + case ShapeContextTokens::kTextfieldRadius: { + if (classic_omnibox) { + return 4; + } else { + return 8; + } + } + case ShapeContextTokens::kSidePanelContentRadius: + return 16; + case ShapeContextTokens::kSidePanelPageContentRadius: + return 8; + default: + return 0; + } + } + ShapeSysTokens token = GetShapeSysToken(id); DCHECK_NE(token, ShapeSysTokens::kDefault) << "kDefault token means there is a missing mapping between shape tokens"; diff --git a/ui/webui/resources/cr_elements/md_select.css b/ui/webui/resources/cr_elements/md_select.css index c6f72014e5f24..9032a51118467 100644 --- a/ui/webui/resources/cr_elements/md_select.css +++ b/ui/webui/resources/cr_elements/md_select.css @@ -23,7 +23,7 @@ background-size: var(--md-arrow-width); border: solid 1px var(--color-combobox-container-outline, var(--cr-fallback-color-neutral-outline)); - border-radius: 8px; + border-radius: 4px; box-sizing: border-box; color: var(--md-select-text-color); cursor: pointer; diff --git a/ui/webui/resources/cr_elements/cr_button/cr_button.css b/ui/webui/resources/cr_elements/cr_button/cr_button.css index 69dc68d302b63..c0b974153be08 100644 --- a/ui/webui/resources/cr_elements/cr_button/cr_button.css +++ b/ui/webui/resources/cr_elements/cr_button/cr_button.css @@ -74,7 +74,7 @@ user-select: none; -webkit-tap-highlight-color: transparent; border: var(--cr-button-border, 1px solid var(--cr-button-border-color)); - border-radius: 100px; + border-radius: 4px; background: var(--cr-button-background-color); color: var(--cr-button-text-color); font-weight: 500; @@ -92,7 +92,7 @@ } :host(.floating-button) { - border-radius: 8px; + border-radius: 4px; height: 40px; transition: box-shadow 80ms linear; } diff --git a/ui/webui/resources/cr_elements/cr_toggle/cr_toggle.css b/ui/webui/resources/cr_elements/cr_toggle/cr_toggle.css index c467dbadf8e14..a193f5893743d 100644 --- a/ui/webui/resources/cr_elements/cr_toggle/cr_toggle.css +++ b/ui/webui/resources/cr_elements/cr_toggle/cr_toggle.css @@ -28,7 +28,7 @@ --cr-active-neutral-on-subtle-background-color); --cr-toggle-bar-border-color: var(--cr-toggle-unchecked-button-color); --cr-toggle-bar-border: 1px solid var(--cr-toggle-bar-border-color); - --cr-toggle-bar-width: 26px; + --cr-toggle-bar-width: 32px; --cr-toggle-knob-diameter: 8px; -webkit-tap-highlight-color: transparent; cursor: pointer; @@ -92,7 +92,7 @@ border-radius: 50px; box-sizing: border-box; display: block; - height: 16px; + height: 20px; left: 3px; opacity: 1; position: initial;