Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle AXManualAccessibility attribute cross-protocol #38224

Merged
merged 1 commit into from
May 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions shell/browser/mac/electron_application.mm
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,33 @@ - (void)handleURLEvent:(NSAppleEventDescriptor*)event
electron::Browser::Get()->OpenURL(base::SysNSStringToUTF8(url));
}

// Returns the list of accessibility attributes that this object supports.
- (NSArray*)accessibilityAttributeNames {
NSMutableArray* attributes =
[[super accessibilityAttributeNames] mutableCopy];
[attributes addObject:@"AXManualAccessibility"];
return attributes;
}

// Returns whether or not the specified attribute can be set by the
// accessibility API via |accessibilitySetValue:forAttribute:|.
- (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute {
bool is_manual_ax = [attribute isEqualToString:@"AXManualAccessibility"];
return is_manual_ax || [super accessibilityIsAttributeSettable:attribute];
}

// Returns the accessibility value for the given attribute. If the value isn't
// supported this will return nil.
- (id)accessibilityAttributeValue:(NSString*)attribute {
if ([attribute isEqualToString:@"AXManualAccessibility"]) {
auto* ax_state = content::BrowserAccessibilityState::GetInstance();
return [NSNumber numberWithBool:ax_state->IsAccessibleBrowser()];
}

return [super accessibilityAttributeValue:attribute];
}

// Sets the value for an accessibility attribute via the accessibility API.
// AXEnhancedUserInterface is an undocumented attribute that screen reader
// related functionality sets when running, and AXManualAccessibility is an
// attribute Electron specifically allows third-party apps to use to enable
Expand Down