Commit ff571471 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Simplified logic for GetFrameColor() in BrowserNonClientView

Simplified GetFrameColor() logic to a single GetColor() call to the
browser frame's ThemeProvider.

GetFrameThemeProvider() will return the app's ThemeProvider if
the AppBrowserController is present. The AppBrowserController's
ThemeProvider will query the AppBrowserController's ThemeSupplier
first as part of its GetColor() method before falling back to the
default.

The effect of this is that the desired GetColor() functionality can
be simplified down to the single call.

Bug: 1056916
Change-Id: I44cfc977c4fb651732a02f5badc688c621889da7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2091940
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748883}
parent df1f6dae
...@@ -144,26 +144,10 @@ SkColor BrowserNonClientFrameView::GetCaptionColor( ...@@ -144,26 +144,10 @@ SkColor BrowserNonClientFrameView::GetCaptionColor(
SkColor BrowserNonClientFrameView::GetFrameColor( SkColor BrowserNonClientFrameView::GetFrameColor(
BrowserFrameActiveState active_state) const { BrowserFrameActiveState active_state) const {
ThemeProperties::OverwritableByUserThemeProperty color_id; return GetFrameThemeProvider()->GetColor(
ShouldPaintAsActive(active_state)
color_id = ShouldPaintAsActive(active_state) ? ThemeProperties::COLOR_FRAME
? ThemeProperties::COLOR_FRAME : ThemeProperties::COLOR_FRAME_INACTIVE);
: ThemeProperties::COLOR_FRAME_INACTIVE;
if (frame_->ShouldUseTheme())
return GetFrameThemeProvider()->GetColor(color_id);
// Use ThemeSupplier.
web_app::AppBrowserController* app_controller =
browser_view_->browser()->app_controller();
if (app_controller && app_controller->GetThemeSupplier()) {
CustomThemeSupplier* theme = app_controller->GetThemeSupplier();
SkColor result;
if (theme->GetColor(color_id, &result))
return result;
}
return GetUnthemedColor(color_id);
} }
void BrowserNonClientFrameView::UpdateFrameColor() { void BrowserNonClientFrameView::UpdateFrameColor() {
...@@ -180,8 +164,8 @@ SkColor BrowserNonClientFrameView::GetToolbarTopSeparatorColor() const { ...@@ -180,8 +164,8 @@ SkColor BrowserNonClientFrameView::GetToolbarTopSeparatorColor() const {
: ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR_INACTIVE; : ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR_INACTIVE;
// The vertical tab separator might show through the stroke if the stroke // The vertical tab separator might show through the stroke if the stroke
// color is translucent. To prevent this, always use an opaque stroke color. // color is translucent. To prevent this, always use an opaque stroke color.
return color_utils::GetResultingPaintColor(GetThemeOrDefaultColor(color_id), return color_utils::GetResultingPaintColor(
GetFrameColor()); GetFrameThemeProvider()->GetColor(color_id), GetFrameColor());
} }
base::Optional<int> BrowserNonClientFrameView::GetCustomBackgroundId( base::Optional<int> BrowserNonClientFrameView::GetCustomBackgroundId(
...@@ -398,21 +382,3 @@ const ui::ThemeProvider* BrowserNonClientFrameView::GetFrameThemeProvider() ...@@ -398,21 +382,3 @@ const ui::ThemeProvider* BrowserNonClientFrameView::GetFrameThemeProvider()
// into the view hierarchy. // into the view hierarchy.
return frame_->GetThemeProvider(); return frame_->GetThemeProvider();
} }
SkColor BrowserNonClientFrameView::GetThemeOrDefaultColor(int color_id) const {
if (!frame_->ShouldUseTheme())
return GetUnthemedColor(color_id);
// During shutdown, there may no longer be a widget, and thus no theme
// provider.
const auto* theme_provider = GetThemeProvider();
return theme_provider ? theme_provider->GetColor(color_id)
: gfx::kPlaceholderColor;
}
SkColor BrowserNonClientFrameView::GetUnthemedColor(int color_id) const {
DCHECK(!frame_->ShouldUseTheme());
return ThemeProperties::GetDefaultColor(
color_id, browser_view_->IsIncognito(),
GetNativeTheme()->ShouldUseDarkColors());
}
...@@ -181,13 +181,6 @@ class BrowserNonClientFrameView : public views::NonClientFrameView, ...@@ -181,13 +181,6 @@ class BrowserNonClientFrameView : public views::NonClientFrameView,
// we're added to the view hierarchy. // we're added to the view hierarchy.
const ui::ThemeProvider* GetFrameThemeProvider() const; const ui::ThemeProvider* GetFrameThemeProvider() const;
// Returns the color of the given |color_id| from the theme provider or the
// default theme properties.
SkColor GetThemeOrDefaultColor(int color_id) const;
// Returns the color of the given |color_id| for an un-themed frame.
SkColor GetUnthemedColor(int color_id) const;
// The frame that hosts this view. // The frame that hosts this view.
BrowserFrame* frame_; BrowserFrame* frame_;
......
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