refactor: use NativeTheme dark mode detection on macOS 10.14+
This commit is contained in:
parent
70857e9a5d
commit
b57e623c11
2 changed files with 4 additions and 4 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include "shell/browser/ui/cocoa/NSColor+Hex.h"
|
#include "shell/browser/ui/cocoa/NSColor+Hex.h"
|
||||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||||
#include "shell/common/native_mate_converters/value_converter.h"
|
#include "shell/common/native_mate_converters/value_converter.h"
|
||||||
|
#include "ui/native_theme/native_theme.h"
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
template <>
|
template <>
|
||||||
|
@ -636,8 +637,7 @@ void SystemPreferences::RemoveUserDefault(const std::string& name) {
|
||||||
|
|
||||||
bool SystemPreferences::IsDarkMode() {
|
bool SystemPreferences::IsDarkMode() {
|
||||||
if (@available(macOS 10.14, *)) {
|
if (@available(macOS 10.14, *)) {
|
||||||
return [[NSApplication sharedApplication].effectiveAppearance.name
|
return ui::NativeTheme::GetInstanceForNativeUi()->SystemDarkModeEnabled();
|
||||||
isEqualToString:NSAppearanceNameDarkAqua];
|
|
||||||
}
|
}
|
||||||
NSString* mode = [[NSUserDefaults standardUserDefaults]
|
NSString* mode = [[NSUserDefaults standardUserDefaults]
|
||||||
stringForKey:@"AppleInterfaceStyle"];
|
stringForKey:@"AppleInterfaceStyle"];
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "ui/events/cocoa/cocoa_event_utils.h"
|
#include "ui/events/cocoa/cocoa_event_utils.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
#include "ui/gfx/mac/coordinate_conversion.h"
|
#include "ui/gfx/mac/coordinate_conversion.h"
|
||||||
|
#include "ui/native_theme/native_theme.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -153,8 +154,7 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
|
|
||||||
- (BOOL)isDarkMode {
|
- (BOOL)isDarkMode {
|
||||||
if (@available(macOS 10.14, *)) {
|
if (@available(macOS 10.14, *)) {
|
||||||
return [[NSApplication sharedApplication].effectiveAppearance.name
|
return ui::NativeTheme::GetInstanceForNativeUi()->SystemDarkModeEnabled();
|
||||||
isEqualToString:NSAppearanceNameDarkAqua];
|
|
||||||
}
|
}
|
||||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||||
NSString* mode = [defaults stringForKey:@"AppleInterfaceStyle"];
|
NSString* mode = [defaults stringForKey:@"AppleInterfaceStyle"];
|
||||||
|
|
Loading…
Reference in a new issue