-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit is a squash of 4 commits from #3281. - Fix setting preferred color scheme logic for brave theme change - Fix system dark mode change affect brave theme on Win10 When brave theme is set to dark or light, system dark mode change should not affect brave theme. - CleanUp: Delete SystemThemeSupportDarkMode Upstream added ui::NativeTheme::SystemDarkModeSupported(). Replace ours with upstream one. - Add dark mode change test by modifying reg value for Windows This test can verify whether theme change notification is delivered or not. If brave theme option is not default, system dark theme change should not trigger theme change notificagtion delivery. Chromium change: https://chromium.googlesource.com/chromium/src/+/67fd4d9f35650a079f6a636b5d19de77856bd2cf commit 67fd4d9f35650a079f6a636b5d19de77856bd2cf Author: Alison Maher <almaher@microsoft.com> Date: Fri Jul 12 18:34:21 2019 +0000 Set preferred color scheme for high contrast This change adds logic to update the preferred color scheme based on the OS high contrast theme. If high contrast is not enabled, preferred color scheme will continue to be based on the OS dark mode state. A PreferredColorScheme enum was added to NativeTheme to keep track of the current high contrast/dark mode preferred color scheme. The updated preferred color scheme is used to evaluate the prefers-color-scheme media query. Bug: 970285
- Loading branch information
Showing
16 changed files
with
261 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/themes/brave_theme_utils.h" | ||
|
||
#include "ui/native_theme/native_theme.h" | ||
|
||
namespace internal { | ||
|
||
void SetSystemThemeForNonDarkModePlatform(BraveThemeType type) { | ||
// Call SetDarkMode() first then call ReCalcPreferredColorScheme() because | ||
// ReCalcPreferredColorScheme() calculates preferred color scheme based on dark | ||
// mode. | ||
ui::BraveThemeUtils::SetDarkMode(type == | ||
BraveThemeType::BRAVE_THEME_TYPE_DARK); | ||
ui::BraveThemeUtils::ReCalcAndSetPreferredColorScheme(); | ||
// Have to notify observers explicitly because | ||
// |ui::BraveThemeUtils::SetDarkMode()| and | ||
// |ui::BraveThemeUtils::ReCalcPreferredColorScheme| just set | ||
// ui::NativeTheme:dark_mode_ and ui::NativeTheme:preferred_color_scheme_ | ||
// values. | ||
ui::NativeTheme::GetInstanceForNativeUi()->NotifyObservers(); | ||
ui::NativeTheme::GetInstanceForWeb()->NotifyObservers(); | ||
} | ||
|
||
} // namespace internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_THEMES_BRAVE_THEME_UTILS_INTERNAL_H_ | ||
#define BRAVE_BROWSER_THEMES_BRAVE_THEME_UTILS_INTERNAL_H_ | ||
|
||
#include "brave/browser/themes/brave_theme_service.h" | ||
|
||
namespace internal { | ||
|
||
// Reset dark mode and preferred color scheme and notify. | ||
void SetSystemThemeForNonDarkModePlatform(BraveThemeType type); | ||
|
||
} // namespace internal | ||
|
||
#endif // BRAVE_BROWSER_THEMES_BRAVE_THEME_UTILS_INTERNAL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2019 The Brave Authors | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// you can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#ifndef BRAVE_CHROMIUM_SRC_UI_NATIVE_THEME_NATIVE_THEME_H_ | ||
#define BRAVE_CHROMIUM_SRC_UI_NATIVE_THEME_NATIVE_THEME_H_ | ||
|
||
namespace ui { | ||
class BraveThemeUtils; | ||
} // namespace ui | ||
|
||
#define BRAVE_UI_NATIVE_THEME_NATIVE_THEME_H_ friend class ui::BraveThemeUtils; | ||
#include "../../../../ui/native_theme/native_theme.h" | ||
#undef BRAVE_UI_NATIVE_THEME_NATIVE_THEME_H_ | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_UI_NATIVE_THEME_NATIVE_THEME_H_ |
Oops, something went wrong.