diff --git a/docs/api/native-theme.md b/docs/api/native-theme.md index 3235eba9a78d..e6bdd6c80606 100644 --- a/docs/api/native-theme.md +++ b/docs/api/native-theme.md @@ -72,3 +72,7 @@ or is being instructed to use an inverted color scheme. A `boolean` indicating whether Chromium is in forced colors mode, controlled by system accessibility settings. Currently, Windows high contrast is the only system setting that triggers forced colors mode. + +### `nativeTheme.prefersReducedTransparency` _Readonly_ + +A `boolean` that indicates the whether the user has chosen via system accessibility settings to reduce transparency at the OS level. diff --git a/shell/browser/api/electron_api_native_theme.cc b/shell/browser/api/electron_api_native_theme.cc index 413983e214f1..32958bf99f0e 100644 --- a/shell/browser/api/electron_api_native_theme.cc +++ b/shell/browser/api/electron_api_native_theme.cc @@ -68,6 +68,10 @@ bool NativeTheme::InForcedColorsMode() { return ui_theme_->InForcedColorsMode(); } +bool NativeTheme::GetPrefersReducedTransparency() { + return ui_theme_->GetPrefersReducedTransparency(); +} + #if BUILDFLAG(IS_MAC) const CFStringRef WhiteOnBlack = CFSTR("whiteOnBlack"); const CFStringRef UniversalAccessDomain = CFSTR("com.apple.universalaccess"); @@ -108,7 +112,9 @@ gin::ObjectTemplateBuilder NativeTheme::GetObjectTemplateBuilder( &NativeTheme::ShouldUseHighContrastColors) .SetProperty("shouldUseInvertedColorScheme", &NativeTheme::ShouldUseInvertedColorScheme) - .SetProperty("inForcedColorsMode", &NativeTheme::InForcedColorsMode); + .SetProperty("inForcedColorsMode", &NativeTheme::InForcedColorsMode) + .SetProperty("prefersReducedTransparency", + &NativeTheme::GetPrefersReducedTransparency); } const char* NativeTheme::GetTypeName() { diff --git a/shell/browser/api/electron_api_native_theme.h b/shell/browser/api/electron_api_native_theme.h index 6be9c008e03b..ecf5edbb929f 100644 --- a/shell/browser/api/electron_api_native_theme.h +++ b/shell/browser/api/electron_api_native_theme.h @@ -46,6 +46,7 @@ class NativeTheme : public gin::Wrappable, bool ShouldUseHighContrastColors(); bool ShouldUseInvertedColorScheme(); bool InForcedColorsMode(); + bool GetPrefersReducedTransparency(); // ui::NativeThemeObserver: void OnNativeThemeUpdated(ui::NativeTheme* theme) override; diff --git a/spec/api-native-theme-spec.ts b/spec/api-native-theme-spec.ts index 70bf2f0a02a1..a6abb6762cc9 100644 --- a/spec/api-native-theme-spec.ts +++ b/spec/api-native-theme-spec.ts @@ -105,4 +105,10 @@ describe('nativeTheme module', () => { expect(nativeTheme.inForcedColorsMode).to.be.a('boolean'); }); }); + + describe('nativeTheme.prefersReducesTransparency', () => { + it('returns a boolean', () => { + expect(nativeTheme.prefersReducedTransparency).to.be.a('boolean'); + }); + }); });