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

Unified Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 471703002: [Mac] Add accessibility features to the new avatar menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a bunch of rebase mishaps >_< Created 6 years, 4 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 | « chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
index 4a8b03442b2746f06f7a76856450d117dd339318..ca2c61f70345a0f6522fbc31667362e14b720663 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
@@ -486,6 +486,32 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
// Hide the button until the image is hovered over.
[changePhotoButton_ setHidden:YES];
}
+
+ // Set the image cell's accessibility strings to be the same as the
+ // button's strings.
+ [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSString(
+ editingAllowed ?
+ IDS_PROFILES_NEW_AVATAR_MENU_CHANGE_PHOTO_ACCESSIBLE_NAME :
+ IDS_PROFILES_NEW_AVATAR_MENU_PHOTO_ACCESSIBLE_NAME)
+ forAttribute:NSAccessibilityTitleAttribute];
+ [[self cell] accessibilitySetOverrideValue:
+ editingAllowed ? NSAccessibilityButtonRole : NSAccessibilityImageRole
+ forAttribute:NSAccessibilityRoleAttribute];
+ [[self cell] accessibilitySetOverrideValue:
+ NSAccessibilityRoleDescription(NSAccessibilityButtonRole, nil)
+ forAttribute:NSAccessibilityRoleDescriptionAttribute];
+
+ // The button and the cell should read the same thing.
+ [self accessibilitySetOverrideValue:l10n_util::GetNSString(
+ editingAllowed ?
+ IDS_PROFILES_NEW_AVATAR_MENU_CHANGE_PHOTO_ACCESSIBLE_NAME :
+ IDS_PROFILES_NEW_AVATAR_MENU_PHOTO_ACCESSIBLE_NAME)
+ forAttribute:NSAccessibilityTitleAttribute];
+ [self accessibilitySetOverrideValue:NSAccessibilityButtonRole
+ forAttribute:NSAccessibilityRoleAttribute];
+ [self accessibilitySetOverrideValue:
+ NSAccessibilityRoleDescription(NSAccessibilityButtonRole, nil)
+ forAttribute:NSAccessibilityRoleDescriptionAttribute];
}
return self;
}
@@ -517,6 +543,28 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[changePhotoButton_ setHidden:YES];
}
+// Make sure the element is focusable for accessibility.
+- (BOOL)canBecomeKeyView {
+ return YES;
+}
+
+- (BOOL)accessibilityIsIgnored {
+ return NO;
+}
+
+- (NSArray*)accessibilityActionNames {
+ NSArray* parentActions = [super accessibilityActionNames];
+ return [parentActions arrayByAddingObject:NSAccessibilityPressAction];
+}
+
+- (void)accessibilityPerformAction:(NSString*)action {
+ if ([action isEqualToString:NSAccessibilityPressAction]) {
+ avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex());
+ }
+
+ [super accessibilityPerformAction:action];
+}
+
- (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect {
TransparentBackgroundButton* button =
[[TransparentBackgroundButton alloc] initWithFrame:rect];
@@ -609,6 +657,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[profileNameTextField_ setHidden:YES];
}
+ [[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole
+ forAttribute:NSAccessibilityRoleAttribute];
+ [[self cell] accessibilitySetOverrideValue:
+ NSAccessibilityRoleDescription(NSAccessibilityButtonRole, nil)
+ forAttribute:NSAccessibilityRoleDescriptionAttribute];
+
[self setBordered:NO];
[self setFont:[NSFont labelFontOfSize:kTitleFontSize]];
[self setAlignment:NSCenterTextAlignment];
@@ -994,6 +1048,13 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
viewMode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
}
+ [window accessibilitySetOverrideValue:
+ l10n_util::GetNSString(IDS_PROFILES_NEW_AVATAR_MENU_ACCESSIBLE_NAME)
+ forAttribute:NSAccessibilityTitleAttribute];
+ [window accessibilitySetOverrideValue:
+ l10n_util::GetNSString(IDS_PROFILES_NEW_AVATAR_MENU_ACCESSIBLE_NAME)
+ forAttribute:NSAccessibilityHelpAttribute];
+
[[self bubble] setAlignment:info_bubble::kAlignRightEdgeToAnchorEdge];
[[self bubble] setArrowLocation:info_bubble::kNoArrow];
[[self bubble] setBackgroundColor:GetDialogBackgroundColor()];
@@ -1409,6 +1470,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[link setTarget:self];
[link setAction:@selector(showAccountReauthenticationView:)];
[link setTag:kPrimaryProfileTag];
+ [[link cell]
+ accessibilitySetOverrideValue:l10n_util::GetNSStringF(
+ IDS_PROFILES_ACCOUNT_BUTTON_AUTH_ERROR_ACCESSIBLE_NAME,
+ item.sync_state)
+ forAttribute:NSAccessibilityTitleAttribute];
} else {
[link setEnabled:NO];
}
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698