Commit 74ac577b authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

a11y: announce hold-to-quit message

Since the hold-to-quit message is delivered by a borderless window,
VoiceOver does not announce its presence; we need to explicitly announce
its message here so screenreader users know why their quit command is
not immediate.

Bug: 957356
Change-Id: I7df32194175decffe8f97a02644d5b7dfc9aba0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1606380
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Auto-Submit: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659044}
parent c7c59059
...@@ -154,6 +154,7 @@ const NSTimeInterval kTimeDeltaFuzzFactor = 1.0; ...@@ -154,6 +154,7 @@ const NSTimeInterval kTimeDeltaFuzzFactor = 1.0;
// Returns the menu item for the Quit menu item, or a thrown-together default // Returns the menu item for the Quit menu item, or a thrown-together default
// one if no Quit menu item exists. // one if no Quit menu item exists.
+ (NSMenuItem*)quitMenuItem; + (NSMenuItem*)quitMenuItem;
- (void)sendAccessibilityAnnouncement;
@end @end
ConfirmQuitPanelController* g_confirmQuitPanelController = nil; ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
...@@ -236,6 +237,13 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil; ...@@ -236,6 +237,13 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
// Show the info panel that explains what the user must to do confirm quit. // Show the info panel that explains what the user must to do confirm quit.
[self showWindow:self]; [self showWindow:self];
// Explicitly announce the hold-to-quit message. For an ordinary modal dialog
// VoiceOver would announce it and read its message, but VoiceOver does not do
// this for windows whose styleMask is NSBorderlessWindowMask, so do it
// manually here. Without this screenreader users have no way to know why
// their quit hotkey seems not to work.
[self sendAccessibilityAnnouncement];
// Spin a nested run loop until the |targetDate| is reached or a KeyUp event // Spin a nested run loop until the |targetDate| is reached or a KeyUp event
// is sent. // is sent.
NSDate* targetDate = [NSDate NSDate* targetDate = [NSDate
...@@ -396,4 +404,16 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil; ...@@ -396,4 +404,16 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
return string; return string;
} }
- (void)sendAccessibilityAnnouncement {
NSString* message = l10n_util::GetNSStringF(
IDS_CONFIRM_TO_QUIT_DESCRIPTION,
base::SysNSStringToUTF16([[self class] keyCommandString]));
NSAccessibilityPostNotificationWithUserInfo(
[NSApp mainWindow], NSAccessibilityAnnouncementRequestedNotification, @{
NSAccessibilityAnnouncementKey : message,
NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh),
});
}
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment