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/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
|
||||
namespace mate {
|
||||
template <>
|
||||
|
@ -636,8 +637,7 @@ void SystemPreferences::RemoveUserDefault(const std::string& name) {
|
|||
|
||||
bool SystemPreferences::IsDarkMode() {
|
||||
if (@available(macOS 10.14, *)) {
|
||||
return [[NSApplication sharedApplication].effectiveAppearance.name
|
||||
isEqualToString:NSAppearanceNameDarkAqua];
|
||||
return ui::NativeTheme::GetInstanceForNativeUi()->SystemDarkModeEnabled();
|
||||
}
|
||||
NSString* mode = [[NSUserDefaults standardUserDefaults]
|
||||
stringForKey:@"AppleInterfaceStyle"];
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "ui/events/cocoa/cocoa_event_utils.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/mac/coordinate_conversion.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -153,8 +154,7 @@ const CGFloat kVerticalTitleMargin = 2;
|
|||
|
||||
- (BOOL)isDarkMode {
|
||||
if (@available(macOS 10.14, *)) {
|
||||
return [[NSApplication sharedApplication].effectiveAppearance.name
|
||||
isEqualToString:NSAppearanceNameDarkAqua];
|
||||
return ui::NativeTheme::GetInstanceForNativeUi()->SystemDarkModeEnabled();
|
||||
}
|
||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString* mode = [defaults stringForKey:@"AppleInterfaceStyle"];
|
||||
|
|
Loading…
Reference in a new issue