0d16be9560
* feat: add nativeTheme.shouldUseDarkColorsOverride to allow apps to override Chromiums theme choice * spec: add tests for shouldUseDarkColorsOverride * chore: add missing forward declarations * refactor: rename overrideShouldUseDarkColors to themeSource * chore: only run appLevelAppearance specs on Mojave and up * chore: update patch with more info and no define * Update spec-main/api-native-theme-spec.ts Co-Authored-By: Jeremy Apthorp <jeremya@chromium.org> * Update api-native-theme-spec.ts * Update api-native-theme-spec.ts * Update api-native-theme-spec.ts
37 lines
1.1 KiB
Text
37 lines
1.1 KiB
Text
// 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/common/api/atom_api_native_theme.h"
|
|
|
|
#include "base/mac/sdk_forward_declarations.h"
|
|
#include "shell/browser/mac/atom_application.h"
|
|
|
|
namespace electron {
|
|
|
|
namespace api {
|
|
|
|
void NativeTheme::UpdateMacOSAppearanceForOverrideValue(
|
|
ui::NativeTheme::ThemeSource override) {
|
|
if (@available(macOS 10.14, *)) {
|
|
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 api
|
|
|
|
} // namespace electron
|