| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 label()->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 button_style == AvatarButtonStyle::NATIVE) |
| 97 use_win10_native_button_ = true; | 97 use_win10_native_button_ = true; |
| 98 } | |
| 99 #endif // defined(OS_WIN) | 98 #endif // defined(OS_WIN) |
| 100 | 99 |
| 101 if (use_win10_native_button_) { | 100 if (use_win10_native_button_) { |
| 102 constexpr int kMdButtonIconHeight = 16; | 101 constexpr int kMdButtonIconHeight = 16; |
| 103 constexpr SkColor kMdButtonIconColor = | 102 constexpr SkColor kMdButtonIconColor = |
| 104 SkColorSetA(SK_ColorBLACK, static_cast<SkAlpha>(0.54 * 0xFF)); | 103 SkColorSetA(SK_ColorBLACK, static_cast<SkAlpha>(0.54 * 0xFF)); |
| 105 generic_avatar_ = gfx::CreateVectorIcon( | 104 generic_avatar_ = gfx::CreateVectorIcon( |
| 106 kAccountCircleIcon, kMdButtonIconHeight, kMdButtonIconColor); | 105 kAccountCircleIcon, kMdButtonIconHeight, kMdButtonIconColor); |
| 107 SetBorder(CreateWin10NativeBorder()); | 106 SetBorder(CreateWin10NativeBorder()); |
| 108 | 107 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 const int kDefaultImageTextSpacing = 5; | 272 const int kDefaultImageTextSpacing = 5; |
| 274 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing); | 273 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing); |
| 275 | 274 |
| 276 PreferredSizeChanged(); | 275 PreferredSizeChanged(); |
| 277 } | 276 } |
| 278 | 277 |
| 279 void AvatarButton::SetButtonAvatar(int avatar_idr) { | 278 void AvatarButton::SetButtonAvatar(int avatar_idr) { |
| 280 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 279 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 281 generic_avatar_ = *rb->GetImageNamed(avatar_idr).ToImageSkia(); | 280 generic_avatar_ = *rb->GetImageNamed(avatar_idr).ToImageSkia(); |
| 282 } | 281 } |
| OLD | NEW |