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_menu_bubble_view.h" | 5 #include "chrome/browser/ui/views/profiles/avatar_menu_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 ProfileItemView::ProfileItemView(const AvatarMenu::Item& item, | 252 ProfileItemView::ProfileItemView(const AvatarMenu::Item& item, |
253 AvatarMenuBubbleView* parent, | 253 AvatarMenuBubbleView* parent, |
254 AvatarMenu* menu) | 254 AvatarMenu* menu) |
255 : views::CustomButton(parent), | 255 : views::CustomButton(parent), |
256 item_(item), | 256 item_(item), |
257 parent_(parent), | 257 parent_(parent), |
258 menu_(menu) { | 258 menu_(menu) { |
259 set_notify_enter_exit_on_child(true); | 259 set_notify_enter_exit_on_child(true); |
260 | 260 |
261 image_view_ = new ProfileImageView(); | 261 image_view_ = new ProfileImageView(); |
262 gfx::ImageSkia profile_icon = *item_.icon.ToImageSkia(); | 262 // GetSizedAvatarIcon will resize the icon in case it's too large. |
| 263 const gfx::ImageSkia profile_icon = *profiles::GetSizedAvatarIcon(item_.icon, |
| 264 false, profiles::kAvatarIconWidth, kItemHeight).ToImageSkia(); |
263 if (item_.active || item_.signin_required) | 265 if (item_.active || item_.signin_required) |
264 image_view_->SetImage(GetBadgedIcon(profile_icon)); | 266 image_view_->SetImage(GetBadgedIcon(profile_icon)); |
265 else | 267 else |
266 image_view_->SetImage(profile_icon); | 268 image_view_->SetImage(profile_icon); |
267 AddChildView(image_view_); | 269 AddChildView(image_view_); |
268 | 270 |
269 // Add a label to show the profile name. | 271 // Add a label to show the profile name. |
270 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 272 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
271 name_label_ = new views::Label(item_.name, | 273 name_label_ = new views::Label(item_.name, |
272 rb->GetFontList(item_.active ? | 274 rb->GetFontList(item_.active ? |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 Layout(); | 801 Layout(); |
800 if (GetBubbleFrameView()) | 802 if (GetBubbleFrameView()) |
801 SizeToContents(); | 803 SizeToContents(); |
802 } | 804 } |
803 | 805 |
804 void AvatarMenuBubbleView::SetBackgroundColors() { | 806 void AvatarMenuBubbleView::SetBackgroundColors() { |
805 for (size_t i = 0; i < item_views_.size(); ++i) { | 807 for (size_t i = 0; i < item_views_.size(); ++i) { |
806 item_views_[i]->OnHighlightStateChanged(); | 808 item_views_[i]->OnHighlightStateChanged(); |
807 } | 809 } |
808 } | 810 } |
OLD | NEW |