| 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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/win/windows_version.h" | 8 #include "base/win/windows_version.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 const gfx::FontList font_list; | 54 const gfx::FontList font_list; |
| 55 return gfx::ElideText(original_text, font_list, | 55 return gfx::ElideText(original_text, font_list, |
| 56 font_list.GetExpectedTextWidth(kMaxCharactersToDisplay), | 56 font_list.GetExpectedTextWidth(kMaxCharactersToDisplay), |
| 57 gfx::ELIDE_TAIL); | 57 gfx::ELIDE_TAIL); |
| 58 } | 58 } |
| 59 | 59 |
| 60 base::string16 GetButtonText(Profile* profile) { | 60 base::string16 GetButtonText(Profile* profile) { |
| 61 base::string16 name = GetElidedText( | 61 base::string16 name = GetElidedText( |
| 62 profiles::GetAvatarNameForProfile(profile)); | 62 profiles::GetAvatarNameForProfile(profile)); |
| 63 if (profile->IsSupervised()) | 63 if (profile->IsSupervised()) |
| 64 name = l10n_util::GetStringFUTF16(IDS_MANAGED_USER_NEW_AVATAR_LABEL, name); | 64 name = l10n_util::GetStringFUTF16(IDS_SUPERVISED_USER_NEW_AVATAR_LABEL, |
| 65 name); |
| 65 return name; | 66 return name; |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // namespace | 69 } // namespace |
| 69 | 70 |
| 70 NewAvatarButton::NewAvatarButton( | 71 NewAvatarButton::NewAvatarButton( |
| 71 views::ButtonListener* listener, | 72 views::ButtonListener* listener, |
| 72 const base::string16& profile_name, | 73 const base::string16& profile_name, |
| 73 AvatarButtonStyle button_style, | 74 AvatarButtonStyle button_style, |
| 74 Browser* browser) | 75 Browser* browser) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // We want the button to resize if the new text is shorter. | 175 // We want the button to resize if the new text is shorter. |
| 175 SetText(GetButtonText(browser_->profile())); | 176 SetText(GetButtonText(browser_->profile())); |
| 176 set_min_size(gfx::Size()); | 177 set_min_size(gfx::Size()); |
| 177 InvalidateLayout(); | 178 InvalidateLayout(); |
| 178 | 179 |
| 179 // Because the width of the button might have changed, the parent browser | 180 // Because the width of the button might have changed, the parent browser |
| 180 // frame needs to recalculate the button bounds and redraw it. | 181 // frame needs to recalculate the button bounds and redraw it. |
| 181 if (parent()) | 182 if (parent()) |
| 182 parent()->Layout(); | 183 parent()->Layout(); |
| 183 } | 184 } |
| OLD | NEW |