OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
6 | 6 |
7 #import <Carbon/Carbon.h> // kVK_Return. | 7 #import <Carbon/Carbon.h> // kVK_Return. |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2139 xOffset += kMdImageSide + kHorizontalSpacing; | 2139 xOffset += kMdImageSide + kHorizontalSpacing; |
2140 CGFloat fontSize = kTextFontSize + 1.0; | 2140 CGFloat fontSize = kTextFontSize + 1.0; |
2141 NSTextField* profileName = | 2141 NSTextField* profileName = |
2142 BuildLabel(base::SysUTF16ToNSString(profileNameString), NSZeroPoint, nil); | 2142 BuildLabel(base::SysUTF16ToNSString(profileNameString), NSZeroPoint, nil); |
2143 [[profileName cell] setLineBreakMode:NSLineBreakByTruncatingTail]; | 2143 [[profileName cell] setLineBreakMode:NSLineBreakByTruncatingTail]; |
2144 [profileName setFont:[NSFont labelFontOfSize:fontSize]]; | 2144 [profileName setFont:[NSFont labelFontOfSize:fontSize]]; |
2145 [profileName sizeToFit]; | 2145 [profileName sizeToFit]; |
2146 const int profileNameYOffset = | 2146 const int profileNameYOffset = |
2147 cardYOffset + | 2147 cardYOffset + |
2148 std::floor((kMdImageSide - NSHeight([profileName frame])) / 2); | 2148 std::floor((kMdImageSide - NSHeight([profileName frame])) / 2); |
2149 if (profileName.frame.size.width > availableTextWidth) { | |
2150 // Add the tooltip only if the profile name is truncated. This method to | |
2151 // test if text field is truncated is not ideal (spaces between characters | |
2152 // can be reduced without truncated). | |
2153 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.
| |
2154 } | |
2149 [profileName | 2155 [profileName |
2150 setFrame:NSMakeRect(xOffset, profileNameYOffset, availableTextWidth, | 2156 setFrame:NSMakeRect(xOffset, profileNameYOffset, availableTextWidth, |
2151 NSHeight([profileName frame]))]; | 2157 NSHeight([profileName frame]))]; |
2152 [profileCard addSubview:profileName]; | 2158 [profileCard addSubview:profileName]; |
2153 | 2159 |
msarda
2017/01/17 13:26:44
Have you tried using the same test as for the user
jlebel
2017/01/17 13:54:28
-[NSTextField stringValue] returns the value given
| |
2154 // Username, left-aligned to the right of profile icon and below the profile | 2160 // Username, left-aligned to the right of profile icon and below the profile |
2155 // name. | 2161 // name. |
2156 if (item.signed_in && !switches::IsEnableAccountConsistency()) { | 2162 if (item.signed_in && !switches::IsEnableAccountConsistency()) { |
2157 // Adjust the y-position of profile name to leave space for username. | 2163 // Adjust the y-position of profile name to leave space for username. |
2158 cardYOffset += kMdImageSide / 2 - [profileName frame].size.height; | 2164 cardYOffset += kMdImageSide / 2 - [profileName frame].size.height; |
2159 [profileName setFrameOrigin:NSMakePoint(xOffset, cardYOffset)]; | 2165 [profileName setFrameOrigin:NSMakePoint(xOffset, cardYOffset)]; |
2160 | 2166 |
2161 NSTextField* username = BuildLabel( | 2167 NSTextField* username = BuildLabel( |
2162 ElideEmail(base::UTF16ToUTF8(item.username), availableTextWidth), | 2168 ElideEmail(base::UTF16ToUTF8(item.username), availableTextWidth), |
2163 NSZeroPoint, skia::SkColorToSRGBNSColor(SK_ColorGRAY)); | 2169 NSZeroPoint, skia::SkColorToSRGBNSColor(SK_ColorGRAY)); |
2164 [username setFrameOrigin:NSMakePoint(xOffset, NSMaxY([profileName frame]))]; | 2170 [username setFrameOrigin:NSMakePoint(xOffset, NSMaxY([profileName frame]))]; |
2171 if (![[username stringValue] | |
2172 isEqualToString:base::SysUTF16ToNSString(item.username)]) { | |
2173 // Add the tooltip only if the user name is truncated. | |
2174 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.
| |
2175 } | |
2165 [profileCard addSubview:username]; | 2176 [profileCard addSubview:username]; |
2166 } | 2177 } |
2167 | 2178 |
2168 yOffset = NSMaxY([profileCard frame]); | 2179 yOffset = NSMaxY([profileCard frame]); |
2169 [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)]; | 2180 [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)]; |
2170 return container.autorelease(); | 2181 return container.autorelease(); |
2171 } | 2182 } |
2172 | 2183 |
2173 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item | 2184 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item |
2174 rect:(NSRect)rect { | 2185 rect:(NSRect)rect { |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2939 } | 2950 } |
2940 | 2951 |
2941 - (bool)shouldShowGoIncognito { | 2952 - (bool)shouldShowGoIncognito { |
2942 bool incognitoAvailable = | 2953 bool incognitoAvailable = |
2943 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2954 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
2944 IncognitoModePrefs::DISABLED; | 2955 IncognitoModePrefs::DISABLED; |
2945 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2956 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
2946 } | 2957 } |
2947 | 2958 |
2948 @end | 2959 @end |
OLD | NEW |