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

Side by Side Diff: chrome/browser/themes/theme_service_win.cc

Issue 1771933002: Revert of Monitor the system native frame color on Win 10. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/themes/theme_service_win.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/themes/theme_service_win.h"
6
7 #include "base/bind.h"
8 #include "base/win/windows_version.h"
9 #include "chrome/browser/themes/theme_properties.h"
10 #include "grit/theme_resources.h"
11 #include "skia/ext/skia_utils_win.h"
12 #include "ui/base/win/shell.h"
13
14 ThemeServiceWin::ThemeServiceWin() {
15 // This just checks for Windows 10 instead of calling ShouldUseDwmFrameColor()
16 // because we want to monitor the frame color even when a custom frame is in
17 // use, so that it will be correct if at any time the user switches to the
18 // native frame.
19 if (base::win::GetVersion() >= base::win::VERSION_WIN10) {
20 dwm_key_.reset(new base::win::RegKey(
21 HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\DWM", KEY_READ));
22 OnDwmKeyUpdated();
23 }
24 }
25
26 ThemeServiceWin::~ThemeServiceWin() {
27 }
28
29 bool ThemeServiceWin::ShouldUseNativeFrame() const {
30 return !HasCustomImage(IDR_THEME_FRAME) && ui::win::IsAeroGlassEnabled();
31 }
32
33 SkColor ThemeServiceWin::GetDefaultColor(int id, bool incognito) const {
34 if (ShouldUseDwmFrameColor()) {
35 // Active native windows on Windows 10 may have a custom frame color.
36 if (id == ThemeProperties::COLOR_FRAME)
37 return dwm_frame_color_;
38
39 // Inactive native windows on Windows 10 always have a white frame.
40 if (id == ThemeProperties::COLOR_FRAME_INACTIVE)
41 return SK_ColorWHITE;
42 }
43
44 return ThemeService::GetDefaultColor(id, incognito);
45 }
46
47 bool ThemeServiceWin::ShouldUseDwmFrameColor() const {
48 return ShouldUseNativeFrame() &&
49 (base::win::GetVersion() >= base::win::VERSION_WIN10);
50 }
51
52 void ThemeServiceWin::OnDwmKeyUpdated() {
53 // Attempt to read the accent color.
54 DWORD accent_color, color_prevalence;
55 dwm_frame_color_ =
56 ((dwm_key_->ReadValueDW(L"ColorPrevalence", &color_prevalence) ==
57 ERROR_SUCCESS) &&
58 (color_prevalence == 1) &&
59 (dwm_key_->ReadValueDW(L"AccentColor", &accent_color) == ERROR_SUCCESS))
60 ? skia::COLORREFToSkColor(accent_color)
61 : SK_ColorWHITE;
62
63 // Watch for future changes.
64 if (!dwm_key_->StartWatching(base::Bind(
65 &ThemeServiceWin::OnDwmKeyUpdated, base::Unretained(this))))
66 dwm_key_.reset();
67 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service_win.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698