Chromium Code Reviews| 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 if (item_.active || item_.signin_required) | 263 const gfx::ImageSkia profile_icon = *profiles::GetSizedAvatarIcon(item_.icon, |
| 264 false, profiles::kAvatarIconWidth, kItemHeight).ToImageSkia(); | |
| 265 if (item_.active || item_.signin_required) { | |
|
msw
2014/04/29 21:25:10
nit: remove unnecessary braces
Mike Lerman
2014/04/30 13:12:47
Done.
| |
| 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); |
| 269 } | |
| 267 AddChildView(image_view_); | 270 AddChildView(image_view_); |
| 268 | 271 |
| 269 // Add a label to show the profile name. | 272 // Add a label to show the profile name. |
| 270 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 273 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 271 name_label_ = new views::Label(item_.name, | 274 name_label_ = new views::Label(item_.name, |
| 272 rb->GetFontList(item_.active ? | 275 rb->GetFontList(item_.active ? |
| 273 ui::ResourceBundle::BoldFont : | 276 ui::ResourceBundle::BoldFont : |
| 274 ui::ResourceBundle::BaseFont)); | 277 ui::ResourceBundle::BaseFont)); |
| 275 name_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 278 name_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 276 AddChildView(name_label_); | 279 AddChildView(name_label_); |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 Layout(); | 802 Layout(); |
| 800 if (GetBubbleFrameView()) | 803 if (GetBubbleFrameView()) |
| 801 SizeToContents(); | 804 SizeToContents(); |
| 802 } | 805 } |
| 803 | 806 |
| 804 void AvatarMenuBubbleView::SetBackgroundColors() { | 807 void AvatarMenuBubbleView::SetBackgroundColors() { |
| 805 for (size_t i = 0; i < item_views_.size(); ++i) { | 808 for (size_t i = 0; i < item_views_.size(); ++i) { |
| 806 item_views_[i]->OnHighlightStateChanged(); | 809 item_views_[i]->OnHighlightStateChanged(); |
| 807 } | 810 } |
| 808 } | 811 } |
| OLD | NEW |