diff --git a/atom/browser/api/atom_api_system_preferences.cc b/atom/browser/api/atom_api_system_preferences.cc index acc3ba2d55bc..c02ada914417 100644 --- a/atom/browser/api/atom_api_system_preferences.cc +++ b/atom/browser/api/atom_api_system_preferences.cc @@ -89,6 +89,8 @@ void SystemPreferences::BuildPrototype( &SystemPreferences::GetAppLevelAppearance) .SetMethod("setAppLevelAppearance", &SystemPreferences::SetAppLevelAppearance) + .SetMethod("isTrustedAccessibilityClient", + &SystemPreferences::IsTrustedAccessibilityClient) .SetMethod("getMediaAccessStatus", &SystemPreferences::GetMediaAccessStatus) .SetMethod("askForMediaAccess", &SystemPreferences::AskForMediaAccess) diff --git a/atom/browser/api/atom_api_system_preferences.h b/atom/browser/api/atom_api_system_preferences.h index b83d6574da7c..4ec4e2e682be 100644 --- a/atom/browser/api/atom_api_system_preferences.h +++ b/atom/browser/api/atom_api_system_preferences.h @@ -92,6 +92,8 @@ class SystemPreferences : public mate::EventEmitter void RemoveUserDefault(const std::string& name); bool IsSwipeTrackingFromScrollEventsEnabled(); + bool IsTrustedAccessibilityClient(bool prompt); + // TODO(codebytere): Write tests for these methods once we // are running tests on a Mojave machine std::string GetMediaAccessStatus(const std::string& media_type, diff --git a/atom/browser/api/atom_api_system_preferences_mac.mm b/atom/browser/api/atom_api_system_preferences_mac.mm index 25dbc61ec6af..505944fa1a25 100644 --- a/atom/browser/api/atom_api_system_preferences_mac.mm +++ b/atom/browser/api/atom_api_system_preferences_mac.mm @@ -378,6 +378,11 @@ void SystemPreferences::SetUserDefault(const std::string& name, } } +bool SystemPreferences::IsTrustedAccessibilityClient(bool prompt) { + NSDictionary* options = @{(id)kAXTrustedCheckOptionPrompt : @(prompt)}; + return AXIsProcessTrustedWithOptions((CFDictionaryRef)options); +} + std::string SystemPreferences::GetMediaAccessStatus( const std::string& media_type, mate::Arguments* args) { diff --git a/docs/api/system-preferences.md b/docs/api/system-preferences.md index 51558ccc4aca..5b70f0e4fe24 100644 --- a/docs/api/system-preferences.md +++ b/docs/api/system-preferences.md @@ -327,6 +327,12 @@ You can use the `setAppLevelAppearance` API to set this value. Sets the appearance setting for your application, this should override the system default and override the value of `getEffectiveAppearance`. +### `systemPreferences.isTrustedAccessibilityClient(prompt)` _macOS_ + +* `prompt` Boolean - whether or not the user will be informed via prompt if the current process is untrusted. + +Returns `Boolean` - `true` if the current process is a trusted accessibility client and `false` if it is not. + ### `systemPreferences.getMediaAccessStatus(mediaType)` _macOS_ * `mediaType` String - `microphone` or `camera`.