Skip to content

Commit

Permalink
Merge pull request #12675 from brave/brave_vpn_button_colors
Browse files Browse the repository at this point in the history
Picked brave vpn button colors based on toolbar color
  • Loading branch information
simonhong authored Mar 21, 2022
2 parents 157d6e3 + d8d77c0 commit 1f8ff56
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
22 changes: 20 additions & 2 deletions browser/themes/brave_theme_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion browser/themes/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}

0 comments on commit 1f8ff56

Please sign in to comment.