Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2589)

Unified Diff: chrome/browser/themes/theme_service_win.cc

Issue 2605443002: Ensure UI elements contrast with the right frame color. (Closed)
Patch Set: use optional Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/themes/theme_service_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/themes/theme_service_win.cc
diff --git a/chrome/browser/themes/theme_service_win.cc b/chrome/browser/themes/theme_service_win.cc
index defcb6368baabda0a2c2e3c8fdf53e61935b6692..e556783dfe38adc99cb9f516c45ce5ce253237b5 100644
--- a/chrome/browser/themes/theme_service_win.cc
+++ b/chrome/browser/themes/theme_service_win.cc
@@ -43,12 +43,28 @@ SkColor ThemeServiceWin::GetDefaultColor(int id, bool incognito) const {
if (id == ThemeProperties::COLOR_ACCENT_BORDER)
return dwm_accent_border_color_;
- if (use_dwm_frame_color_) {
- // Incognito frame is the same as normal when we're using DWM colors.
- if (id == ThemeProperties::COLOR_FRAME)
- return dwm_frame_color_;
- if (id == ThemeProperties::COLOR_FRAME_INACTIVE)
- return dwm_inactive_frame_color_;
+ // When we're custom-drawing the titlebar we want to use either the colors
+ // we calculated in OnDwmKeyUpdated() or the default colors. When we're not
+ // custom-drawing the titlebar we want to match the color Windows actually
+ // uses because some things (like the incognito icon) use this color to
+ // decide whether they should draw in light or dark mode. Incognito colors
+ // should be the same as non-incognito in all cases here.
+ if (id == ThemeProperties::COLOR_FRAME) {
+ if (dwm_frame_color_)
+ return dwm_frame_color_.value();
+ if (!ShouldCustomDrawSystemTitlebar())
+ return SK_ColorWHITE;
+ // Fall through and use default.
+ }
+ if (id == ThemeProperties::COLOR_FRAME_INACTIVE) {
+ if (!ShouldCustomDrawSystemTitlebar()) {
+ return inactive_frame_color_from_registry_
+ ? dwm_inactive_frame_color_.value()
+ : SK_ColorWHITE;
+ }
+ if (dwm_inactive_frame_color_)
+ return dwm_inactive_frame_color_.value();
+ // Fall through and use default.
}
}
@@ -62,25 +78,30 @@ bool ThemeServiceWin::DwmColorsAllowed() const {
void ThemeServiceWin::OnDwmKeyUpdated() {
DWORD accent_color, color_prevalence;
- use_dwm_frame_color_ =
+ bool use_dwm_frame_color =
dwm_key_->ReadValueDW(L"AccentColor", &accent_color) == ERROR_SUCCESS &&
dwm_key_->ReadValueDW(L"ColorPrevalence", &color_prevalence) ==
ERROR_SUCCESS &&
color_prevalence == 1;
- if (use_dwm_frame_color_) {
+ inactive_frame_color_from_registry_ = false;
+ if (use_dwm_frame_color) {
dwm_frame_color_ = skia::COLORREFToSkColor(accent_color);
DWORD accent_color_inactive;
if (dwm_key_->ReadValueDW(L"AccentColorInactive", &accent_color_inactive) ==
ERROR_SUCCESS) {
dwm_inactive_frame_color_ =
skia::COLORREFToSkColor(accent_color_inactive);
+ inactive_frame_color_from_registry_ = true;
} else {
// Tint to create inactive color. Always use the non-incognito version of
// the tint, since the frame should look the same in both modes.
dwm_inactive_frame_color_ = color_utils::HSLShift(
- dwm_frame_color_,
+ dwm_frame_color_.value(),
GetTint(ThemeProperties::TINT_FRAME_INACTIVE, false));
}
+ } else {
+ dwm_frame_color_.reset();
+ dwm_inactive_frame_color_.reset();
}
dwm_accent_border_color_ = SK_ColorWHITE;
« no previous file with comments | « chrome/browser/themes/theme_service_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698