diff --git a/docs/api/native-theme.md b/docs/api/native-theme.md index e6bdd6c80606..7860c870307b 100644 --- a/docs/api/native-theme.md +++ b/docs/api/native-theme.md @@ -63,6 +63,14 @@ Your application should then always use `shouldUseDarkColors` to determine what A `boolean` for if the OS / Chromium currently has high-contrast mode enabled or is being instructed to show a high-contrast UI. +### `nativeTheme.shouldUseDarkColorsForSystemIntegratedUI` _macOS_ _Windows_ _Readonly_ + +A `boolean` property indicating whether or not the system theme has been set to dark or light. + +On Windows this property distinguishes between system and app light/dark theme, returning +`true` if the system theme is set to dark theme and `false` otherwise. On macOS the return +value will be the same as `nativeTheme.shouldUseDarkColors`. + ### `nativeTheme.shouldUseInvertedColorScheme` _macOS_ _Windows_ _Readonly_ A `boolean` for if the OS / Chromium currently has an inverted color scheme diff --git a/shell/browser/api/electron_api_native_theme.cc b/shell/browser/api/electron_api_native_theme.cc index a86481e4d67a..01e470c227c2 100644 --- a/shell/browser/api/electron_api_native_theme.cc +++ b/shell/browser/api/electron_api_native_theme.cc @@ -63,6 +63,10 @@ bool NativeTheme::ShouldUseHighContrastColors() { return ui_theme_->UserHasContrastPreference(); } +bool NativeTheme::ShouldUseDarkColorsForSystemIntegratedUI() { + return ui_theme_->ShouldUseDarkColorsForSystemIntegratedUI(); +} + bool NativeTheme::InForcedColorsMode() { return ui_theme_->InForcedColorsMode(); } @@ -109,6 +113,8 @@ gin::ObjectTemplateBuilder NativeTheme::GetObjectTemplateBuilder( &NativeTheme::SetThemeSource) .SetProperty("shouldUseHighContrastColors", &NativeTheme::ShouldUseHighContrastColors) + .SetProperty("shouldUseDarkColorsForSystemIntegratedUI", + &NativeTheme::ShouldUseDarkColorsForSystemIntegratedUI) .SetProperty("shouldUseInvertedColorScheme", &NativeTheme::ShouldUseInvertedColorScheme) .SetProperty("inForcedColorsMode", &NativeTheme::InForcedColorsMode) diff --git a/shell/browser/api/electron_api_native_theme.h b/shell/browser/api/electron_api_native_theme.h index d94f148ec531..86cc3412d385 100644 --- a/shell/browser/api/electron_api_native_theme.h +++ b/shell/browser/api/electron_api_native_theme.h @@ -48,6 +48,7 @@ class NativeTheme final : public gin::Wrappable, ui::NativeTheme::ThemeSource GetThemeSource() const; bool ShouldUseDarkColors(); bool ShouldUseHighContrastColors(); + bool ShouldUseDarkColorsForSystemIntegratedUI(); bool ShouldUseInvertedColorScheme(); bool InForcedColorsMode(); bool GetPrefersReducedTransparency(); diff --git a/spec/api-native-theme-spec.ts b/spec/api-native-theme-spec.ts index 2d2a3a3b00d6..d68caf06fb81 100644 --- a/spec/api-native-theme-spec.ts +++ b/spec/api-native-theme-spec.ts @@ -102,6 +102,12 @@ describe('nativeTheme module', () => { }); }); + describe('nativeTheme.shouldUseDarkColorsForSystemIntegratedUI', () => { + it('returns a boolean', () => { + expect(nativeTheme.shouldUseDarkColorsForSystemIntegratedUI).to.be.a('boolean'); + }); + }); + describe('nativeTheme.inForcedColorsMode', () => { it('returns a boolean', () => { expect(nativeTheme.inForcedColorsMode).to.be.a('boolean');