[mac] Dynamically enable accessibility based on VoiceOver status

This commit is contained in:
Theo Julienne 2015-04-12 10:44:27 -07:00
parent 159e013ce5
commit ddfd2bc4be
2 changed files with 39 additions and 10 deletions

View file

@ -8,6 +8,8 @@
#include "base/strings/sys_string_conversions.h"
#include "atom/browser/browser.h"
#include "content/public/browser/browser_accessibility_state.h"
@implementation AtomApplication
+ (AtomApplication*)sharedApplication {
@ -46,4 +48,23 @@
atom::Browser::Get()->OpenURL(base::SysNSStringToUTF8(url));
}
- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute {
// undocumented attribute that VoiceOver happens to set while running.
// Chromium uses this too, even though it's not exactly right.
if ([attribute isEqualToString:@"AXEnhancedUserInterface"]) {
[self updateAccessibilityEnabled:[value boolValue]];
}
return [super accessibilitySetValue:value forAttribute:attribute];
}
- (void)updateAccessibilityEnabled:(BOOL)enabled {
content::BrowserAccessibilityState *ax_state = content::BrowserAccessibilityState::GetInstance();
if (enabled) {
ax_state->OnScreenReaderDetected();
} else {
ax_state->DisableAccessibility();
}
}
@end