mirror of https://github.com/electron/electron
34 lines
1.0 KiB
Plaintext
34 lines
1.0 KiB
Plaintext
// Copyright (c) 2019 Slack Technologies, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "shell/browser/api/electron_api_native_theme.h"
|
|
|
|
#include "shell/browser/mac/electron_application.h"
|
|
|
|
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
|
#error "This file requires ARC support."
|
|
#endif
|
|
|
|
namespace electron::api {
|
|
|
|
void NativeTheme::UpdateMacOSAppearanceForOverrideValue(
|
|
ui::NativeTheme::ThemeSource override) {
|
|
NSAppearance* new_appearance;
|
|
switch (override) {
|
|
case ui::NativeTheme::ThemeSource::kForcedDark:
|
|
new_appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
|
|
break;
|
|
case ui::NativeTheme::ThemeSource::kForcedLight:
|
|
new_appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
|
|
break;
|
|
case ui::NativeTheme::ThemeSource::kSystem:
|
|
default:
|
|
new_appearance = nil;
|
|
break;
|
|
}
|
|
[[NSApplication sharedApplication] setAppearance:new_appearance];
|
|
}
|
|
|
|
} // namespace electron::api
|