Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: ui/message_center/cocoa/notification_controller.mm

Issue 17408004: [Mac][MC] Initial accessibility pass. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Title -> Description Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/strings/ui_strings.grd ('k') | ui/message_center/cocoa/status_item_view.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/cocoa/notification_controller.mm
diff --git a/ui/message_center/cocoa/notification_controller.mm b/ui/message_center/cocoa/notification_controller.mm
index f599381d5753cc6c3d41b58cba6c6953293cea60..87b4a8f4c5b2690e33caaf1f125a72edc2e1c943 100644
--- a/ui/message_center/cocoa/notification_controller.mm
+++ b/ui/message_center/cocoa/notification_controller.mm
@@ -9,8 +9,10 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "grit/ui_resources.h"
+#include "grit/ui_strings.h"
#include "skia/ext/skia_utils_mac.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/text/text_elider.h"
#include "ui/message_center/message_center.h"
@@ -89,6 +91,8 @@
}
@end
+////////////////////////////////////////////////////////////////////////////////
+
@interface MCNotificationView : NSBox {
@private
MCNotificationController* controller_;
@@ -113,8 +117,37 @@
}
[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
+////////////////////////////////////////////////////////////////////////////////
+
+@interface AccessibilityIgnoredBox : NSBox
+@end
+
+@implementation AccessibilityIgnoredBox
+- (BOOL)accessibilityIsIgnored {
+ return YES;
+}
+@end
+
+////////////////////////////////////////////////////////////////////////////////
+
@interface MCNotificationController (Private)
// Returns a string with item's title in title color and item's message in
// message color.
@@ -155,6 +188,8 @@
maxNumberOfLines:(size_t)lines;
@end
+////////////////////////////////////////////////////////////////////////////////
+
@implementation MCNotificationController
- (id)initWithNotification:(const message_center::Notification*)notification
@@ -252,6 +287,11 @@
listFrame.origin.y = 0;
listFrame.size.height = 0;
listItemView_.reset([[NSView alloc] initWithFrame:listFrame]);
+ [listItemView_ accessibilitySetOverrideValue:NSAccessibilityListRole
+ forAttribute:NSAccessibilityRoleAttribute];
+ [listItemView_
+ accessibilitySetOverrideValue:NSAccessibilityContentListSubrole
+ forAttribute:NSAccessibilitySubroleAttribute];
CGFloat y = 0;
NSFont* font = [NSFont systemFontOfSize:message_center::kMessageFontSize];
@@ -327,7 +367,7 @@
separatorFrame.origin = NSMakePoint(0, y);
separatorFrame.size.height = 1;
scoped_nsobject<NSBox> separator(
- [[NSBox alloc] initWithFrame:separatorFrame]);
+ [[AccessibilityIgnoredBox alloc] initWithFrame:separatorFrame]);
[self configureCustomBox:separator];
[separator setFillColor:gfx::SkColorToCalibratedNSColor(
message_center::kButtonSeparatorColor)];
@@ -441,7 +481,8 @@
NSRect imageFrame = NSMakeRect(0, 0,
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];
[imageBox setFillColor:gfx::SkColorToCalibratedNSColor(
message_center::kLegacyIconBackgroundColor)];
@@ -473,6 +514,13 @@
[closeButton_ setAutoresizingMask:NSViewMinYMargin];
[closeButton_ setTarget:self];
[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 {
« no previous file with comments | « ui/base/strings/ui_strings.grd ('k') | ui/message_center/cocoa/status_item_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698