Commit 31d82b37 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Fix a toolbar button test when the system is in dark mode.

This was never updated for the identity pill work.

Bug: none
Change-Id: I129b3184d997612c960253dfd596423d2beca068
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071576
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744394}
parent 159524df
...@@ -75,11 +75,6 @@ AvatarToolbarButton::AvatarToolbarButton(Browser* browser, ...@@ -75,11 +75,6 @@ AvatarToolbarButton::AvatarToolbarButton(Browser* browser,
// the left and the (potential) user name on the right. // the left and the (potential) user name on the right.
SetHorizontalAlignment(gfx::ALIGN_LEFT); SetHorizontalAlignment(gfx::ALIGN_LEFT);
// Set initial text and tooltip. UpdateIcon() needs to be called from the
// outside as GetThemeProvider() is not available until the button is added to
// ToolbarView's hierarchy.
UpdateText();
md_observer_.Add(ui::MaterialDesignController::GetInstance()); md_observer_.Add(ui::MaterialDesignController::GetInstance());
// TODO(crbug.com/922525): DCHECK(parent_) instead of the if, once we always // TODO(crbug.com/922525): DCHECK(parent_) instead of the if, once we always
......
...@@ -4,12 +4,10 @@ ...@@ -4,12 +4,10 @@
#include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h" #include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/test_with_browser_view.h" #include "chrome/browser/ui/views/frame/test_with_browser_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_account_icon_container_view.h" #include "chrome/browser/ui/views/toolbar/toolbar_account_icon_container_view.h"
#include "ui/base/theme_provider.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -26,7 +24,7 @@ TEST_F(AvatarToolbarButtonTest, HighlightMeetsMinimumContrast) { ...@@ -26,7 +24,7 @@ TEST_F(AvatarToolbarButtonTest, HighlightMeetsMinimumContrast) {
browser_view()->GetWidget()->GetContentsView()->AddChildView(button.get()); browser_view()->GetWidget()->GetContentsView()->AddChildView(button.get());
SkColor toolbar_color = SkColor toolbar_color =
button->GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR); ToolbarButton::GetDefaultBackgroundColor(button->GetThemeProvider());
SkColor highlight_color = SkColorSetRGB(0xFE, 0x00, 0x00); SkColor highlight_color = SkColorSetRGB(0xFE, 0x00, 0x00);
DCHECK_LT(color_utils::GetContrastRatio(highlight_color, toolbar_color), DCHECK_LT(color_utils::GetContrastRatio(highlight_color, toolbar_color),
......
...@@ -53,11 +53,6 @@ SkColor GetDefaultTextColor(const ui::ThemeProvider* theme_provider) { ...@@ -53,11 +53,6 @@ SkColor GetDefaultTextColor(const ui::ThemeProvider* theme_provider) {
theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR)); theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR));
} }
SkColor GetDefaultBackgroundColor(const ui::ThemeProvider* theme_provider) {
return color_utils::GetColorWithMaxContrast(
GetDefaultTextColor(theme_provider));
}
} // namespace } // namespace
ToolbarButton::ToolbarButton(views::ButtonListener* listener) ToolbarButton::ToolbarButton(views::ButtonListener* listener)
...@@ -417,8 +412,6 @@ SkColor ToolbarButton::AdjustHighlightColorForContrast( ...@@ -417,8 +412,6 @@ SkColor ToolbarButton::AdjustHighlightColorForContrast(
SkColor desired_light_color, SkColor desired_light_color,
SkColor dark_extreme, SkColor dark_extreme,
SkColor light_extreme) { SkColor light_extreme) {
if (!theme_provider)
return desired_light_color;
const SkColor background_color = GetDefaultBackgroundColor(theme_provider); const SkColor background_color = GetDefaultBackgroundColor(theme_provider);
const SkColor contrasting_color = color_utils::PickContrastingColor( const SkColor contrasting_color = color_utils::PickContrastingColor(
desired_dark_color, desired_light_color, background_color); desired_dark_color, desired_light_color, background_color);
...@@ -439,6 +432,13 @@ SkColor ToolbarButton::AdjustHighlightColorForContrast( ...@@ -439,6 +432,13 @@ SkColor ToolbarButton::AdjustHighlightColorForContrast(
.color; .color;
} }
// static
SkColor ToolbarButton::GetDefaultBackgroundColor(
const ui::ThemeProvider* theme_provider) {
return color_utils::GetColorWithMaxContrast(
GetDefaultTextColor(theme_provider));
}
// static // static
SkColor ToolbarButton::GetDefaultBorderColor(views::View* host_view) { SkColor ToolbarButton::GetDefaultBorderColor(views::View* host_view) {
return SkColorSetA(GetToolbarInkDropBaseColor(host_view), return SkColorSetA(GetToolbarInkDropBaseColor(host_view),
......
...@@ -124,8 +124,10 @@ class ToolbarButton : public views::LabelButton, ...@@ -124,8 +124,10 @@ class ToolbarButton : public views::LabelButton,
SkColor dark_extreme, SkColor dark_extreme,
SkColor light_extreme); SkColor light_extreme);
// Returns the default border color used for toolbar buttons (when having a // Returns the default background and border color used for toolbar buttons
// highlight text, see SetHighlight()). // (when having a highlight text, see SetHighlight()).
static SkColor GetDefaultBackgroundColor(
const ui::ThemeProvider* theme_provider);
static SkColor GetDefaultBorderColor(views::View* host_view); static SkColor GetDefaultBorderColor(views::View* host_view);
protected: protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment