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/avatar_button.h" | 5 #include "chrome/browser/ui/views/profiles/avatar_button.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "chrome/app/vector_icons/vector_icons.h" | 9 #include "chrome/app/vector_icons/vector_icons.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 SetTextSubpixelRenderingEnabled(false); | 79 SetTextSubpixelRenderingEnabled(false); |
80 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 80 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
81 | 81 |
82 profile_observer_.Add( | 82 profile_observer_.Add( |
83 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); | 83 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); |
84 | 84 |
85 // The largest text height that fits in the button. If the font list height | 85 // The largest text height that fits in the button. If the font list height |
86 // is larger than this, it will be shrunk to match it. | 86 // is larger than this, it will be shrunk to match it. |
87 // TODO(noms): Calculate this constant algorithmically from the button's size. | 87 // TODO(noms): Calculate this constant algorithmically from the button's size. |
88 const int kDisplayFontHeight = 16; | 88 const int kDisplayFontHeight = 16; |
89 SetFontList( | 89 label()->SetFontList( |
90 label()->font_list().DeriveWithHeightUpperBound(kDisplayFontHeight)); | 90 label()->font_list().DeriveWithHeightUpperBound(kDisplayFontHeight)); |
91 | 91 |
92 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
93 // TODO(estade): Use MD button in other cases, too [http://crbug.com/591586] | 93 // TODO(estade): Use MD button in other cases, too [http://crbug.com/591586] |
94 if ((base::win::GetVersion() >= base::win::VERSION_WIN10) && | 94 if ((base::win::GetVersion() >= base::win::VERSION_WIN10) && |
95 ThemeServiceFactory::GetForProfile(profile)->UsingSystemTheme()) { | 95 ThemeServiceFactory::GetForProfile(profile)->UsingSystemTheme()) { |
96 DCHECK_EQ(AvatarButtonStyle::NATIVE, button_style); | 96 DCHECK_EQ(AvatarButtonStyle::NATIVE, button_style); |
97 use_win10_native_button_ = true; | 97 use_win10_native_button_ = true; |
98 } | 98 } |
99 #endif // defined(OS_WIN) | 99 #endif // defined(OS_WIN) |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 const int kDefaultImageTextSpacing = 5; | 273 const int kDefaultImageTextSpacing = 5; |
274 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing); | 274 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing); |
275 | 275 |
276 PreferredSizeChanged(); | 276 PreferredSizeChanged(); |
277 } | 277 } |
278 | 278 |
279 void AvatarButton::SetButtonAvatar(int avatar_idr) { | 279 void AvatarButton::SetButtonAvatar(int avatar_idr) { |
280 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 280 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
281 generic_avatar_ = *rb->GetImageNamed(avatar_idr).ToImageSkia(); | 281 generic_avatar_ = *rb->GetImageNamed(avatar_idr).ToImageSkia(); |
282 } | 282 } |
OLD | NEW |