OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/avatar_menu_bubble_view.h" | 5 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 209 } |
210 | 210 |
211 } // namespace | 211 } // namespace |
212 | 212 |
213 // ProfileItemView ------------------------------------------------------------ | 213 // ProfileItemView ------------------------------------------------------------ |
214 | 214 |
215 // Control that shows information about a single profile. | 215 // Control that shows information about a single profile. |
216 class ProfileItemView : public views::CustomButton, | 216 class ProfileItemView : public views::CustomButton, |
217 public HighlightDelegate { | 217 public HighlightDelegate { |
218 public: | 218 public: |
219 ProfileItemView(const AvatarMenuModel::Item& item, | 219 ProfileItemView(const ui::AvatarMenuItemModel& item, |
220 AvatarMenuBubbleView* parent); | 220 AvatarMenuBubbleView* parent); |
221 | 221 |
222 virtual gfx::Size GetPreferredSize() OVERRIDE; | 222 virtual gfx::Size GetPreferredSize() OVERRIDE; |
223 virtual void Layout() OVERRIDE; | 223 virtual void Layout() OVERRIDE; |
224 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 224 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
225 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 225 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
226 virtual void OnFocus() OVERRIDE; | 226 virtual void OnFocus() OVERRIDE; |
227 virtual void OnBlur() OVERRIDE; | 227 virtual void OnBlur() OVERRIDE; |
228 | 228 |
229 virtual void OnHighlightStateChanged() OVERRIDE; | 229 virtual void OnHighlightStateChanged() OVERRIDE; |
230 virtual void OnFocusStateChanged(bool has_focus) OVERRIDE; | 230 virtual void OnFocusStateChanged(bool has_focus) OVERRIDE; |
231 | 231 |
232 const AvatarMenuModel::Item& item() const { return item_; } | 232 const ui::AvatarMenuItemModel& item() const { return item_; } |
233 EditProfileLink* edit_link() { return edit_link_; } | 233 EditProfileLink* edit_link() { return edit_link_; } |
234 | 234 |
235 private: | 235 private: |
236 gfx::ImageSkia GetBadgedIcon(const gfx::ImageSkia& icon); | 236 gfx::ImageSkia GetBadgedIcon(const gfx::ImageSkia& icon); |
237 | 237 |
238 bool IsHighlighted(); | 238 bool IsHighlighted(); |
239 | 239 |
240 AvatarMenuModel::Item item_; | 240 ui::AvatarMenuItemModel item_; |
241 AvatarMenuBubbleView* parent_; | 241 AvatarMenuBubbleView* parent_; |
242 views::ImageView* image_view_; | 242 views::ImageView* image_view_; |
243 views::Label* name_label_; | 243 views::Label* name_label_; |
244 views::Label* sync_state_label_; | 244 views::Label* sync_state_label_; |
245 EditProfileLink* edit_link_; | 245 EditProfileLink* edit_link_; |
246 | 246 |
247 DISALLOW_COPY_AND_ASSIGN(ProfileItemView); | 247 DISALLOW_COPY_AND_ASSIGN(ProfileItemView); |
248 }; | 248 }; |
249 | 249 |
250 ProfileItemView::ProfileItemView(const AvatarMenuModel::Item& item, | 250 ProfileItemView::ProfileItemView(const ui::AvatarMenuItemModel& item, |
251 AvatarMenuBubbleView* parent) | 251 AvatarMenuBubbleView* parent) |
252 : views::CustomButton(parent), | 252 : views::CustomButton(parent), |
253 item_(item), | 253 item_(item), |
254 parent_(parent) { | 254 parent_(parent) { |
255 set_notify_enter_exit_on_child(true); | 255 set_notify_enter_exit_on_child(true); |
256 | 256 |
257 image_view_ = new ProfileImageView(); | 257 image_view_ = new ProfileImageView(); |
258 gfx::ImageSkia profile_icon = *item_.icon.ToImageSkia(); | 258 gfx::ImageSkia profile_icon = *item_.icon.ToImageSkia(); |
259 if (item_.active || item_.signin_required) | 259 if (item_.active || item_.signin_required) |
260 image_view_->SetImage(GetBadgedIcon(profile_icon)); | 260 image_view_->SetImage(GetBadgedIcon(profile_icon)); |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 } | 700 } |
701 | 701 |
702 void AvatarMenuBubbleView::WindowClosing() { | 702 void AvatarMenuBubbleView::WindowClosing() { |
703 DCHECK_EQ(avatar_bubble_, this); | 703 DCHECK_EQ(avatar_bubble_, this); |
704 avatar_bubble_ = NULL; | 704 avatar_bubble_ = NULL; |
705 } | 705 } |
706 | 706 |
707 void AvatarMenuBubbleView::InitMenuContents( | 707 void AvatarMenuBubbleView::InitMenuContents( |
708 AvatarMenuModel* avatar_menu_model) { | 708 AvatarMenuModel* avatar_menu_model) { |
709 for (size_t i = 0; i < avatar_menu_model->GetNumberOfItems(); ++i) { | 709 for (size_t i = 0; i < avatar_menu_model->GetNumberOfItems(); ++i) { |
710 const AvatarMenuModel::Item& item = avatar_menu_model->GetItemAt(i); | 710 const ui::AvatarMenuItemModel& item = avatar_menu_model->GetItemAt(i); |
711 ProfileItemView* item_view = new ProfileItemView(item, this); | 711 ProfileItemView* item_view = new ProfileItemView(item, this); |
712 item_view->SetAccessibleName(l10n_util::GetStringFUTF16( | 712 item_view->SetAccessibleName(l10n_util::GetStringFUTF16( |
713 IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME, item.name)); | 713 IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME, item.name)); |
714 item_view->set_focusable(true); | 714 item_view->set_focusable(true); |
715 AddChildView(item_view); | 715 AddChildView(item_view); |
716 item_views_.push_back(item_view); | 716 item_views_.push_back(item_view); |
717 } | 717 } |
718 | 718 |
719 if (CommandLine::ForCurrentProcess()->HasSwitch( | 719 if (CommandLine::ForCurrentProcess()->HasSwitch( |
720 switches::kNewProfileManagement)) { | 720 switches::kNewProfileManagement)) { |
(...skipping 11 matching lines...) Expand all Loading... |
732 AddChildView(separator_); | 732 AddChildView(separator_); |
733 buttons_view_ = add_profile_link; | 733 buttons_view_ = add_profile_link; |
734 AddChildView(buttons_view_); | 734 AddChildView(buttons_view_); |
735 } | 735 } |
736 } | 736 } |
737 | 737 |
738 void AvatarMenuBubbleView::InitManagedUserContents( | 738 void AvatarMenuBubbleView::InitManagedUserContents( |
739 AvatarMenuModel* avatar_menu_model) { | 739 AvatarMenuModel* avatar_menu_model) { |
740 // Show the profile of the managed user. | 740 // Show the profile of the managed user. |
741 size_t active_index = avatar_menu_model->GetActiveProfileIndex(); | 741 size_t active_index = avatar_menu_model->GetActiveProfileIndex(); |
742 const AvatarMenuModel::Item& item = | 742 const ui::AvatarMenuItemModel& item = |
743 avatar_menu_model->GetItemAt(active_index); | 743 avatar_menu_model->GetItemAt(active_index); |
744 ProfileItemView* item_view = new ProfileItemView(item, this); | 744 ProfileItemView* item_view = new ProfileItemView(item, this); |
745 item_view->SetAccessibleName(l10n_util::GetStringFUTF16( | 745 item_view->SetAccessibleName(l10n_util::GetStringFUTF16( |
746 IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME, item.name)); | 746 IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME, item.name)); |
747 item_views_.push_back(item_view); | 747 item_views_.push_back(item_view); |
748 AddChildView(item_view); | 748 AddChildView(item_view); |
749 separator_ = new views::Separator(views::Separator::HORIZONTAL); | 749 separator_ = new views::Separator(views::Separator::HORIZONTAL); |
750 AddChildView(separator_); | 750 AddChildView(separator_); |
751 | 751 |
752 // Add information about managed users. | 752 // Add information about managed users. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 Layout(); | 793 Layout(); |
794 if (GetBubbleFrameView()) | 794 if (GetBubbleFrameView()) |
795 SizeToContents(); | 795 SizeToContents(); |
796 } | 796 } |
797 | 797 |
798 void AvatarMenuBubbleView::SetBackgroundColors() { | 798 void AvatarMenuBubbleView::SetBackgroundColors() { |
799 for (size_t i = 0; i < item_views_.size(); ++i) { | 799 for (size_t i = 0; i < item_views_.size(); ++i) { |
800 item_views_[i]->OnHighlightStateChanged(); | 800 item_views_[i]->OnHighlightStateChanged(); |
801 } | 801 } |
802 } | 802 } |
OLD | NEW |