From d8d77c08fe868dd85a864d66f3f81e97c50985bd Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Sun, 20 Mar 2022 22:00:24 +0900 Subject: [PATCH] Picked brave vpn button colors based on toolbar color fix https://github.com/brave/brave-browser/issues/21242 VPN Button's colors are selected by choosing most contrasted colors based on current toolbar color. --- browser/themes/brave_theme_helper.cc | 22 ++++++++++++++++++++-- browser/themes/sources.gni | 6 +++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/browser/themes/brave_theme_helper.cc b/browser/themes/brave_theme_helper.cc index 64c076525727..0106525176f3 100644 --- a/browser/themes/brave_theme_helper.cc +++ b/browser/themes/brave_theme_helper.cc @@ -8,6 +8,7 @@ #include "base/numerics/safe_conversions.h" #include "brave/browser/themes/brave_dark_mode_utils.h" #include "brave/browser/themes/theme_properties.h" +#include "brave/components/brave_vpn/buildflags/buildflags.h" #include "brave/components/sidebar/buildflags/buildflags.h" #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/omnibox/omnibox_theme.h" @@ -107,10 +108,10 @@ SkColor BraveThemeHelper::GetDefaultColor( incognito = true; } -#if BUILDFLAG(ENABLE_SIDEBAR) switch (id) { // Pick most contrast color between our light and dark colors based on // current toolbar color. +#if BUILDFLAG(ENABLE_SIDEBAR) case BraveThemeProperties::COLOR_SIDEBAR_ITEM_DRAG_INDICATOR_COLOR: case BraveThemeProperties::COLOR_SIDEBAR_ADD_BUTTON_DISABLED: case BraveThemeProperties::COLOR_SIDEBAR_BUTTON_BASE: @@ -138,10 +139,27 @@ SkColor BraveThemeHelper::GetDefaultColor( incognito, theme_supplier), 0xFF * kToolbarInkDropHighlightVisibleOpacity); } +#endif +#if BUILDFLAG(ENABLE_BRAVE_VPN) + case BraveThemeProperties::COLOR_BRAVE_VPN_BUTTON_BORDER: + case BraveThemeProperties::COLOR_BRAVE_VPN_BUTTON_TEXT_CONNECTED: + case BraveThemeProperties::COLOR_BRAVE_VPN_BUTTON_TEXT_DISCONNECTED: { + const auto toolbar_color = + GetColor(ThemeProperties::COLOR_TOOLBAR, incognito, theme_supplier); + const auto color_for_light = MaybeGetDefaultColorForBraveUi( + id, incognito, is_tor_, + dark_mode::BraveDarkModeType::BRAVE_DARK_MODE_TYPE_LIGHT); + const auto color_for_dark = MaybeGetDefaultColorForBraveUi( + id, incognito, is_tor_, + dark_mode::BraveDarkModeType::BRAVE_DARK_MODE_TYPE_DARK); + DCHECK(color_for_light && color_for_dark); + return color_utils::PickContrastingColor( + color_for_light.value(), color_for_dark.value(), toolbar_color); + } +#endif default: break; } -#endif const dark_mode::BraveDarkModeType type = dark_mode::GetActiveBraveDarkModeType(); diff --git a/browser/themes/sources.gni b/browser/themes/sources.gni index 3bc70d83e50c..2dbde059d2cc 100644 --- a/browser/themes/sources.gni +++ b/browser/themes/sources.gni @@ -28,8 +28,12 @@ if (!is_android) { "//brave/app:brave_generated_resources_grit", "//brave/common:pref_names", "//brave/common:switches", + "//brave/components/brave_vpn/buildflags", + "//brave/components/sidebar/buildflags", "//chrome/common", - "//components/prefs", "//components/pref_registry", + "//components/prefs", + "//ui/gfx", + "//ui/native_theme", ] }