Commit b518fa10 authored by rsesek@chromium.org's avatar rsesek@chromium.org

[Mac][MC] Initial accessibility pass.

This gives all the buttons appropriate roles, AXTitles, and makes accessible
more of the notification content.

BUG=238248
R=dewittj@chromium.org, dmazzoni@chromium.org, thakis@chromium.org

Review URL: https://codereview.chromium.org/17408004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207994 0039d316-1c4b-4281-b951-d872f2087c98
parent 5f6f9bce
...@@ -452,6 +452,9 @@ need to be translated for each locale.--> ...@@ -452,6 +452,9 @@ need to be translated for each locale.-->
<message name="IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL" desc="The button label for visiting the appropriate settings page in the footer of the message center."> <message name="IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL" desc="The button label for visiting the appropriate settings page in the footer of the message center.">
Settings Settings
</message> </message>
<message name="IDS_MESSAGE_CENTER_SETTINGS_GO_BACK_BUTTON_TOOLTIP" desc="The tooltip on back button that returns from settings to the notification list.">
Go back to notifications
</message>
<message name="IDS_MESSAGE_CENTER_SETTINGS_DIALOG_DESCRIPTION" desc="The label to describe the settings dialog."> <message name="IDS_MESSAGE_CENTER_SETTINGS_DIALOG_DESCRIPTION" desc="The label to describe the settings dialog.">
Allow notifications from the following: Allow notifications from the following:
</message> </message>
......
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "grit/ui_resources.h" #include "grit/ui_resources.h"
#include "grit/ui_strings.h"
#include "skia/ext/skia_utils_mac.h" #include "skia/ext/skia_utils_mac.h"
#import "ui/base/cocoa/hover_image_button.h" #import "ui/base/cocoa/hover_image_button.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/text/text_elider.h" #include "ui/base/text/text_elider.h"
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
...@@ -89,6 +91,8 @@ ...@@ -89,6 +91,8 @@
} }
@end @end
////////////////////////////////////////////////////////////////////////////////
@interface MCNotificationView : NSBox { @interface MCNotificationView : NSBox {
@private @private
MCNotificationController* controller_; MCNotificationController* controller_;
...@@ -113,8 +117,37 @@ ...@@ -113,8 +117,37 @@
} }
[controller_ notificationClicked]; [controller_ notificationClicked];
} }
- (BOOL)accessibilityIsIgnored {
return NO;
}
- (NSArray*)accessibilityActionNames {
return @[ NSAccessibilityPressAction ];
}
- (void)accessibilityPerformAction:(NSString*)action {
if ([action isEqualToString:NSAccessibilityPressAction]) {
[controller_ notificationClicked];
return;
}
[super accessibilityPerformAction:action];
}
@end @end
////////////////////////////////////////////////////////////////////////////////
@interface AccessibilityIgnoredBox : NSBox
@end
@implementation AccessibilityIgnoredBox
- (BOOL)accessibilityIsIgnored {
return YES;
}
@end
////////////////////////////////////////////////////////////////////////////////
@interface MCNotificationController (Private) @interface MCNotificationController (Private)
// Returns a string with item's title in title color and item's message in // Returns a string with item's title in title color and item's message in
// message color. // message color.
...@@ -155,6 +188,8 @@ ...@@ -155,6 +188,8 @@
maxNumberOfLines:(size_t)lines; maxNumberOfLines:(size_t)lines;
@end @end
////////////////////////////////////////////////////////////////////////////////
@implementation MCNotificationController @implementation MCNotificationController
- (id)initWithNotification:(const message_center::Notification*)notification - (id)initWithNotification:(const message_center::Notification*)notification
...@@ -252,6 +287,11 @@ ...@@ -252,6 +287,11 @@
listFrame.origin.y = 0; listFrame.origin.y = 0;
listFrame.size.height = 0; listFrame.size.height = 0;
listItemView_.reset([[NSView alloc] initWithFrame:listFrame]); listItemView_.reset([[NSView alloc] initWithFrame:listFrame]);
[listItemView_ accessibilitySetOverrideValue:NSAccessibilityListRole
forAttribute:NSAccessibilityRoleAttribute];
[listItemView_
accessibilitySetOverrideValue:NSAccessibilityContentListSubrole
forAttribute:NSAccessibilitySubroleAttribute];
CGFloat y = 0; CGFloat y = 0;
NSFont* font = [NSFont systemFontOfSize:message_center::kMessageFontSize]; NSFont* font = [NSFont systemFontOfSize:message_center::kMessageFontSize];
...@@ -327,7 +367,7 @@ ...@@ -327,7 +367,7 @@
separatorFrame.origin = NSMakePoint(0, y); separatorFrame.origin = NSMakePoint(0, y);
separatorFrame.size.height = 1; separatorFrame.size.height = 1;
scoped_nsobject<NSBox> separator( scoped_nsobject<NSBox> separator(
[[NSBox alloc] initWithFrame:separatorFrame]); [[AccessibilityIgnoredBox alloc] initWithFrame:separatorFrame]);
[self configureCustomBox:separator]; [self configureCustomBox:separator];
[separator setFillColor:gfx::SkColorToCalibratedNSColor( [separator setFillColor:gfx::SkColorToCalibratedNSColor(
message_center::kButtonSeparatorColor)]; message_center::kButtonSeparatorColor)];
...@@ -441,7 +481,8 @@ ...@@ -441,7 +481,8 @@
NSRect imageFrame = NSMakeRect(0, 0, NSRect imageFrame = NSMakeRect(0, 0,
message_center::kNotificationIconSize, message_center::kNotificationIconSize,
message_center::kNotificationIconSize); message_center::kNotificationIconSize);
scoped_nsobject<NSBox> imageBox([[NSBox alloc] initWithFrame:imageFrame]); scoped_nsobject<NSBox> imageBox(
[[AccessibilityIgnoredBox alloc] initWithFrame:imageFrame]);
[self configureCustomBox:imageBox]; [self configureCustomBox:imageBox];
[imageBox setFillColor:gfx::SkColorToCalibratedNSColor( [imageBox setFillColor:gfx::SkColorToCalibratedNSColor(
message_center::kLegacyIconBackgroundColor)]; message_center::kLegacyIconBackgroundColor)];
...@@ -473,6 +514,13 @@ ...@@ -473,6 +514,13 @@
[closeButton_ setAutoresizingMask:NSViewMinYMargin]; [closeButton_ setAutoresizingMask:NSViewMinYMargin];
[closeButton_ setTarget:self]; [closeButton_ setTarget:self];
[closeButton_ setAction:@selector(close:)]; [closeButton_ setAction:@selector(close:)];
[[closeButton_ cell]
accessibilitySetOverrideValue:NSAccessibilityCloseButtonSubrole
forAttribute:NSAccessibilitySubroleAttribute];
[[closeButton_ cell]
accessibilitySetOverrideValue:
l10n_util::GetNSString(IDS_APP_ACCNAME_CLOSE)
forAttribute:NSAccessibilityTitleAttribute];
} }
- (void)configureTitleInFrame:(NSRect)rootFrame { - (void)configureTitleInFrame:(NSRect)rootFrame {
......
...@@ -150,6 +150,19 @@ const CGFloat kUnreadCountMinY = 4; ...@@ -150,6 +150,19 @@ const CGFloat kUnreadCountMinY = 4;
} }
} }
- (NSArray*)accessibilityActionNames {
return @[ NSAccessibilityPressAction ];
}
- (void)accessibilityPerformAction:(NSString*)action {
if ([action isEqualToString:NSAccessibilityPressAction]) {
if (callback_)
callback_.get()();
return;
}
[super accessibilityPerformAction:action];
}
// Private ///////////////////////////////////////////////////////////////////// // Private /////////////////////////////////////////////////////////////////////
- (BOOL)shouldHighlight { - (BOOL)shouldHighlight {
......
...@@ -294,12 +294,16 @@ const CGFloat kTrayBottomMargin = 75; ...@@ -294,12 +294,16 @@ const CGFloat kTrayBottomMargin = 75;
[backButton_ setHidden:NO]; [backButton_ setHidden:NO];
[clearAllButton_ setEnabled:NO]; [clearAllButton_ setEnabled:NO];
[scrollView_ setHidden:YES];
[[[self view] window] recalculateKeyViewLoop]; [[[self view] window] recalculateKeyViewLoop];
[self updateTrayViewAndWindow]; [self updateTrayViewAndWindow];
} }
- (void)hideSettings:(id)sender { - (void)hideSettings:(id)sender {
[scrollView_ setHidden:NO];
[[settingsController_ view] removeFromSuperview]; [[settingsController_ view] removeFromSuperview];
settingsController_.reset(); settingsController_.reset();
...@@ -413,6 +417,11 @@ const CGFloat kTrayBottomMargin = 75; ...@@ -413,6 +417,11 @@ const CGFloat kTrayBottomMargin = 75;
configureButton(backButton_); configureButton(backButton_);
[backButton_ setHidden:YES]; [backButton_ setHidden:YES];
[backButton_ setKeyEquivalent:@"\e"]; [backButton_ setKeyEquivalent:@"\e"];
[backButton_ setToolTip:l10n_util::GetNSString(
IDS_MESSAGE_CENTER_SETTINGS_GO_BACK_BUTTON_TOOLTIP)];
[[backButton_ cell]
accessibilitySetOverrideValue:[backButton_ toolTip]
forAttribute:NSAccessibilityDescriptionAttribute];
[[self view] addSubview:backButton_]; [[self view] addSubview:backButton_];
// Create the divider line between the control area and the notifications. // Create the divider line between the control area and the notifications.
...@@ -451,6 +460,9 @@ const CGFloat kTrayBottomMargin = 75; ...@@ -451,6 +460,9 @@ const CGFloat kTrayBottomMargin = 75;
rb.GetNativeImageNamed(IDR_NOTIFICATION_SETTINGS_PRESSED).ToNSImage()]; rb.GetNativeImageNamed(IDR_NOTIFICATION_SETTINGS_PRESSED).ToNSImage()];
[settingsButton_ setToolTip: [settingsButton_ setToolTip:
l10n_util::GetNSString(IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL)]; l10n_util::GetNSString(IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL)];
[[settingsButton_ cell]
accessibilitySetOverrideValue:[settingsButton_ toolTip]
forAttribute:NSAccessibilityDescriptionAttribute];
[settingsButton_ setAction:@selector(showSettings:)]; [settingsButton_ setAction:@selector(showSettings:)];
configureButton(settingsButton_); configureButton(settingsButton_);
[view addSubview:settingsButton_]; [view addSubview:settingsButton_];
...@@ -469,6 +481,9 @@ const CGFloat kTrayBottomMargin = 75; ...@@ -469,6 +481,9 @@ const CGFloat kTrayBottomMargin = 75;
rb.GetNativeImageNamed(IDR_NOTIFICATION_CLEAR_ALL_PRESSED).ToNSImage()]; rb.GetNativeImageNamed(IDR_NOTIFICATION_CLEAR_ALL_PRESSED).ToNSImage()];
[clearAllButton_ setToolTip: [clearAllButton_ setToolTip:
l10n_util::GetNSString(IDS_MESSAGE_CENTER_CLEAR_ALL)]; l10n_util::GetNSString(IDS_MESSAGE_CENTER_CLEAR_ALL)];
[[clearAllButton_ cell]
accessibilitySetOverrideValue:[clearAllButton_ toolTip]
forAttribute:NSAccessibilityDescriptionAttribute];
[clearAllButton_ setAction:@selector(clearAllNotifications:)]; [clearAllButton_ setAction:@selector(clearAllNotifications:)];
configureButton(clearAllButton_); configureButton(clearAllButton_);
[view addSubview:clearAllButton_]; [view addSubview:clearAllButton_];
...@@ -486,6 +501,9 @@ const CGFloat kTrayBottomMargin = 75; ...@@ -486,6 +501,9 @@ const CGFloat kTrayBottomMargin = 75;
rb.GetNativeImageNamed(IDR_NOTIFICATION_PAUSE_PRESSED).ToNSImage()]; rb.GetNativeImageNamed(IDR_NOTIFICATION_PAUSE_PRESSED).ToNSImage()];
[pauseButton_ setToolTip: [pauseButton_ setToolTip:
l10n_util::GetNSString(IDS_MESSAGE_CENTER_QUIET_MODE_BUTTON_TOOLTIP)]; l10n_util::GetNSString(IDS_MESSAGE_CENTER_QUIET_MODE_BUTTON_TOOLTIP)];
[[pauseButton_ cell]
accessibilitySetOverrideValue:[pauseButton_ toolTip]
forAttribute:NSAccessibilityDescriptionAttribute];
[pauseButton_ setAction:@selector(toggleQuietMode:)]; [pauseButton_ setAction:@selector(toggleQuietMode:)];
configureButton(pauseButton_); configureButton(pauseButton_);
[view addSubview:pauseButton_]; [view addSubview:pauseButton_];
......
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