Skip to content

Commit

Permalink
[Mac][MD User Menu] Fixed the accessibility string of profile button
Browse files Browse the repository at this point in the history
The new profile card button needs an accessibility string since it has
no label. The string would be "Edit person, <profile name>" or "Edit
person, <profile name>, <email>" for signed in profiles. See first bug.

Tested with VoiceOver.

BUG=619725
BUG=615893

Review-Url: https://codereview.chromium.org/2268353003
Cr-Commit-Position: refs/heads/master@{#413965}
  • Loading branch information
janeliulwq authored and Commit bot committed Aug 24, 2016
1 parent 6e60851 commit d7356a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
6 changes: 6 additions & 0 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -10851,6 +10851,12 @@ I don't think this site should be blocked!
Manage People
</message>
</if>
<message name="IDS_PROFILES_EDIT_PROFILE_ACCESSIBLE_NAME" desc="Description of the Edit Profile button. This is used for accessibility.">
Edit person, <ph name="PROFILE_NAME">$1<ex>Jane Doe</ex></ph>
</message>
<message name="IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME" desc="Description of the Edit Profile button for a signed-in profile. This is used for accessibility.">
Edit person, <ph name="PROFILE_NAME">$1<ex>Jane Doe</ex></ph>, <ph name="USERNAME">$2<ex>jane.doe@gmail.com</ex></ph>
</message>
<message name="IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME" desc="Description of the switch to profile button. This is used for accessibility.">
Switch to user: <ph name="PROFILE_NAME">$1<ex>First user</ex></ph>
</message>
Expand Down
22 changes: 18 additions & 4 deletions chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,8 @@ - (NSView*)createMaterialDesignCurrentProfileView:
}

// Profile card button that contains the profile icon, name, and username.
const base::string16 profileNameString =
profiles::GetAvatarNameForProfile(browser_->profile()->GetPath());
NSRect rect = NSMakeRect(0, yOffset, GetFixedMenuWidth(),
kMdImageSide + kVerticalSpacing);
NSButton* profileCard =
Expand All @@ -2080,6 +2082,20 @@ - (NSView*)createMaterialDesignCurrentProfileView:
profiles::SHAPE_CIRCLE)
action:@selector(editProfile:)];
[[profileCard cell] setImageDimsWhenDisabled:NO];
if (item.signed_in) {
[[profileCard cell]
accessibilitySetOverrideValue:
l10n_util::GetNSStringF(
IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME,
profileNameString, item.username)
forAttribute:NSAccessibilityTitleAttribute];
} else {
[[profileCard cell]
accessibilitySetOverrideValue:
l10n_util::GetNSStringF(IDS_PROFILES_EDIT_PROFILE_ACCESSIBLE_NAME,
profileNameString)
forAttribute:NSAccessibilityTitleAttribute];
}
[container addSubview:profileCard];
if (isGuestSession_)
[profileCard setEnabled:NO];
Expand Down Expand Up @@ -2117,10 +2133,8 @@ - (NSView*)createMaterialDesignCurrentProfileView:
// Profile name, left-aligned to the right of profile icon.
xOffset += kMdImageSide + kHorizontalSpacing;
CGFloat fontSize = kTextFontSize + 1.0;
NSTextField* profileName = BuildLabel(
base::SysUTF16ToNSString(
profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())),
NSZeroPoint, nil);
NSTextField* profileName =
BuildLabel(base::SysUTF16ToNSString(profileNameString), NSZeroPoint, nil);
[[profileName cell] setLineBreakMode:NSLineBreakByTruncatingTail];
[profileName setFont:[NSFont labelFontOfSize:fontSize]];
[profileName sizeToFit];
Expand Down

0 comments on commit d7356a6

Please sign in to comment.