Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picked brave vpn button colors based on toolbar color #12675

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more missing deps from brave_theme_helpers.cc

"//ui/gfx",
"//ui/native_theme",
]
}