Chromium Code Reviews| 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 caac7e85b636c9820ddf40ac024d3837bbee4bf5..6990e183b1b27965bf6d7fd6f1778e3325acdd49 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| @@ -2138,14 +2138,20 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| // Profile name, left-aligned to the right of profile icon. |
| xOffset += kMdImageSide + kHorizontalSpacing; |
| CGFloat fontSize = kTextFontSize + 1.0; |
| - NSTextField* profileName = |
| - BuildLabel(base::SysUTF16ToNSString(profileNameString), NSZeroPoint, nil); |
| + NSString* profileNameNSString = base::SysUTF16ToNSString(profileNameString); |
| + NSTextField* profileName = BuildLabel(profileNameNSString, NSZeroPoint, nil); |
| [[profileName cell] setLineBreakMode:NSLineBreakByTruncatingTail]; |
| [profileName setFont:[NSFont labelFontOfSize:fontSize]]; |
| [profileName sizeToFit]; |
| const int profileNameYOffset = |
| cardYOffset + |
| std::floor((kMdImageSide - NSHeight([profileName frame])) / 2); |
| + if (profileName.frame.size.width > availableTextWidth) { |
| + // Add the tooltip only if the profile name is truncated. This method to |
| + // test if text field is truncated is not ideal (spaces between characters |
| + // can be reduced without truncated). |
|
msarda
2017/01/17 14:01:33
s/can be reduced without truncated/may be reduced
jlebel
2017/01/17 14:16:54
Done.
|
| + profileName.toolTip = profileNameNSString; |
| + } |
| [profileName |
| setFrame:NSMakeRect(xOffset, profileNameYOffset, availableTextWidth, |
| NSHeight([profileName frame]))]; |
| @@ -2158,10 +2164,16 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| cardYOffset += kMdImageSide / 2 - [profileName frame].size.height; |
| [profileName setFrameOrigin:NSMakePoint(xOffset, cardYOffset)]; |
| + NSString* elideEmail = |
|
msarda
2017/01/17 14:01:33
Nit: s/elideEmail/elidedEmail
jlebel
2017/01/17 14:16:54
Done.
|
| + ElideEmail(base::UTF16ToUTF8(item.username), availableTextWidth); |
| NSTextField* username = BuildLabel( |
| - ElideEmail(base::UTF16ToUTF8(item.username), availableTextWidth), |
| - NSZeroPoint, skia::SkColorToSRGBNSColor(SK_ColorGRAY)); |
| + elideEmail, NSZeroPoint, skia::SkColorToSRGBNSColor(SK_ColorGRAY)); |
| [username setFrameOrigin:NSMakePoint(xOffset, NSMaxY([profileName frame]))]; |
| + NSString* usernameNSString = base::SysUTF16ToNSString(item.username); |
| + if (![[username stringValue] isEqualToString:usernameNSString]) { |
| + // Add the tooltip only if the user name is truncated. |
| + username.toolTip = usernameNSString; |
| + } |
| [profileCard addSubview:username]; |
| } |