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

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

Issue 2541873004: Change default frame colors. Change custom titlebar colors on Windows. (Closed)
Patch Set: Created 4 years 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
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 322a55a87330c88311720bdae1ee93c00c0cdce4..ad8dd677be2ae72a91fa81a79630d3e956ebce7a 100644
--- a/chrome/browser/themes/theme_service_win.cc
+++ b/chrome/browser/themes/theme_service_win.cc
@@ -15,7 +15,7 @@
#include "ui/gfx/geometry/safe_integer_conversions.h"
ThemeServiceWin::ThemeServiceWin() {
- // This just checks for Windows 10 instead of calling ShouldUseDwmFrameColor()
+ // This just checks for Windows 10 instead of calling DwmColorsAllowed()
// because we want to monitor the frame color even when a custom frame is in
// use, so that it will be correct if at any time the user switches to the
// native frame.
@@ -39,37 +39,47 @@ bool ThemeServiceWin::ShouldUseNativeFrame() const {
}
SkColor ThemeServiceWin::GetDefaultColor(int id, bool incognito) const {
- if (ShouldUseDwmFrameColor()) {
- // Active native windows on Windows 10 may have a custom frame color.
- if (id == ThemeProperties::COLOR_FRAME)
- return dwm_frame_color_;
-
+ if (DwmColorsAllowed()) {
if (id == ThemeProperties::COLOR_ACCENT_BORDER)
return dwm_accent_border_color_;
- // Inactive native windows on Windows 10 always have a white frame.
- if (id == ThemeProperties::COLOR_FRAME_INACTIVE)
- return SK_ColorWHITE;
+ 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_;
+ }
}
return ThemeService::GetDefaultColor(id, incognito);
}
-bool ThemeServiceWin::ShouldUseDwmFrameColor() const {
+bool ThemeServiceWin::DwmColorsAllowed() const {
return ShouldUseNativeFrame() &&
(base::win::GetVersion() >= base::win::VERSION_WIN10);
}
void ThemeServiceWin::OnDwmKeyUpdated() {
- // Attempt to read the accent color.
DWORD accent_color, color_prevalence;
- dwm_frame_color_ =
- ((dwm_key_->ReadValueDW(L"ColorPrevalence", &color_prevalence) ==
- ERROR_SUCCESS) &&
- (color_prevalence == 1) &&
- (dwm_key_->ReadValueDW(L"AccentColor", &accent_color) == ERROR_SUCCESS))
- ? skia::COLORREFToSkColor(accent_color)
- : SK_ColorWHITE;
+ 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_) {
+ 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);
+ } else {
+ // 20% active color/80% white blend to create the inactive color.
+ dwm_inactive_frame_color_ =
+ color_utils::AlphaBlend(dwm_frame_color_, SK_ColorWHITE, 0x33);
Peter Kasting 2016/12/01 06:19:04 Nit: If you wint up preserving this, consider shif
Bret 2016/12/08 00:16:07 Done.
+ }
+ }
dwm_accent_border_color_ = SK_ColorWHITE;
DWORD colorization_color, colorization_color_balance;

Powered by Google App Engine
This is Rietveld 408576698