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

Unified Diff: chrome/browser/ui/views/profiles/new_avatar_button.cc

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/views/profiles/new_avatar_button.cc
diff --git a/chrome/browser/ui/views/profiles/new_avatar_button.cc b/chrome/browser/ui/views/profiles/new_avatar_button.cc
index a39991a46825c42f38cf4b31337d4b047a8865e5..aeb99f83e6964125c9dabcaa14762de17016f0a8 100644
--- a/chrome/browser/ui/views/profiles/new_avatar_button.cc
+++ b/chrome/browser/ui/views/profiles/new_avatar_button.cc
@@ -48,24 +48,6 @@ scoped_ptr<views::Border> CreateBorder(const int normal_image_set[],
return border.PassAs<views::Border>();
}
-base::string16 GetElidedText(const base::string16& original_text) {
- // Maximum characters the button can be before the text will get elided.
- const int kMaxCharactersToDisplay = 15;
- const gfx::FontList font_list;
- return gfx::ElideText(original_text, font_list,
- font_list.GetExpectedTextWidth(kMaxCharactersToDisplay),
- gfx::ELIDE_TAIL);
-}
-
-base::string16 GetButtonText(Profile* profile) {
- base::string16 name = GetElidedText(profiles::GetAvatarNameForProfile(
- profile->GetPath()));
- if (profile->IsSupervised())
- name = l10n_util::GetStringFUTF16(IDS_SUPERVISED_USER_NEW_AVATAR_LABEL,
- name);
- return name;
-}
-
} // namespace
NewAvatarButton::NewAvatarButton(
@@ -73,7 +55,10 @@ NewAvatarButton::NewAvatarButton(
const base::string16& profile_name,
AvatarButtonStyle button_style,
Browser* browser)
- : MenuButton(listener, GetButtonText(browser->profile()), NULL, true),
+ : MenuButton(listener,
+ profiles::GetAvatarButtonTextForProfile(browser->profile()),
+ NULL,
+ true),
browser_(browser) {
set_animate_on_state_change(false);
SetTextColor(views::Button::STATE_NORMAL, SK_ColorWHITE);
@@ -173,7 +158,7 @@ void NewAvatarButton::OnErrorChanged() {
void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() {
// We want the button to resize if the new text is shorter.
- SetText(GetButtonText(browser_->profile()));
+ SetText(profiles::GetAvatarButtonTextForProfile(browser_->profile()));
set_min_size(gfx::Size());
InvalidateLayout();

Powered by Google App Engine
This is Rietveld 408576698