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

Unified Diff: chrome/browser/profiles/profiles_state.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: 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/profiles/profiles_state.cc
diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc
index de95755b0e49b796d67dac8b0e3bba556636f33f..13c6c08571dbb7ee1de0b6d6203dfe5e9b6a493c 100644
--- a/chrome/browser/profiles/profiles_state.cc
+++ b/chrome/browser/profiles/profiles_state.cc
@@ -22,6 +22,8 @@
#include "components/signin/core/common/profile_management_switches.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/gfx/font_list.h"
+#include "ui/gfx/text_elider.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/users/user_manager.h"
@@ -81,6 +83,20 @@ base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path) {
return display_name;
}
+base::string16 GetAvatarButtonTextForProfile(Profile* profile,
+ const gfx::FontList& font_list) {
+ const int kMaxCharactersToDisplay = 15;
noms (inactive) 2014/07/11 13:21:57 I think msw had suggested we use a max size, and n
msw 2014/07/11 22:17:06 My goal is to remove the explicit call to ElideTex
+ base::string16 name = GetAvatarNameForProfile(profile->GetPath());
+ name = gfx::ElideText(name,
+ font_list,
+ font_list.GetExpectedTextWidth(kMaxCharactersToDisplay),
msw 2014/07/16 16:58:28 Could you use gfx::TruncateString instead, since y
Marc Treib 2014/07/17 08:43:00 Well, that depends on what exactly the intended be
+ gfx::ELIDE_TAIL);
+ if (profile->IsSupervised())
+ name = l10n_util::GetStringFUTF16(IDS_SUPERVISED_USER_NEW_AVATAR_LABEL,
+ name);
+ return name;
+}
+
void UpdateProfileName(Profile* profile,
const base::string16& new_profile_name) {
PrefService* pref_service = profile->GetPrefs();
« no previous file with comments | « chrome/browser/profiles/profiles_state.h ('k') | chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698