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 a060e297211c1d1e00ae8ecc09048f89d0981a96..6285c4562ffd120fd462bc287ecd9997f45e9651 100644 |
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
@@ -455,6 +455,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// When hovering away from the profile photo, hide the "Change" button. |
- (void)mouseExited:(NSEvent*)event; |
+ |
+- (BOOL)acceptsFirstResponder; |
+- (BOOL)canBecomeKeyView; |
+- (BOOL)accessibilityIsIgnored; |
+- (NSArray*)accessibilityActionNames; |
+- (void)accessibilityPerformAction:(NSString*)action; |
groby-ooo-7-16
2014/08/15 00:38:35
No need to declare any of them - they're all imple
noms (inactive)
2014/08/15 19:26:47
Argh, sorry. I never know when to declare and when
groby-ooo-7-16
2014/08/15 19:52:07
This is one of the few places ObjC pretends to not
|
@end |
@interface EditableProfilePhoto (Private) |
@@ -490,6 +496,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; |
} |
@@ -521,6 +553,32 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
[changePhotoButton_ setHidden:YES]; |
} |
+// Make sure the element is focusable for accessibility. |
+- (BOOL)canBecomeKeyView { |
+ return YES; |
+} |
+ |
+- (BOOL)acceptsFirstResponder { |
+ 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]; |
@@ -553,6 +611,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// Called when enter is pressed in the text field. |
- (void)saveProfileName:(id)sender; |
+- (BOOL)acceptsFirstResponder; |
+ |
@end |
@implementation EditableProfileNameButton |
@@ -613,6 +673,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]; |
@@ -639,6 +705,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
[[self window] makeFirstResponder:profileNameTextField_]; |
} |
+- (BOOL)acceptsFirstResponder { |
groby-ooo-7-16
2014/08/15 00:38:35
Technically, a control's -acceptsFirstResponder is
noms (inactive)
2014/08/15 19:26:47
No. I think I just hoped these would make regular
|
+ return YES; |
+} |
+ |
@end |
// A custom button that allows for setting a background color when hovered over. |
@@ -686,6 +756,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
[[self cell] setBackgroundColor:backgroundColor]; |
} |
+- (BOOL)acceptsFirstResponder { |
+ return YES; |
+} |
+ |
@end |
// A custom view with the given background color. |
@@ -982,6 +1056,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()]; |
@@ -1394,6 +1475,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 { |
NSTextField* label = BuildLabel(email, rect.origin, nil); |
[label setAlignment:NSCenterTextAlignment]; |