Chromium Code Reviews| 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 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2131 setImage:NSImageFromImageSkia(gfx::CreateVectorIcon( | 2131 setImage:NSImageFromImageSkia(gfx::CreateVectorIcon( |
| 2132 badgeIcon, badgeIconSize, gfx::kChromeIconGrey))]; | 2132 badgeIcon, badgeIconSize, gfx::kChromeIconGrey))]; |
| 2133 [badgeIconWithCircle addSubview:badgeIconView]; | 2133 [badgeIconWithCircle addSubview:badgeIconView]; |
| 2134 | 2134 |
| 2135 [profileCard addSubview:badgeIconWithCircle]; | 2135 [profileCard addSubview:badgeIconWithCircle]; |
| 2136 } | 2136 } |
| 2137 | 2137 |
| 2138 // Profile name, left-aligned to the right of profile icon. | 2138 // Profile name, left-aligned to the right of profile icon. |
| 2139 xOffset += kMdImageSide + kHorizontalSpacing; | 2139 xOffset += kMdImageSide + kHorizontalSpacing; |
| 2140 CGFloat fontSize = kTextFontSize + 1.0; | 2140 CGFloat fontSize = kTextFontSize + 1.0; |
| 2141 NSTextField* profileName = | 2141 NSString* profileNameNSString = base::SysUTF16ToNSString(profileNameString); |
| 2142 BuildLabel(base::SysUTF16ToNSString(profileNameString), NSZeroPoint, nil); | 2142 NSTextField* profileName = BuildLabel(profileNameNSString, 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). | |
|
msarda
2017/01/17 14:01:33
s/can be reduced without truncated/may be reduced
jlebel
2017/01/17 14:16:54
Done.
| |
| 2153 profileName.toolTip = profileNameNSString; | |
| 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 |
| 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 |
| 2167 NSString* elideEmail = | |
|
msarda
2017/01/17 14:01:33
Nit: s/elideEmail/elidedEmail
jlebel
2017/01/17 14:16:54
Done.
| |
| 2168 ElideEmail(base::UTF16ToUTF8(item.username), availableTextWidth); | |
| 2161 NSTextField* username = BuildLabel( | 2169 NSTextField* username = BuildLabel( |
| 2162 ElideEmail(base::UTF16ToUTF8(item.username), availableTextWidth), | 2170 elideEmail, NSZeroPoint, skia::SkColorToSRGBNSColor(SK_ColorGRAY)); |
| 2163 NSZeroPoint, skia::SkColorToSRGBNSColor(SK_ColorGRAY)); | |
| 2164 [username setFrameOrigin:NSMakePoint(xOffset, NSMaxY([profileName frame]))]; | 2171 [username setFrameOrigin:NSMakePoint(xOffset, NSMaxY([profileName frame]))]; |
| 2172 NSString* usernameNSString = base::SysUTF16ToNSString(item.username); | |
| 2173 if (![[username stringValue] isEqualToString:usernameNSString]) { | |
| 2174 // Add the tooltip only if the user name is truncated. | |
| 2175 username.toolTip = usernameNSString; | |
| 2176 } | |
| 2165 [profileCard addSubview:username]; | 2177 [profileCard addSubview:username]; |
| 2166 } | 2178 } |
| 2167 | 2179 |
| 2168 yOffset = NSMaxY([profileCard frame]); | 2180 yOffset = NSMaxY([profileCard frame]); |
| 2169 [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)]; | 2181 [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)]; |
| 2170 return container.autorelease(); | 2182 return container.autorelease(); |
| 2171 } | 2183 } |
| 2172 | 2184 |
| 2173 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item | 2185 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item |
| 2174 rect:(NSRect)rect { | 2186 rect:(NSRect)rect { |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2939 } | 2951 } |
| 2940 | 2952 |
| 2941 - (bool)shouldShowGoIncognito { | 2953 - (bool)shouldShowGoIncognito { |
| 2942 bool incognitoAvailable = | 2954 bool incognitoAvailable = |
| 2943 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2955 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2944 IncognitoModePrefs::DISABLED; | 2956 IncognitoModePrefs::DISABLED; |
| 2945 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2957 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
| 2946 } | 2958 } |
| 2947 | 2959 |
| 2948 @end | 2960 @end |
| OLD | NEW |