Commit 5afcb514 authored by bsep's avatar bsep Committed by Commit bot

Change default frame colors. Change custom titlebar colors on Windows.

Default frame colors are changed so that inactive frames are always a
blend of 80% white/20% active color to increase contrast.
* The normal/inactive frame is changed to #F6F6F6 on all platforms. (OSX
  was already at this color.)
* The incognito/inactive frame is changed to #D4D5D5 on all platforms
  except OSX.
* The tints applied to theme images are changed to match the new
  lightness ratio as well. Inactive tint is changed to 80% lightness.
  Incognito/inactive is changed to be 74% lightness, which approximates
  blending 80% white on top of the active tint's 30% black. Also
  increased saturation change of incognito/inactive to match
  incognito/active.

Windows will now pick up the user colors specified by the system and use
them when custom drawing the titlebar. It will never draw the titlebar
white unless the user explicitly specifies that color. It uses an 80%
white/20% active blend to calculate inactive frame colors if the user
has no frame color specified, just like above.

BUG=505013,645682

Review-Url: https://codereview.chromium.org/2541873004
Cr-Commit-Position: refs/heads/master@{#439030}
parent d02702a7
......@@ -48,7 +48,7 @@ namespace {
// theme packs that aren't int-equal to this. Increment this number if you
// change default theme assets or if you need themes to recreate their generated
// images (which are cached).
const int kThemePackVersion = 44;
const int kThemePackVersion = 45;
// IDs that are in the DataPack won't clash with the positive integer
// uint16_t. kHeaderID should always have the maximum value because we want the
......
......@@ -24,22 +24,14 @@ namespace {
// browser_theme_pack.cc.
const SkColor kDefaultColorFrame = SkColorSetRGB(0xCC, 0xCC, 0xCC);
#if defined(OS_MACOSX)
// Used for theme fallback colors.
const SkColor kDefaultColorFrameInactive = SkColorSetRGB(0xF6, 0xF6, 0xF6);
#else
const SkColor kDefaultColorFrameInactive = SkColorSetRGB(0xDC, 0xDC, 0xDC);
#endif
#if defined(OS_MACOSX)
const SkColor kDefaultColorFrameIncognito =
SkColorSetARGB(0xE6, 0x14, 0x16, 0x18);
const SkColor kDefaultColorFrameIncognitoInactive =
const SkColor kDefaultColorFrameIncognitoInactiveMac =
SkColorSetRGB(0x1E, 0x1E, 0x1E);
#else
const SkColor kDefaultColorFrameIncognito = SkColorSetRGB(0x28, 0x2B, 0x2D);
const SkColor kDefaultColorFrameIncognitoInactive =
SkColorSetRGB(0x38, 0x3B, 0x3D);
#endif
const SkColor kDefaultColorToolbar = SkColorSetRGB(0xF2, 0xF2, 0xF2);
......@@ -83,9 +75,9 @@ constexpr SkColor kDefaultColorButtonBackground = SK_ColorTRANSPARENT;
constexpr color_utils::HSL kDefaultTintButtons = {-1, -1, -1};
constexpr color_utils::HSL kDefaultTintButtonsIncognito = {-1, -1, 0.85};
constexpr color_utils::HSL kDefaultTintFrame = {-1, -1, -1};
constexpr color_utils::HSL kDefaultTintFrameInactive = {-1, -1, 0.75};
constexpr color_utils::HSL kDefaultTintFrameInactive = {-1, -1, 0.9};
constexpr color_utils::HSL kDefaultTintFrameIncognito = {-1, 0.2, 0.35};
constexpr color_utils::HSL kDefaultTintFrameIncognitoInactive = {-1, 0.3, 0.6};
constexpr color_utils::HSL kDefaultTintFrameIncognitoInactive = {-1, 0.2, 0.87};
constexpr color_utils::HSL kDefaultTintBackgroundTab = {-1, -1, 0.75};
// ----------------------------------------------------------------------------
......@@ -236,8 +228,13 @@ SkColor ThemeProperties::GetDefaultColor(int id, bool otr) {
case COLOR_FRAME:
return otr ? kDefaultColorFrameIncognito : kDefaultColorFrame;
case COLOR_FRAME_INACTIVE:
return otr ? kDefaultColorFrameIncognitoInactive
: kDefaultColorFrameInactive;
#if defined(OS_MACOSX)
if (otr)
return kDefaultColorFrameIncognitoInactiveMac;
#endif
return color_utils::HSLShift(
GetDefaultColor(ThemeProperties::COLOR_FRAME, otr),
GetDefaultTint(ThemeProperties::TINT_FRAME_INACTIVE, false));
case COLOR_TOOLBAR:
return otr ? kDefaultColorToolbarIncognito : kDefaultColorToolbar;
case COLOR_TAB_TEXT:
......
......@@ -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,49 @@ 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 {
// 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_,
GetTint(ThemeProperties::TINT_FRAME_INACTIVE, false));
}
}
dwm_accent_border_color_ = SK_ColorWHITE;
DWORD colorization_color, colorization_color_balance;
......
......@@ -8,6 +8,9 @@
#include "base/win/registry.h"
#include "chrome/browser/themes/theme_service.h"
// Tracks updates to the native colors on Windows 10 and calcuates the values we
// should use (which are not always what Windows uses). None of the values here
// are relevant to earlier versions of Windows.
class ThemeServiceWin : public ThemeService {
public:
ThemeServiceWin();
......@@ -18,21 +21,28 @@ class ThemeServiceWin : public ThemeService {
bool ShouldUseNativeFrame() const override;
SkColor GetDefaultColor(int id, bool incognito) const override;
// Returns true if the window frame color is determined by the DWM, i.e. this
// is a native frame on Windows 10.
bool ShouldUseDwmFrameColor() const;
// Returns true if colors from DWM can be used, i.e. this is a native frame
// on Windows 10.
bool DwmColorsAllowed() const;
// Callback executed when |dwm_key_| is updated. This re-reads the active
// frame color and updates |dwm_frame_color_|.
// Callback executed when |dwm_key_| is updated. This re-reads the active
// frame color and updates |use_dwm_frame_color_|, |dwm_frame_color_| and
// |dwm_inactive_frame_color_|.
void OnDwmKeyUpdated();
// Registry key containing the params that determine the DWM frame color.
// This is only initialized on Windows 10.
std::unique_ptr<base::win::RegKey> dwm_key_;
// The DWM frame color, if available; white otherwise.
// True if the frame should be colored using the DWM values here. False if the
// default frame colors should be used instead.
bool use_dwm_frame_color_;
// The frame color when active.
SkColor dwm_frame_color_;
// The frame color when inactive.
SkColor dwm_inactive_frame_color_;
// The DWM accent border color, if available; white otherwise.
SkColor dwm_accent_border_color_;
......
......@@ -555,7 +555,10 @@ bool GlassBrowserFrameView::ShowSystemIcon() const {
}
SkColor GlassBrowserFrameView::GetTitlebarColor() const {
return GetThemeProvider()->GetColor(ThemeProperties::COLOR_FRAME);
const ui::ThemeProvider* tp = GetThemeProvider();
return ShouldPaintAsActive()
? tp->GetColor(ThemeProperties::COLOR_FRAME)
: tp->GetColor(ThemeProperties::COLOR_FRAME_INACTIVE);
}
Windows10CaptionButton* GlassBrowserFrameView::CreateCaptionButton(
......
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