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

Side by Side Diff: chrome/browser/ui/views/profiles/new_avatar_button.cc

Issue 287103004: New avatar menu: For supervised users, show "(Supervised)" in the avatar button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add Mac implementation Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" 5 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
6 6
7 #include "base/win/windows_version.h" 7 #include "base/win/windows_version.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/profiles/profiles_state.h" 10 #include "chrome/browser/profiles/profiles_state.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 const int kMaxCharactersToDisplay = 15; 49 const int kMaxCharactersToDisplay = 15;
50 50
51 const gfx::FontList font_list; 51 const gfx::FontList font_list;
52 return gfx::ElideText( 52 return gfx::ElideText(
53 original_text, 53 original_text,
54 font_list, 54 font_list,
55 font_list.GetExpectedTextWidth(kMaxCharactersToDisplay), 55 font_list.GetExpectedTextWidth(kMaxCharactersToDisplay),
56 gfx::ELIDE_AT_END); 56 gfx::ELIDE_AT_END);
57 } 57 }
58 58
59 base::string16 GetButtonText(Profile* profile) {
msw 2014/05/27 17:16:41 nit: could this and GetElidedText be shared cross-
Marc Treib 2014/05/28 11:04:05 At the moment, the GetElidedText implementations b
msw 2014/05/28 20:13:24 You can land as-is and cleanup later if needed. Co
60 base::string16 name = GetElidedText(
61 profiles::GetAvatarNameForProfile(profile));
62 if (profile->IsManaged())
63 name = l10n_util::GetStringFUTF16(IDS_MANAGED_USER_NEW_AVATAR_LABEL, name);
64 return name;
65 }
66
59 } // namespace 67 } // namespace
60 68
61 NewAvatarButton::NewAvatarButton( 69 NewAvatarButton::NewAvatarButton(
62 views::ButtonListener* listener, 70 views::ButtonListener* listener,
63 const base::string16& profile_name, 71 const base::string16& profile_name,
64 AvatarButtonStyle button_style, 72 AvatarButtonStyle button_style,
65 Browser* browser) 73 Browser* browser)
66 : MenuButton(listener, GetElidedText(profile_name), NULL, true), 74 : MenuButton(listener, GetButtonText(browser->profile()), NULL, true),
67 browser_(browser) { 75 browser_(browser) {
68 set_animate_on_state_change(false); 76 set_animate_on_state_change(false);
69 set_icon_placement(ICON_ON_RIGHT); 77 set_icon_placement(ICON_ON_RIGHT);
70 78
71 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 79 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
72 80
73 bool is_win8 = false; 81 bool is_win8 = false;
74 #if defined(OS_WIN) 82 #if defined(OS_WIN)
75 is_win8 = base::win::GetVersion() >= base::win::VERSION_WIN8; 83 is_win8 = base::win::GetVersion() >= base::win::VERSION_WIN8;
76 #endif 84 #endif
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 174 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
167 icon = *rb->GetImageNamed(IDR_WARNING).ToImageSkia(); 175 icon = *rb->GetImageNamed(IDR_WARNING).ToImageSkia();
168 } 176 }
169 177
170 SetIcon(icon); 178 SetIcon(icon);
171 UpdateAvatarButtonAndRelayoutParent(); 179 UpdateAvatarButtonAndRelayoutParent();
172 } 180 }
173 181
174 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() { 182 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() {
175 // We want the button to resize if the new text is shorter. 183 // We want the button to resize if the new text is shorter.
176 SetText(GetElidedText( 184 SetText(GetButtonText(browser_->profile()));
177 profiles::GetAvatarNameForProfile(browser_->profile())));
178 ClearMaxTextSize(); 185 ClearMaxTextSize();
179 186
180 // Because the width of the button might have changed, the parent browser 187 // Because the width of the button might have changed, the parent browser
181 // frame needs to recalculate the button bounds and redraw it. 188 // frame needs to recalculate the button bounds and redraw it.
182 if (parent()) 189 if (parent())
183 parent()->Layout(); 190 parent()->Layout();
184 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698