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

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

Issue 2632293002: macOS: Adding tooltip in the profile chooser (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | 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 caac7e85b636c9820ddf40ac024d3837bbee4bf5..e86d6733b42485dd3758fe9c141263ce64a0daff 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
@@ -2146,6 +2146,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
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).
+ profileName.toolTip = base::SysUTF16ToNSString(profileNameString);
msarda 2017/01/17 13:26:44 profileNameString is converted from NSString to UT
jlebel 2017/01/17 13:54:28 Done.
+ }
[profileName
setFrame:NSMakeRect(xOffset, profileNameYOffset, availableTextWidth,
NSHeight([profileName frame]))];
@@ -2162,6 +2168,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
ElideEmail(base::UTF16ToUTF8(item.username), availableTextWidth),
NSZeroPoint, skia::SkColorToSRGBNSColor(SK_ColorGRAY));
[username setFrameOrigin:NSMakePoint(xOffset, NSMaxY([profileName frame]))];
+ if (![[username stringValue]
+ isEqualToString:base::SysUTF16ToNSString(item.username)]) {
+ // Add the tooltip only if the user name is truncated.
+ username.toolTip = base::SysUTF16ToNSString(item.username);
msarda 2017/01/17 13:26:44 base::SysUTF16ToNSString(item.username) is convert
jlebel 2017/01/17 13:54:28 Done.
+ }
[profileCard addSubview:username];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698