From f10c65bbf781b4dcb4b608b41563b837902a7381 Mon Sep 17 00:00:00 2001 From: petemill Date: Wed, 29 Aug 2018 12:44:45 -0700 Subject: [PATCH 1/4] Setup layout_constants override --- browser/ui/BUILD.gn | 2 ++ browser/ui/brave_layout_constants.cc | 26 +++++++++++++++++++ browser/ui/brave_layout_constants.h | 9 +++++++ .../chrome/browser/ui/layout_constants.cc | 19 ++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 browser/ui/brave_layout_constants.cc create mode 100644 browser/ui/brave_layout_constants.h create mode 100644 chromium_src/chrome/browser/ui/layout_constants.cc diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index a568c7dac9b1..96025b8a8941 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -10,6 +10,8 @@ source_set("ui") { "brave_browser_content_setting_bubble_model_delegate.h", "brave_pages.cc", "brave_pages.h", + "brave_layout_constants.cc", + "brave_layout_constants.h", "brave_actions/shields_action_view_controller.cc", "brave_actions/shields_action_view_controller.h", "brave_actions/brave_action_icon_with_badge_image_source.cc", diff --git a/browser/ui/brave_layout_constants.cc b/browser/ui/brave_layout_constants.cc new file mode 100644 index 000000000000..a980f846a89b --- /dev/null +++ b/browser/ui/brave_layout_constants.cc @@ -0,0 +1,26 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/browser/ui/brave_layout_constants.h" + +#include "chrome/browser/ui/layout_constants.h" +#include "ui/base/material_design/material_design_controller.h" + +// Returns a |nullopt| if the UI color is not handled by Brave. +base::Optional GetBraveLayoutConstant(LayoutConstant constant) { + // const int mode = ui::MaterialDesignController::GetMode(); + // const bool hybrid = mode == ui::MaterialDesignController::MATERIAL_HYBRID; + // const bool touch_optimized_material = + // ui::MaterialDesignController::IsTouchOptimizedUiEnabled(); + // const bool newer_material = ui::MaterialDesignController::IsNewerMaterialUi(); + switch (constant) { + case LOCATION_BAR_BUBBLE_CORNER_RADIUS: + // Note: this is likely to be moved in to views/layout_provider.h + // in a future chromium version. + return 4; + default: + break; + } + return base::nullopt; +} \ No newline at end of file diff --git a/browser/ui/brave_layout_constants.h b/browser/ui/brave_layout_constants.h new file mode 100644 index 000000000000..3870ad7294e6 --- /dev/null +++ b/browser/ui/brave_layout_constants.h @@ -0,0 +1,9 @@ +#ifndef BRAVE_BROWSER_UI_LAYOUT_CONSTANTS_H_ +#define BRAVE_BROWSER_UI_LAYOUT_CONSTANTS_H_ + +#include "base/optional.h" +#include "chrome/browser/ui/layout_constants.h" + +base::Optional GetBraveLayoutConstant(LayoutConstant constant); + +#endif \ No newline at end of file diff --git a/chromium_src/chrome/browser/ui/layout_constants.cc b/chromium_src/chrome/browser/ui/layout_constants.cc new file mode 100644 index 000000000000..7f1ea301b13c --- /dev/null +++ b/chromium_src/chrome/browser/ui/layout_constants.cc @@ -0,0 +1,19 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#define GetLayoutConstant GetLayoutConstant_ChromiumImpl +#include "../../../../../chrome/browser/ui/layout_constants.cc" +#undef GetLayoutConstant + +#include "brave/browser/ui/brave_layout_constants.h" + +int GetLayoutConstant(LayoutConstant constant) { + // get brave overriden value + const base::Optional braveOption = GetBraveLayoutConstant(constant); + if (braveOption) { + return braveOption.value(); + } + // get chromium value + return GetLayoutConstant_ChromiumImpl(constant); +} From 068261bfe2ed17bd8c9f95f76f4ae0ffe3e93eed Mon Sep 17 00:00:00 2001 From: petemill Date: Fri, 31 Aug 2018 16:39:07 -0700 Subject: [PATCH 2/4] Introduce Private Window theme and refine dark theme Fallback dark and private themes to chromium incognito theme --- browser/themes/brave_theme_service.cc | 43 +++++-- browser/themes/brave_theme_service.h | 17 +-- .../themes/brave_theme_service_browsertest.cc | 14 +-- browser/themes/theme_properties.cc | 116 +++++++++++++----- browser/themes/theme_properties.h | 5 +- .../settings/brave_appearance_handler.cc | 22 ++-- 6 files changed, 148 insertions(+), 69 deletions(-) diff --git a/browser/themes/brave_theme_service.cc b/browser/themes/brave_theme_service.cc index 9ae13accb06f..2440fd068859 100644 --- a/browser/themes/brave_theme_service.cc +++ b/browser/themes/brave_theme_service.cc @@ -13,8 +13,10 @@ #include "base/strings/string_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service_factory.h" +#include "chrome/common/channel_info.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_service.h" +#include "components/version_info/channel.h" // static void BraveThemeService::RegisterProfilePrefs( @@ -23,7 +25,8 @@ void BraveThemeService::RegisterProfilePrefs( } // static -BraveThemeService::BraveThemeType BraveThemeService::GetBraveThemeType(Profile* profile) { +BraveThemeType BraveThemeService::GetUserPreferredBraveThemeType( + Profile* profile) { // allow override via cli flag const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); @@ -31,15 +34,37 @@ BraveThemeService::BraveThemeType BraveThemeService::GetBraveThemeType(Profile* std::string requested_theme_value = command_line.GetSwitchValueASCII(switches::kUiMode); std::string requested_theme_value_lower = base::ToLowerASCII(requested_theme_value); if (requested_theme_value_lower == "light") - return BraveThemeService::BraveThemeType::BRAVE_THEME_TYPE_LIGHT; + return BraveThemeType::BRAVE_THEME_TYPE_LIGHT; if (requested_theme_value_lower == "light") - return BraveThemeService::BraveThemeType::BRAVE_THEME_TYPE_DARK; + return BraveThemeType::BRAVE_THEME_TYPE_DARK; } // get value from preferences - return static_cast( + return static_cast( profile->GetPrefs()->GetInteger(kBraveThemeType)); } +// static +BraveThemeType BraveThemeService::GetActiveBraveThemeType( + Profile* profile) { + const BraveThemeType preferred_theme = + GetUserPreferredBraveThemeType(profile); + switch (preferred_theme) { + case BraveThemeType::BRAVE_THEME_TYPE_DEFAULT: + switch (chrome::GetChannel()) { + case version_info::Channel::STABLE: + case version_info::Channel::BETA: + return BraveThemeType::BRAVE_THEME_TYPE_LIGHT; + case version_info::Channel::DEV: + case version_info::Channel::CANARY: + case version_info::Channel::UNKNOWN: + default: + return BraveThemeType::BRAVE_THEME_TYPE_DARK; + } + default: + return preferred_theme; + } +} + BraveThemeService::BraveThemeService() {} BraveThemeService::~BraveThemeService() {} @@ -56,12 +81,16 @@ void BraveThemeService::Init(Profile* profile) { ThemeService::Init(profile); } + + SkColor BraveThemeService::GetDefaultColor(int id, bool incognito) const { - const base::Optional braveColor = - MaybeGetDefaultColorForBraveUi(id, incognito, profile()); + const BraveThemeType theme = GetActiveBraveThemeType(profile()); + const base::Optional braveColor = MaybeGetDefaultColorForBraveUi(id, incognito, theme); if (braveColor) return braveColor.value(); - + // make sure we fallback to chrome's dark theme (incognito) for our dark theme + if (theme == BraveThemeType::BRAVE_THEME_TYPE_DARK) + incognito = true; return ThemeService::GetDefaultColor(id, incognito); } diff --git a/browser/themes/brave_theme_service.h b/browser/themes/brave_theme_service.h index 8edd55d14e19..c90d906d1653 100644 --- a/browser/themes/brave_theme_service.h +++ b/browser/themes/brave_theme_service.h @@ -12,23 +12,24 @@ namespace user_prefs { class PrefRegistrySyncable; } +enum BraveThemeType { + BRAVE_THEME_TYPE_DEFAULT, // Choose theme by channel + BRAVE_THEME_TYPE_DARK, // Use dark theme regardless of channel + BRAVE_THEME_TYPE_LIGHT, // Use light theme regardless of channel +}; + class BraveThemeService : public ThemeService { public: - enum BraveThemeType { - BRAVE_THEME_TYPE_DEFAULT, // Choose theme by channel - BRAVE_THEME_TYPE_DARK, // Use dark theme regardless of channel - BRAVE_THEME_TYPE_LIGHT, // Use light theme regardless of channel - }; - static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); - static BraveThemeType GetBraveThemeType(Profile* profile); + static BraveThemeType GetUserPreferredBraveThemeType(Profile* profile); + static BraveThemeType GetActiveBraveThemeType(Profile* profile); BraveThemeService(); ~BraveThemeService() override; // ThemeService overrides: void Init(Profile* profile) override; - + protected: // ThemeService overrides: SkColor GetDefaultColor(int id, bool incognito) const override; diff --git a/browser/themes/brave_theme_service_browsertest.cc b/browser/themes/brave_theme_service_browsertest.cc index 1186905daa21..7dc236c36dfa 100644 --- a/browser/themes/brave_theme_service_browsertest.cc +++ b/browser/themes/brave_theme_service_browsertest.cc @@ -15,7 +15,7 @@ using BraveThemeServiceTest = InProcessBrowserTest; using BTS = BraveThemeService; namespace { -void SetBraveThemeType(Profile* profile, BTS::BraveThemeType type) { +void SetBraveThemeType(Profile* profile, BraveThemeType type) { profile->GetPrefs()->SetInteger(kBraveThemeType, type); } } // namespace @@ -23,17 +23,17 @@ void SetBraveThemeType(Profile* profile, BTS::BraveThemeType type) { IN_PROC_BROWSER_TEST_F(BraveThemeServiceTest, BraveThemeChangeTest) { Profile* profile = browser()->profile(); const SkColor light_frame_color = SkColorSetRGB(0xD8, 0xDE, 0xE1); - const SkColor dark_frame_color = SkColorSetRGB(0x58, 0x5B, 0x5E); + const SkColor dark_frame_color = SkColorSetRGB(0x22, 0x22, 0x22); // Check default type is set initially. - EXPECT_EQ(BTS::BRAVE_THEME_TYPE_DEFAULT, BTS::GetBraveThemeType(profile)); + EXPECT_EQ(BraveThemeType::BRAVE_THEME_TYPE_DEFAULT, BTS::GetUserPreferredBraveThemeType(profile)); const ui::ThemeProvider& tp = ThemeService::GetThemeProviderForProfile(profile); - SetBraveThemeType(browser()->profile(), BTS::BRAVE_THEME_TYPE_LIGHT); - EXPECT_EQ(BTS::BRAVE_THEME_TYPE_LIGHT, BTS::GetBraveThemeType(profile)); + SetBraveThemeType(browser()->profile(), BraveThemeType::BRAVE_THEME_TYPE_LIGHT); + EXPECT_EQ(BraveThemeType::BRAVE_THEME_TYPE_LIGHT, BTS::GetUserPreferredBraveThemeType(profile)); EXPECT_EQ(light_frame_color, tp.GetColor(ThemeProperties::COLOR_FRAME)); - SetBraveThemeType(browser()->profile(), BTS::BRAVE_THEME_TYPE_DARK); - EXPECT_EQ(BTS::BRAVE_THEME_TYPE_DARK, BTS::GetBraveThemeType(profile)); + SetBraveThemeType(browser()->profile(), BraveThemeType::BRAVE_THEME_TYPE_DARK); + EXPECT_EQ(BraveThemeType::BRAVE_THEME_TYPE_DARK, BTS::GetUserPreferredBraveThemeType(profile)); EXPECT_EQ(dark_frame_color, tp.GetColor(ThemeProperties::COLOR_FRAME)); } diff --git a/browser/themes/theme_properties.cc b/browser/themes/theme_properties.cc index 0d367164c1f3..16c3f38bc7bc 100644 --- a/browser/themes/theme_properties.cc +++ b/browser/themes/theme_properties.cc @@ -5,92 +5,142 @@ #include "brave/browser/themes/theme_properties.h" #include "brave/browser/themes/brave_theme_service.h" -#include "brave/common/pref_names.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_properties.h" -#include "chrome/common/channel_info.h" -#include "components/prefs/pref_service.h" -#include "components/version_info/channel.h" namespace { -base::Optional MaybeGetDefaultColorForBraveLightUi(int id, bool incognito) { +base::Optional MaybeGetDefaultColorForBraveLightUi(int id) { switch (id) { // Applies when the window is active, tabs and also tab bar everywhere except active tab case ThemeProperties::COLOR_FRAME: case ThemeProperties::COLOR_BACKGROUND_TAB: - return incognito ? SkColorSetRGB(0x81, 0x85, 0x89) : SkColorSetRGB(0xD8, 0xDE, 0xE1); + return SkColorSetRGB(0xD8, 0xDE, 0xE1); // Window when the window is innactive, tabs and also tab bar everywhere except active tab case ThemeProperties::COLOR_FRAME_INACTIVE: case ThemeProperties::COLOR_BACKGROUND_TAB_INACTIVE: - return incognito ? SkColorSetRGB(0x71, 0x75, 0x79) : SkColorSetRGB(0xC8, 0xCE, 0xC8); + return SkColorSetRGB(0xC8, 0xCE, 0xC8); // Active tab and also the URL toolbar // Parts of this color show up as you hover over innactive tabs too case ThemeProperties::COLOR_TOOLBAR: case ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND: case ThemeProperties::COLOR_CONTROL_BACKGROUND: case ThemeProperties::COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR: - return incognito ? SkColorSetRGB(0x91, 0x95, 0x99) : SkColorSetRGB(0xF6, 0xF7, 0xF9); + return SkColorSetRGB(0xF6, 0xF7, 0xF9); case ThemeProperties::COLOR_TAB_TEXT: return SkColorSetRGB(0x22, 0x23, 0x26); case ThemeProperties::COLOR_BOOKMARK_TEXT: case ThemeProperties::COLOR_BACKGROUND_TAB_TEXT: return SkColorSetRGB(0x22, 0x23, 0x26); + case ThemeProperties::COLOR_LOCATION_BAR_BORDER: + return SkColorSetRGB(0xd5, 0xd9, 0xdc); default: return base::nullopt; } } -base::Optional MaybeGetDefaultColorForBraveDarkUi(int id, bool incognito) { +const SkColor kDarkFrame = SkColorSetRGB(0x22, 0x22, 0x22); +const SkColor kDarkToolbar = SkColorSetRGB(0x39, 0x39, 0x39); +const SkColor kDarkToolbarIcon = SkColorSetRGB(0xed, 0xed, 0xed); + +base::Optional MaybeGetDefaultColorForBraveDarkUi(int id) { switch (id) { // Applies when the window is active, tabs and also tab bar everywhere except active tab case ThemeProperties::COLOR_FRAME: case ThemeProperties::COLOR_BACKGROUND_TAB: - return incognito ? SkColorSetRGB(0x68, 0x6B, 0x6E) : SkColorSetRGB(0x58, 0x5B, 0x5E); + return kDarkFrame; // Window when the window is innactive, tabs and also tab bar everywhere except active tab case ThemeProperties::COLOR_FRAME_INACTIVE: case ThemeProperties::COLOR_BACKGROUND_TAB_INACTIVE: - return incognito ? SkColorSetRGB(0x58, 0x5B, 0x5E) : SkColorSetRGB(0x48, 0x4B, 0x4E); + return color_utils::HSLShift(kDarkFrame, { -1, -1, 0.6 }); // Active tab and also the URL toolbar // Parts of this color show up as you hover over innactive tabs too case ThemeProperties::COLOR_TOOLBAR: + case ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR: + case ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR_INACTIVE: case ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND: case ThemeProperties::COLOR_CONTROL_BACKGROUND: case ThemeProperties::COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR: - return incognito ? SkColorSetRGB(0x32, 0x33, 0x36) : SkColorSetRGB(0x22, 0x23, 0x26); + return kDarkToolbar; case ThemeProperties::COLOR_TAB_TEXT: - return SkColorSetRGB(0xF7, 0xF8, 0xF9); + return SkColorSetRGB(0xF3, 0xF3, 0xF3); case ThemeProperties::COLOR_BOOKMARK_TEXT: case ThemeProperties::COLOR_BACKGROUND_TAB_TEXT: - return SkColorSetRGB(0x81, 0x85, 0x89); + return SkColorSetRGB(0xFF, 0xFF, 0xFF); + case ThemeProperties::COLOR_LOCATION_BAR_BORDER: + return SkColorSetRGB(0x22, 0x22, 0x22); + case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON: + return kDarkToolbarIcon; + case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE: + return color_utils::AlphaBlend(kDarkToolbarIcon, kDarkToolbar, 0x4d); default: return base::nullopt; } } +const SkColor kPrivateFrame = SkColorSetRGB(0x1b, 0x0e, 0x2c); +const SkColor kPrivateToolbar = SkColorSetRGB(0x3d, 0x28, 0x41); + +base::Optional MaybeGetDefaultColorForPrivateUi(int id) { + switch (id) { + // Applies when the window is active, tabs and also tab bar everywhere except active tab + case ThemeProperties::COLOR_FRAME: + case ThemeProperties::COLOR_FRAME_INCOGNITO: + case ThemeProperties::COLOR_BACKGROUND_TAB: + case ThemeProperties::COLOR_BACKGROUND_TAB_INCOGNITO: + return kPrivateFrame; + // Window when the window is innactive, tabs and also tab bar everywhere except active tab + case ThemeProperties::COLOR_FRAME_INACTIVE: + case ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE: + case ThemeProperties::COLOR_BACKGROUND_TAB_INCOGNITO_INACTIVE: + return color_utils::HSLShift(kPrivateFrame, { -1, -1, 0.55 }); + // Active tab and also the URL toolbar + // Parts of this color show up as you hover over innactive tabs too + case ThemeProperties::COLOR_TOOLBAR: + case ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND: + case ThemeProperties::COLOR_CONTROL_BACKGROUND: + case ThemeProperties::COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR: + return kPrivateToolbar; + case ThemeProperties::COLOR_TAB_TEXT: + return SkColorSetRGB(0xF3, 0xF3, 0xF3); + case ThemeProperties::COLOR_BOOKMARK_TEXT: + case ThemeProperties::COLOR_BACKGROUND_TAB_TEXT: + return SkColorSetRGB(0xFF, 0xFF, 0xFF); + case ThemeProperties::COLOR_LOCATION_BAR_BORDER: + return kPrivateFrame; + case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON: + return kDarkToolbarIcon; + case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE: + return color_utils::AlphaBlend(kDarkToolbarIcon, kPrivateToolbar, 0x4d); + // The rest is covered by a dark-appropriate value + default: + return MaybeGetDefaultColorForBraveDarkUi(id); + } +} + } // namespace // Returns a |nullopt| if the UI color is not handled by Brave. -base::Optional MaybeGetDefaultColorForBraveUi(int id, bool incognito, Profile* profile) { - switch (BraveThemeService::GetBraveThemeType(profile)) { - case BraveThemeService::BRAVE_THEME_TYPE_DEFAULT: - switch (chrome::GetChannel()) { - case version_info::Channel::STABLE: - case version_info::Channel::BETA: - return MaybeGetDefaultColorForBraveLightUi(id, incognito); - case version_info::Channel::DEV: - case version_info::Channel::CANARY: - case version_info::Channel::UNKNOWN: - default: - return MaybeGetDefaultColorForBraveDarkUi(id, incognito); - } - case BraveThemeService::BRAVE_THEME_TYPE_LIGHT: - return MaybeGetDefaultColorForBraveLightUi(id, incognito); - case BraveThemeService::BRAVE_THEME_TYPE_DARK: - return MaybeGetDefaultColorForBraveDarkUi(id, incognito); +base::Optional MaybeGetDefaultColorForBraveUi(int id, bool incognito, BraveThemeType theme) { + // Consistent (and stable) values across all themes + switch (id) { + case ThemeProperties::COLOR_TAB_THROBBER_SPINNING: + return SkColorSetRGB(0xd7, 0x55, 0x26); default: - NOTREACHED(); + break; + } + // Allow Private Window theme to override dark vs light + if (incognito) { + return MaybeGetDefaultColorForPrivateUi(id); + } + // Get Dark or Light value + switch (theme) { + case BraveThemeType::BRAVE_THEME_TYPE_LIGHT: + return MaybeGetDefaultColorForBraveLightUi(id); + case BraveThemeType::BRAVE_THEME_TYPE_DARK: + return MaybeGetDefaultColorForBraveDarkUi(id); + default: + NOTREACHED(); } return base::nullopt; } diff --git a/browser/themes/theme_properties.h b/browser/themes/theme_properties.h index 7dd7a7bbad7d..98b0c3ff3cda 100644 --- a/browser/themes/theme_properties.h +++ b/browser/themes/theme_properties.h @@ -7,11 +7,10 @@ #include "base/optional.h" #include "third_party/skia/include/core/SkColor.h" - -class Profile; +#include "brave/browser/themes/brave_theme_service.h" #define BRAVE_COLOR_FOR_TEST 0x7FFFFFFF -base::Optional MaybeGetDefaultColorForBraveUi(int id, bool incognito, Profile* profile); +base::Optional MaybeGetDefaultColorForBraveUi(int id, bool incognito, BraveThemeType theme); #endif // BRAVE_BROWSER_THEMES_THEME_PROPERTIES_H_ diff --git a/browser/ui/webui/settings/brave_appearance_handler.cc b/browser/ui/webui/settings/brave_appearance_handler.cc index b0e81d8d7238..8378c053dc7d 100644 --- a/browser/ui/webui/settings/brave_appearance_handler.cc +++ b/browser/ui/webui/settings/brave_appearance_handler.cc @@ -16,33 +16,33 @@ namespace { void SetBraveThemeTypePref(Profile* profile, - BraveThemeService::BraveThemeType type) { + BraveThemeType type) { profile->GetPrefs()->SetInteger(kBraveThemeType, type); } -BraveThemeService::BraveThemeType GetBraveThemeTypeFromString( +BraveThemeType GetBraveThemeTypeFromString( base::StringPiece theme) { if (theme == "Default") - return BraveThemeService::BRAVE_THEME_TYPE_DEFAULT; + return BraveThemeType::BRAVE_THEME_TYPE_DEFAULT; if (theme == "Light") - return BraveThemeService::BRAVE_THEME_TYPE_LIGHT; + return BraveThemeType::BRAVE_THEME_TYPE_LIGHT; if (theme == "Dark") - return BraveThemeService::BRAVE_THEME_TYPE_DARK; + return BraveThemeType::BRAVE_THEME_TYPE_DARK; NOTREACHED(); - return BraveThemeService::BRAVE_THEME_TYPE_DEFAULT; + return BraveThemeType::BRAVE_THEME_TYPE_DEFAULT; } std::string GetStringFromBraveThemeType( - BraveThemeService::BraveThemeType theme) { + BraveThemeType theme) { switch (theme) { - case BraveThemeService::BRAVE_THEME_TYPE_DEFAULT: + case BraveThemeType::BRAVE_THEME_TYPE_DEFAULT: return "Default"; - case BraveThemeService::BRAVE_THEME_TYPE_LIGHT: + case BraveThemeType::BRAVE_THEME_TYPE_LIGHT: return "Light"; - case BraveThemeService::BRAVE_THEME_TYPE_DARK: + case BraveThemeType::BRAVE_THEME_TYPE_DARK: return "Dark"; default: NOTREACHED(); @@ -80,5 +80,5 @@ void BraveAppearanceHandler::GetBraveThemeType(const base::ListValue* args) { ResolveJavascriptCallback( args->GetList()[0].Clone(), base::Value(GetStringFromBraveThemeType( - BraveThemeService::GetBraveThemeType(profile_)))); + BraveThemeService::GetUserPreferredBraveThemeType(profile_)))); } From 9183b494ae16dc3aae54aee8c672ab31eb1afef3 Mon Sep 17 00:00:00 2001 From: petemill Date: Fri, 31 Aug 2018 16:41:06 -0700 Subject: [PATCH 3/4] Override GetOmniboxColor for Brave Theme Extend OmniboxTint to accept Private as well as Light and Dark --- .../location_bar/brave_location_bar_view.cc | 27 ++++++ .../location_bar/brave_location_bar_view.h | 2 + .../browser/ui/omnibox/omnibox_theme.cc | 91 +++++++++++++++++++ .../chrome/browser/ui/omnibox/omnibox_theme.h | 31 +++++++ ...ews-location_bar-location_bar_view.h.patch | 11 ++- 5 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 chromium_src/chrome/browser/ui/omnibox/omnibox_theme.cc create mode 100644 chromium_src/chrome/browser/ui/omnibox/omnibox_theme.h diff --git a/browser/ui/views/location_bar/brave_location_bar_view.cc b/browser/ui/views/location_bar/brave_location_bar_view.cc index 226207995ebd..4fd4fe323d33 100644 --- a/browser/ui/views/location_bar/brave_location_bar_view.cc +++ b/browser/ui/views/location_bar/brave_location_bar_view.cc @@ -4,12 +4,19 @@ #include "brave/browser/ui/views/location_bar/brave_location_bar_view.h" +#include "brave/browser/themes/brave_theme_service.h" +#include "chrome/browser/profiles/profile.h" #include "brave/browser/ui/views/brave_actions/brave_actions_container.h" #include "chrome/browser/ui/layout_constants.h" +#include "chrome/browser/ui/omnibox/omnibox_theme.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "chrome/browser/ui/views/location_bar/star_view.h" +#include "components/version_info/channel.h" void BraveLocationBarView::Init() { + // LocationBarView (original) GetTint is called from ctor, + // which will not use our overriden function, so call it again here. + tint_ = GetTint(); // base method calls Update and Layout LocationBarView::Init(); // brave action buttons @@ -62,9 +69,29 @@ gfx::Size BraveLocationBarView::CalculatePreferredSize() const { return min_size; } +OmniboxTint BraveLocationBarView::GetTint() { + // Match the user-selectable brave theme, even if there is a theme extension + // installed, allowing non-extension-themeable elements to fit in better with + // a theme extension. + if (profile()->GetProfileType() == Profile::INCOGNITO_PROFILE) { + return OmniboxTint::PRIVATE; // special extra enum value + } + // TODO: BraveThemeService can have a simpler get dark / light function + switch (BraveThemeService::GetActiveBraveThemeType(profile())) { + case BraveThemeType::BRAVE_THEME_TYPE_LIGHT: + return OmniboxTint::LIGHT; + case BraveThemeType::BRAVE_THEME_TYPE_DARK: + return OmniboxTint::DARK; + default: + NOTREACHED(); + return OmniboxTint::LIGHT; + } +} + // Provide base class implementation for Update override that has been added to // header via a patch. This should never be called as the only instantiated // implementation should be our |BraveLocationBarView|. void LocationBarView::Layout() { Layout(nullptr); } + diff --git a/browser/ui/views/location_bar/brave_location_bar_view.h b/browser/ui/views/location_bar/brave_location_bar_view.h index 9dde7ffc31a5..e8f7d6d4bf53 100644 --- a/browser/ui/views/location_bar/brave_location_bar_view.h +++ b/browser/ui/views/location_bar/brave_location_bar_view.h @@ -8,6 +8,7 @@ #include "chrome/browser/ui/views/location_bar/location_bar_view.h" class BraveActionsContainer; +enum class OmniboxTint; // The purposes of this subclass are to: // - Add the BraveActionsContainer to the location bar @@ -21,6 +22,7 @@ class BraveLocationBarView : public LocationBarView { gfx::Size CalculatePreferredSize() const override; private: void UpdateBookmarkStarVisibility() override; + OmniboxTint GetTint() override; BraveActionsContainer* brave_actions_ = nullptr; DISALLOW_COPY_AND_ASSIGN(BraveLocationBarView); diff --git a/chromium_src/chrome/browser/ui/omnibox/omnibox_theme.cc b/chromium_src/chrome/browser/ui/omnibox/omnibox_theme.cc new file mode 100644 index 000000000000..dca14240131f --- /dev/null +++ b/chromium_src/chrome/browser/ui/omnibox/omnibox_theme.cc @@ -0,0 +1,91 @@ +#include "chrome/browser/ui/omnibox/omnibox_theme.h" + +// Rewrite original function name (see header file) +#define GetOmniboxColor GetOmniboxColor_ChromiumImpl +#define OmniboxTint OmniboxTint_Chromium +#include "../../../chrome/browser/ui/omnibox/omnibox_theme.cc" +#undef GetOmniboxColor +#undef OmniboxTint + +namespace { + +OmniboxTint_Chromium BraveTintToChromiumTint(OmniboxTint brave_tint) { + switch (brave_tint) { + case OmniboxTint::PRIVATE: + case OmniboxTint::DARK: + return OmniboxTint_Chromium::DARK; + case OmniboxTint::LIGHT: + return OmniboxTint_Chromium::LIGHT; + case OmniboxTint::NATIVE: + return OmniboxTint_Chromium::NATIVE; + default: + return OmniboxTint_Chromium::LIGHT; + } +} + +constexpr SkColor DarkPrivateLight(OmniboxTint tint, + SkColor dark, + SkColor priv, + SkColor light) { + switch (tint) { + case OmniboxTint::DARK: + return dark; + case OmniboxTint::PRIVATE: + return priv; + default: + return light; + } +} + +const SkColor kPrivateLocationBarBackground = SkColorSetRGB(0x1b, 0x0e, 0x2c); + +} + +// Overriden version +SkColor GetOmniboxColor(OmniboxPart part, + OmniboxTint tint, + OmniboxPartState state) { + // Note: OmniboxTint::NATIVE is no longer possible + const bool dark = tint == OmniboxTint::DARK; + const bool priv = tint == OmniboxTint::PRIVATE; + // For high contrast, selected rows use inverted colors to stand out more. + ui::NativeTheme* native_theme = ui::NativeTheme::GetInstanceForNativeUi(); + bool high_contrast = native_theme && native_theme->UsesHighContrastColors(); + // TODO(petemill): Get colors from color-pallete and theme constants + switch (part) { + case OmniboxPart::LOCATION_BAR_BACKGROUND: { + const bool hovered = state == OmniboxPartState::HOVERED; + return dark ? (hovered ? SkColorSetRGB(0x44, 0x44, 0x44) + : SkColorSetRGB(0x22, 0x22, 0x22)) + : (priv ? color_utils::HSLShift( + kPrivateLocationBarBackground, { + -1, + -1, + hovered ? 0.54 : 0.52 }) + : (hovered ? gfx::kGoogleGrey100 + : SkColorSetRGB(0xff, 0xff, 0xff))); + } + case OmniboxPart::LOCATION_BAR_TEXT_DEFAULT: + case OmniboxPart::RESULTS_TEXT_DEFAULT: { + return (dark || priv) ? SkColorSetRGB(0xff, 0xff, 0xff) + : SkColorSetRGB(0x42, 0x42, 0x42); + } + case OmniboxPart::RESULTS_BACKGROUND: + return color_utils::BlendTowardOppositeLuma( + DarkPrivateLight(tint, + high_contrast ? gfx::kGoogleGrey900 : gfx::kGoogleGrey800, + color_utils::HSLShift(kPrivateLocationBarBackground, { + -1, + -1, + high_contrast ? 0.45 + : 0.56 }), + SK_ColorWHITE), + gfx::ToRoundedInt(GetOmniboxStateAlpha(state) * 0xff)); + default: + break; + } + + // All other values, call original function + OmniboxTint_Chromium translate_value = BraveTintToChromiumTint(tint); + return GetOmniboxColor_ChromiumImpl(part, translate_value, state); +} \ No newline at end of file diff --git a/chromium_src/chrome/browser/ui/omnibox/omnibox_theme.h b/chromium_src/chrome/browser/ui/omnibox/omnibox_theme.h new file mode 100644 index 000000000000..7dc5ea98568c --- /dev/null +++ b/chromium_src/chrome/browser/ui/omnibox/omnibox_theme.h @@ -0,0 +1,31 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_THEME_H_OVERRIDE_ +#define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_THEME_H_OVERRIDE_ + +// Intention is to add a value to OmniboxTint since we want to support more +// states than Chromium but do not want to override / patch every call +// to GetOmniboxColor. +// We'd rather override LocationBarView::GetTint to return the extra enum value +// and override GetOmniboxColor to support it. So that means allowing the many +// places which pass around the enum value to support our enum values instead. + +// re-define original enum +#define OmniboxTint OmniboxTint_Chromium +#define GetOmniboxColor GetOmniboxColor_ChromiumImpl +#include "../../../chrome/browser/ui/omnibox/omnibox_theme.h" +#undef OmniboxTint +#undef GetOmniboxColor + +// define new enum +enum class OmniboxTint { DARK, LIGHT, NATIVE, PRIVATE }; + +// Returns the color for the given |part| and |tint|. An optional |state| can be +// provided for OmniboxParts that support stateful colors. +SkColor GetOmniboxColor(OmniboxPart part, + OmniboxTint tint, + OmniboxPartState state = OmniboxPartState::NORMAL); + +#endif diff --git a/patches/chrome-browser-ui-views-location_bar-location_bar_view.h.patch b/patches/chrome-browser-ui-views-location_bar-location_bar_view.h.patch index 9fea803ed155..e0173bfec841 100644 --- a/patches/chrome-browser-ui-views-location_bar-location_bar_view.h.patch +++ b/patches/chrome-browser-ui-views-location_bar-location_bar_view.h.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h -index d32fe4bf3e5f95b1be19d90f0cb1bb85dd48b7e6..2bcc385a1bc3ce38e9b7c93a1407a02b7c24e796 100644 +index d32fe4bf3e5f95b1be19d90f0cb1bb85dd48b7e6..1792f9a36b9bbcc6928120123ce3d27752d55f0f 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.h +++ b/chrome/browser/ui/views/location_bar/location_bar_view.h @@ -50,6 +50,7 @@ class Profile; @@ -44,3 +44,12 @@ index d32fe4bf3e5f95b1be19d90f0cb1bb85dd48b7e6..2bcc385a1bc3ce38e9b7c93a1407a02b void OnThemeChanged() override; void OnNativeThemeChanged(const ui::NativeTheme* theme) override; void ChildPreferredSizeChanged(views::View* child) override; +@@ -332,7 +335,7 @@ class LocationBarView : public LocationBar, + OmniboxPopupView* GetOmniboxPopupView(); + + // Gets the theme color tint for the location bar and results. +- OmniboxTint GetTint(); ++ virtual OmniboxTint GetTint(); + + // LocationBar: + GURL GetDestinationURL() const override; From 966b6d55bf83f283f8da4615159e399f37f882bd Mon Sep 17 00:00:00 2001 From: petemill Date: Wed, 29 Aug 2018 12:45:07 -0700 Subject: [PATCH 4/4] Border Radii for Tabs, Buttons, LocationBar Note that the static LocationBarView::IsRounded is a misnomer since it controls function (i.e. "Should Omnibox Wrap LocationBar"), and not just the shape. Similarly, NewTabButton confusingly uses border radius to infer Button width, so some workarounds need to be employed to use content bounds width instead. Tab height is also reduced in order to match a smaller border radius, otherwise there is too much visual empty surface area. --- browser/themes/theme_properties.cc | 10 +++- browser/ui/BUILD.gn | 4 ++ browser/ui/brave_layout_constants.cc | 6 ++- browser/ui/views/brave_layout_provider.cc | 23 ++++++++++ browser/ui/views/brave_layout_provider.h | 24 ++++++++++ browser/ui/views/tabs/brave_new_tab_button.cc | 46 +++++++++++++++++++ browser/ui/views/tabs/brave_new_tab_button.h | 25 ++++++++++ .../ui/views/chrome_layout_provider.cc | 4 ++ .../chrome/browser/ui/views/tabs/tab_strip.cc | 4 ++ ...owser-ui-views-tabs-new_tab_button.h.patch | 21 +++++++++ 10 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 browser/ui/views/brave_layout_provider.cc create mode 100644 browser/ui/views/brave_layout_provider.h create mode 100644 browser/ui/views/tabs/brave_new_tab_button.cc create mode 100644 browser/ui/views/tabs/brave_new_tab_button.h create mode 100644 chromium_src/chrome/browser/ui/views/chrome_layout_provider.cc create mode 100644 chromium_src/chrome/browser/ui/views/tabs/tab_strip.cc create mode 100644 patches/chrome-browser-ui-views-tabs-new_tab_button.h.patch diff --git a/browser/themes/theme_properties.cc b/browser/themes/theme_properties.cc index 16c3f38bc7bc..d51f370d5aa2 100644 --- a/browser/themes/theme_properties.cc +++ b/browser/themes/theme_properties.cc @@ -67,7 +67,10 @@ base::Optional MaybeGetDefaultColorForBraveDarkUi(int id) { case ThemeProperties::COLOR_BACKGROUND_TAB_TEXT: return SkColorSetRGB(0xFF, 0xFF, 0xFF); case ThemeProperties::COLOR_LOCATION_BAR_BORDER: - return SkColorSetRGB(0x22, 0x22, 0x22); + // TODO: Should be location bar background, but location bar has hover + // color which we don't have access to here. + // Consider increasing height instead. + return kDarkToolbar; case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON: return kDarkToolbarIcon; case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE: @@ -106,7 +109,10 @@ base::Optional MaybeGetDefaultColorForPrivateUi(int id) { case ThemeProperties::COLOR_BACKGROUND_TAB_TEXT: return SkColorSetRGB(0xFF, 0xFF, 0xFF); case ThemeProperties::COLOR_LOCATION_BAR_BORDER: - return kPrivateFrame; + // TODO: Should be location bar background, but location bar has hover + // color which we don't have access to here. + // Consider increasing height instead. + return kPrivateToolbar; case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON: return kDarkToolbarIcon; case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE: diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index 96025b8a8941..ef05d2a767a5 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -32,6 +32,8 @@ source_set("ui") { "toolbar/brave_app_menu_model.h", "toolbar/brave_toolbar_actions_model.cc", "toolbar/brave_toolbar_actions_model.h", + "views/brave_layout_provider.cc", + "views/brave_layout_provider.h", "views/brave_actions/brave_actions_container.cc", "views/brave_actions/brave_actions_container.h", "views/frame/brave_browser_view.cc", @@ -40,6 +42,8 @@ source_set("ui") { "views/importer/brave_import_lock_dialog_view.h", "views/location_bar/brave_location_bar_view.cc", "views/location_bar/brave_location_bar_view.h", + "views/tabs/brave_new_tab_button.cc", + "views/tabs/brave_new_tab_button.h", "views/toolbar/bookmark_button.cc", "views/toolbar/bookmark_button.h", "views/toolbar/brave_toolbar_view.cc", diff --git a/browser/ui/brave_layout_constants.cc b/browser/ui/brave_layout_constants.cc index a980f846a89b..86af75f601db 100644 --- a/browser/ui/brave_layout_constants.cc +++ b/browser/ui/brave_layout_constants.cc @@ -9,7 +9,7 @@ // Returns a |nullopt| if the UI color is not handled by Brave. base::Optional GetBraveLayoutConstant(LayoutConstant constant) { - // const int mode = ui::MaterialDesignController::GetMode(); + const int mode = ui::MaterialDesignController::GetMode(); // const bool hybrid = mode == ui::MaterialDesignController::MATERIAL_HYBRID; // const bool touch_optimized_material = // ui::MaterialDesignController::IsTouchOptimizedUiEnabled(); @@ -19,6 +19,10 @@ base::Optional GetBraveLayoutConstant(LayoutConstant constant) { // Note: this is likely to be moved in to views/layout_provider.h // in a future chromium version. return 4; + case TAB_HEIGHT: { + constexpr int kTabHeight[] = {29, 33, 41, 30, 37}; + return kTabHeight[mode] + GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP); + } default: break; } diff --git a/browser/ui/views/brave_layout_provider.cc b/browser/ui/views/brave_layout_provider.cc new file mode 100644 index 000000000000..ab9f9dc3e496 --- /dev/null +++ b/browser/ui/views/brave_layout_provider.cc @@ -0,0 +1,23 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/browser/ui/views/brave_layout_provider.h" + +#include "ui/views/layout/layout_provider.h" + +int BraveLayoutProvider::GetCornerRadiusMetric( + views::EmphasisMetric emphasis_metric, + const gfx::Size& size) const { + switch (emphasis_metric) { + case views::EMPHASIS_NONE: + NOTREACHED(); + return 0; + case views::EMPHASIS_LOW: + case views::EMPHASIS_MEDIUM: + return 2; + case views::EMPHASIS_HIGH: + case views::EMPHASIS_MAXIMUM: + return 4; + } +} diff --git a/browser/ui/views/brave_layout_provider.h b/browser/ui/views/brave_layout_provider.h new file mode 100644 index 000000000000..682f38c1fcff --- /dev/null +++ b/browser/ui/views/brave_layout_provider.h @@ -0,0 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_BROWSER_UI_VIEWS_BRAVE_LAYOUT_PROVIDER_H_ +#define BRAVE_BROWSER_UI_VIEWS_BRAVE_LAYOUT_PROVIDER_H_ + +#include "base/macros.h" +#include "chrome/browser/ui/views/material_refresh_layout_provider.h" + +// Subclasses MaterialRefresh layout though if this class start to override most +// members, then it should directly subclass ChromeLayoutProvider. +class BraveLayoutProvider : public MaterialRefreshLayoutProvider { + public: + BraveLayoutProvider() = default; + ~BraveLayoutProvider() override = default; + + int GetCornerRadiusMetric(views::EmphasisMetric emphasis_metric, + const gfx::Size& size = gfx::Size()) const override; + private: + DISALLOW_COPY_AND_ASSIGN(BraveLayoutProvider); +}; + +#endif diff --git a/browser/ui/views/tabs/brave_new_tab_button.cc b/browser/ui/views/tabs/brave_new_tab_button.cc new file mode 100644 index 000000000000..84394d272f00 --- /dev/null +++ b/browser/ui/views/tabs/brave_new_tab_button.cc @@ -0,0 +1,46 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/browser/ui/views/tabs/brave_new_tab_button.h" +#include "chrome/browser/ui/layout_constants.h" +#include "chrome/browser/ui/views/tabs/new_tab_button.h" +#include "chrome/browser/ui/views/tabs/tab_strip.h" +#include "ui/gfx/geometry/size.h" + +namespace { + // Returns the size of the button without any margin + gfx::Size GetButtonSize() { + return gfx::Size(20, 20); + } +} + +BraveNewTabButton::BraveNewTabButton( + TabStrip* tab_strip, views::ButtonListener* listener) + : NewTabButton(tab_strip, listener) { + // Overriden so that we use Brave's custom button size + const int margin_vertical = (GetLayoutConstant(TAB_HEIGHT) - + GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP) - + GetButtonSize().height()) / 2; + SetBorder( + views::CreateEmptyBorder(gfx::Insets(margin_vertical, 8, 0, 8)) + ); +} + +BraveNewTabButton::~BraveNewTabButton() {} + +gfx::Size BraveNewTabButton::CalculatePreferredSize() const { + // Overriden so that we use Brave's custom button size + gfx::Size size = GetButtonSize(); + const auto insets = GetInsets(); + size.Enlarge(insets.width(), insets.height()); + return size; +} + +void BraveNewTabButton::PaintPlusIcon(gfx::Canvas* canvas, int offset, int size) { + // Overriden as Chromium incorrectly uses border radius as the width of + // the button, which *happens* to be correct as the button is round (at the + // moment). So this passes the correct values in for offset. + const int fixed_offset = (GetContentsBounds().width() / 2) - (size / 2); + NewTabButton::PaintPlusIcon(canvas, fixed_offset, size); +} diff --git a/browser/ui/views/tabs/brave_new_tab_button.h b/browser/ui/views/tabs/brave_new_tab_button.h new file mode 100644 index 000000000000..f692ec9187e4 --- /dev/null +++ b/browser/ui/views/tabs/brave_new_tab_button.h @@ -0,0 +1,25 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public ++ * License, v. 2.0. If a copy of the MPL was not distributed with this file, ++ * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_NEW_TAB_BUTTON_H_ +#define BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_NEW_TAB_BUTTON_H_ + +#include "chrome/browser/ui/views/tabs/new_tab_button.h" + +class TabStrip; +namespace views { + class ButtonListener; +} + +class BraveNewTabButton : public NewTabButton { + public: + BraveNewTabButton(TabStrip* tab_strip, views::ButtonListener* listener); + ~BraveNewTabButton() override; + private: + gfx::Size CalculatePreferredSize() const override; + void PaintPlusIcon(gfx::Canvas* canvas, int offset, int size) override; + DISALLOW_COPY_AND_ASSIGN(BraveNewTabButton); +}; + +#endif diff --git a/chromium_src/chrome/browser/ui/views/chrome_layout_provider.cc b/chromium_src/chrome/browser/ui/views/chrome_layout_provider.cc new file mode 100644 index 000000000000..64942ae49b4e --- /dev/null +++ b/chromium_src/chrome/browser/ui/views/chrome_layout_provider.cc @@ -0,0 +1,4 @@ +#include "brave/browser/ui/views/brave_layout_provider.h" +#define MaterialRefreshLayoutProvider BraveLayoutProvider +#include "../../../../../chrome/browser/ui/views/chrome_layout_provider.cc" +#undef MaterialRefreshLayoutProvider diff --git a/chromium_src/chrome/browser/ui/views/tabs/tab_strip.cc b/chromium_src/chrome/browser/ui/views/tabs/tab_strip.cc new file mode 100644 index 000000000000..08451df9a2d5 --- /dev/null +++ b/chromium_src/chrome/browser/ui/views/tabs/tab_strip.cc @@ -0,0 +1,4 @@ +#include "brave/browser/ui/views/tabs/brave_new_tab_button.h" +#define NewTabButton BraveNewTabButton +#include "../../../../../../chrome/browser/ui/views/tabs/tab_strip.cc" +#undef NewTabButton diff --git a/patches/chrome-browser-ui-views-tabs-new_tab_button.h.patch b/patches/chrome-browser-ui-views-tabs-new_tab_button.h.patch new file mode 100644 index 000000000000..e9f717219c6c --- /dev/null +++ b/patches/chrome-browser-ui-views-tabs-new_tab_button.h.patch @@ -0,0 +1,21 @@ +diff --git a/chrome/browser/ui/views/tabs/new_tab_button.h b/chrome/browser/ui/views/tabs/new_tab_button.h +index ee40211315f979cfc34a7373195b2179b72429d4..9b3715cfe72390310b277f1ed0361821558da189 100644 +--- a/chrome/browser/ui/views/tabs/new_tab_button.h ++++ b/chrome/browser/ui/views/tabs/new_tab_button.h +@@ -25,6 +25,7 @@ class NewTabButton : public views::ImageButton, + public views::MaskedTargeterDelegate, + public views::WidgetObserver { + public: ++ friend class BraveNewTabButton; + NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener); + ~NewTabButton() override; + +@@ -107,7 +108,7 @@ class NewTabButton : public views::ImageButton, + gfx::Canvas* canvas) const; + + // Paints a properly sized plus (+) icon into the center of the button. +- void PaintPlusIcon(gfx::Canvas* canvas, int offset, int size); ++ virtual void PaintPlusIcon(gfx::Canvas* canvas, int offset, int size); + + SkColor GetButtonFillColor(bool opaque) const; + SkColor GetIconColor() const;