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

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

Issue 381953002: New avatar button: Consolidate text elision between Mac and Win/Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
Index: chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm b/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm
index 16f070355c5c0832d36fe6c5f7946eff9577caec..e7ec7476639cbe2ffd64167a35704938b70137f2 100644
--- a/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm
@@ -30,7 +30,6 @@ const CGFloat kButtonPadding = 12;
const CGFloat kButtonDefaultPadding = 5;
const CGFloat kButtonHeight = 27;
const CGFloat kButtonTitleImageSpacing = 10;
-const CGFloat kMaxButtonContentWidth = 100;
const ui::NinePartImageIds kNormalBorderImageIds =
IMAGE_GRID(IDR_AVATAR_MAC_BUTTON_NORMAL);
@@ -221,12 +220,11 @@ NSImage* GetImageFromResourceID(int resourceId) {
}
}
-- (base::string16)getElidedAvatarName {
- base::string16 name = profiles::GetAvatarNameForProfile(
- browser_->profile()->GetPath());
- int maxTextWidth = kMaxButtonContentWidth - [[button_ image] size].width;
- return gfx::ElideText(name, gfx::FontList(gfx::Font([button_ font])),
- maxTextWidth, gfx::ELIDE_TAIL);
+- (NSString*)getButtonText {
+ const gfx::FontList font_list = gfx::FontList(gfx::Font([button_ font]));
+ base::string16 name =
+ profiles::GetAvatarButtonTextForProfile(browser_->profile(), font_list);
+ return base::SysUTF16ToNSString(name);
}
- (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent {
@@ -249,16 +247,7 @@ NSImage* GetImageFromResourceID(int resourceId) {
[shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.4]];
}
- base::string16 profileName = [self getElidedAvatarName];
- NSString* buttonTitle = nil;
- if (browser_->profile()->IsSupervised()) {
- // Add the "supervised" label after eliding the profile name, so the label
- // will not get elided, but will instead enlarge the button.
- buttonTitle = l10n_util::GetNSStringF(IDS_SUPERVISED_USER_NEW_AVATAR_LABEL,
- profileName);
- } else {
- buttonTitle = base::SysUTF16ToNSString(profileName);
- }
+ NSString* buttonTitle = [self getButtonText];
base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
[[NSMutableParagraphStyle alloc] init]);

Powered by Google App Engine
This is Rietveld 408576698