OLD | NEW |
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 Loading... |
49 const int kMaxCharactersToDisplay = 15; | 49 const int kMaxCharactersToDisplay = 15; |
50 const gfx::FontList font_list; | 50 const gfx::FontList font_list; |
51 return gfx::ElideText(original_text, font_list, | 51 return gfx::ElideText(original_text, font_list, |
52 font_list.GetExpectedTextWidth(kMaxCharactersToDisplay), | 52 font_list.GetExpectedTextWidth(kMaxCharactersToDisplay), |
53 gfx::ELIDE_TAIL); | 53 gfx::ELIDE_TAIL); |
54 } | 54 } |
55 | 55 |
56 base::string16 GetButtonText(Profile* profile) { | 56 base::string16 GetButtonText(Profile* profile) { |
57 base::string16 name = GetElidedText( | 57 base::string16 name = GetElidedText( |
58 profiles::GetAvatarNameForProfile(profile)); | 58 profiles::GetAvatarNameForProfile(profile)); |
59 if (profile->IsManaged()) | 59 if (profile->IsSupervised()) |
60 name = l10n_util::GetStringFUTF16(IDS_MANAGED_USER_NEW_AVATAR_LABEL, name); | 60 name = l10n_util::GetStringFUTF16(IDS_MANAGED_USER_NEW_AVATAR_LABEL, name); |
61 return name; | 61 return name; |
62 } | 62 } |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 NewAvatarButton::NewAvatarButton( | 66 NewAvatarButton::NewAvatarButton( |
67 views::ButtonListener* listener, | 67 views::ButtonListener* listener, |
68 const base::string16& profile_name, | 68 const base::string16& profile_name, |
69 AvatarButtonStyle button_style, | 69 AvatarButtonStyle button_style, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() { | 180 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() { |
181 // We want the button to resize if the new text is shorter. | 181 // We want the button to resize if the new text is shorter. |
182 SetText(GetButtonText(browser_->profile())); | 182 SetText(GetButtonText(browser_->profile())); |
183 ClearMaxTextSize(); | 183 ClearMaxTextSize(); |
184 | 184 |
185 // Because the width of the button might have changed, the parent browser | 185 // Because the width of the button might have changed, the parent browser |
186 // frame needs to recalculate the button bounds and redraw it. | 186 // frame needs to recalculate the button bounds and redraw it. |
187 if (parent()) | 187 if (parent()) |
188 parent()->Layout(); | 188 parent()->Layout(); |
189 } | 189 } |
OLD | NEW |