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

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: use TruncateString 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..dfaa8d16bc64c6a9ded9418a87f72fa018865f25 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,9 @@ 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 {
+ return base::SysUTF16ToNSString(
msw 2014/07/17 17:18:35 nit: maybe inline this below.
Marc Treib 2014/07/18 10:05:09 Done.
+ profiles::GetAvatarButtonTextForProfile(browser_->profile()));
}
- (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent {
@@ -249,16 +245,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