Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(940)

Side by Side Diff: chrome/browser/ui/views/avatar_menu_bubble_view.cc

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 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 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 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 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 } 698 }
699 699
700 void AvatarMenuBubbleView::WindowClosing() { 700 void AvatarMenuBubbleView::WindowClosing() {
701 DCHECK_EQ(avatar_bubble_, this); 701 DCHECK_EQ(avatar_bubble_, this);
702 avatar_bubble_ = NULL; 702 avatar_bubble_ = NULL;
703 } 703 }
704 704
705 void AvatarMenuBubbleView::InitMenuContents( 705 void AvatarMenuBubbleView::InitMenuContents(
706 AvatarMenuModel* avatar_menu_model) { 706 AvatarMenuModel* avatar_menu_model) {
707 for (size_t i = 0; i < avatar_menu_model->GetNumberOfItems(); ++i) { 707 for (size_t i = 0; i < avatar_menu_model->GetNumberOfItems(); ++i) {
708 const AvatarMenuModel::Item& item = avatar_menu_model->GetItemAt(i); 708 const AvatarMenuItemModel& item = avatar_menu_model->GetItemAt(i);
709 ProfileItemView* item_view = new ProfileItemView(item, this); 709 ProfileItemView* item_view = new ProfileItemView(item, this);
710 item_view->SetAccessibleName(l10n_util::GetStringFUTF16( 710 item_view->SetAccessibleName(l10n_util::GetStringFUTF16(
711 IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME, item.name)); 711 IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME, item.name));
712 item_view->set_focusable(true); 712 item_view->set_focusable(true);
713 AddChildView(item_view); 713 AddChildView(item_view);
714 item_views_.push_back(item_view); 714 item_views_.push_back(item_view);
715 } 715 }
716 716
717 if (CommandLine::ForCurrentProcess()->HasSwitch( 717 if (CommandLine::ForCurrentProcess()->HasSwitch(
718 switches::kNewProfileManagement)) { 718 switches::kNewProfileManagement)) {
(...skipping 11 matching lines...) Expand all
730 AddChildView(separator_); 730 AddChildView(separator_);
731 buttons_view_ = add_profile_link; 731 buttons_view_ = add_profile_link;
732 AddChildView(buttons_view_); 732 AddChildView(buttons_view_);
733 } 733 }
734 } 734 }
735 735
736 void AvatarMenuBubbleView::InitManagedUserContents( 736 void AvatarMenuBubbleView::InitManagedUserContents(
737 AvatarMenuModel* avatar_menu_model) { 737 AvatarMenuModel* avatar_menu_model) {
738 // Show the profile of the managed user. 738 // Show the profile of the managed user.
739 size_t active_index = avatar_menu_model->GetActiveProfileIndex(); 739 size_t active_index = avatar_menu_model->GetActiveProfileIndex();
740 const AvatarMenuModel::Item& item = 740 const AvatarMenuItemModel& item =
741 avatar_menu_model->GetItemAt(active_index); 741 avatar_menu_model->GetItemAt(active_index);
742 ProfileItemView* item_view = new ProfileItemView(item, this); 742 ProfileItemView* item_view = new ProfileItemView(item, this);
743 item_view->SetAccessibleName(l10n_util::GetStringFUTF16( 743 item_view->SetAccessibleName(l10n_util::GetStringFUTF16(
744 IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME, item.name)); 744 IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME, item.name));
745 item_views_.push_back(item_view); 745 item_views_.push_back(item_view);
746 AddChildView(item_view); 746 AddChildView(item_view);
747 separator_ = new views::Separator(views::Separator::HORIZONTAL); 747 separator_ = new views::Separator(views::Separator::HORIZONTAL);
748 AddChildView(separator_); 748 AddChildView(separator_);
749 749
750 // Add information about managed users. 750 // Add information about managed users.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 Layout(); 791 Layout();
792 if (GetBubbleFrameView()) 792 if (GetBubbleFrameView())
793 SizeToContents(); 793 SizeToContents();
794 } 794 }
795 795
796 void AvatarMenuBubbleView::SetBackgroundColors() { 796 void AvatarMenuBubbleView::SetBackgroundColors() {
797 for (size_t i = 0; i < item_views_.size(); ++i) { 797 for (size_t i = 0; i < item_views_.size(); ++i) {
798 item_views_[i]->OnHighlightStateChanged(); 798 item_views_[i]->OnHighlightStateChanged();
799 } 799 }
800 } 800 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698