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 "ash/common/system/user/user_view.h" | 5 #include "ash/common/system/user/user_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/common/multi_profile_uma.h" | 10 #include "ash/common/multi_profile_uma.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 bool IsMultiProfileSupportedAndUserActive() { | 63 bool IsMultiProfileSupportedAndUserActive() { |
64 return WmShell::Get()->delegate()->IsMultiProfilesEnabled() && | 64 return WmShell::Get()->delegate()->IsMultiProfilesEnabled() && |
65 !WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked(); | 65 !WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked(); |
66 } | 66 } |
67 | 67 |
68 // Creates the view shown in the user switcher popup ("AddUserMenuOption"). | 68 // Creates the view shown in the user switcher popup ("AddUserMenuOption"). |
69 views::View* CreateAddUserView(AddUserSessionPolicy policy, | 69 views::View* CreateAddUserView(AddUserSessionPolicy policy, |
70 views::ButtonListener* listener) { | 70 views::ButtonListener* listener) { |
71 auto view = new views::View; | 71 auto* view = new views::View; |
72 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2; | 72 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2; |
73 auto layout = | 73 auto* layout = |
74 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 74 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
75 kTrayPopupLabelHorizontalPadding + icon_padding); | 75 kTrayPopupLabelHorizontalPadding + icon_padding); |
76 layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight); | 76 layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight); |
77 view->SetLayoutManager(layout); | 77 view->SetLayoutManager(layout); |
78 view->set_background( | 78 view->set_background( |
79 views::Background::CreateSolidBackground(kBackgroundColor)); | 79 views::Background::CreateSolidBackground(kBackgroundColor)); |
80 | 80 |
81 int message_id = 0; | 81 int message_id = 0; |
82 switch (policy) { | 82 switch (policy) { |
83 case AddUserSessionPolicy::ALLOWED: { | 83 case AddUserSessionPolicy::ALLOWED: { |
84 message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT; | 84 message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT; |
85 | 85 |
86 auto icon = new views::ImageView(); | 86 auto* icon = new views::ImageView(); |
87 icon->SetImage( | 87 icon->SetImage( |
88 gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor)); | 88 gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor)); |
89 view->AddChildView(icon); | 89 view->AddChildView(icon); |
90 break; | 90 break; |
91 } | 91 } |
92 case AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER: | 92 case AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER: |
93 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER; | 93 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER; |
94 break; | 94 break; |
95 case AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED: | 95 case AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED: |
96 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER; | 96 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER; |
97 break; | 97 break; |
98 case AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS: | 98 case AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS: |
99 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS; | 99 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS; |
100 break; | 100 break; |
101 } | 101 } |
102 | 102 |
103 auto command_label = new views::Label(l10n_util::GetStringUTF16(message_id)); | 103 auto* command_label = new views::Label(l10n_util::GetStringUTF16(message_id)); |
104 command_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 104 command_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
105 command_label->SetMultiLine(true); | 105 command_label->SetMultiLine(true); |
106 | 106 |
107 TrayPopupItemStyle label_style( | 107 TrayPopupItemStyle label_style( |
108 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); | 108 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); |
109 int vertical_padding = kMenuSeparatorVerticalPadding; | 109 int vertical_padding = kMenuSeparatorVerticalPadding; |
110 if (policy != AddUserSessionPolicy::ALLOWED) { | 110 if (policy != AddUserSessionPolicy::ALLOWED) { |
111 label_style.set_font_style(TrayPopupItemStyle::FontStyle::CAPTION); | 111 label_style.set_font_style(TrayPopupItemStyle::FontStyle::CAPTION); |
112 label_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); | 112 label_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); |
113 vertical_padding += kMenuSeparatorVerticalPadding; | 113 vertical_padding += kMenuSeparatorVerticalPadding; |
114 } | 114 } |
115 label_style.SetupLabel(command_label); | 115 label_style.SetupLabel(command_label); |
116 view->AddChildView(command_label); | 116 view->AddChildView(command_label); |
117 view->SetBorder(views::CreateEmptyBorder(vertical_padding, icon_padding, | 117 view->SetBorder(views::CreateEmptyBorder(vertical_padding, icon_padding, |
118 vertical_padding, | 118 vertical_padding, |
119 kTrayPopupLabelHorizontalPadding)); | 119 kTrayPopupLabelHorizontalPadding)); |
120 if (policy == AddUserSessionPolicy::ALLOWED) { | 120 if (policy == AddUserSessionPolicy::ALLOWED) { |
121 auto button = | 121 auto* button = |
122 new ButtonFromView(view, listener, TrayPopupInkDropStyle::INSET_BOUNDS); | 122 new ButtonFromView(view, listener, TrayPopupInkDropStyle::INSET_BOUNDS); |
123 button->SetAccessibleName( | 123 button->SetAccessibleName( |
124 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT)); | 124 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT)); |
125 return button; | 125 return button; |
126 } | 126 } |
127 | 127 |
128 return view; | 128 return view; |
129 } | 129 } |
130 | 130 |
131 class UserViewMouseWatcherHost : public views::MouseWatcherHost { | 131 class UserViewMouseWatcherHost : public views::MouseWatcherHost { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 add_user_enabled_(true), | 213 add_user_enabled_(true), |
214 focus_manager_(nullptr) { | 214 focus_manager_(nullptr) { |
215 CHECK_NE(LoginStatus::NOT_LOGGED_IN, login); | 215 CHECK_NE(LoginStatus::NOT_LOGGED_IN, login); |
216 // The logout button must be added before the user card so that the user card | 216 // The logout button must be added before the user card so that the user card |
217 // can correctly calculate the remaining available width. | 217 // can correctly calculate the remaining available width. |
218 // Note that only the current multiprofile user gets a button. | 218 // Note that only the current multiprofile user gets a button. |
219 if (IsActiveUser()) | 219 if (IsActiveUser()) |
220 AddLogoutButton(login); | 220 AddLogoutButton(login); |
221 AddUserCard(login); | 221 AddUserCard(login); |
222 | 222 |
223 auto layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 223 auto* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
224 SetLayoutManager(layout); | 224 SetLayoutManager(layout); |
225 layout->set_cross_axis_alignment( | 225 layout->set_cross_axis_alignment( |
226 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); | 226 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
227 layout->SetFlexForView(user_card_view_, 1); | 227 layout->SetFlexForView(user_card_view_, 1); |
228 | 228 |
229 if (IsActiveUser()) | 229 if (IsActiveUser()) |
230 SetBorder(base::MakeUnique<ActiveUserBorder>()); | 230 SetBorder(base::MakeUnique<ActiveUserBorder>()); |
231 } | 231 } |
232 | 232 |
233 UserView::~UserView() { | 233 UserView::~UserView() { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 return; | 399 return; |
400 focus_manager_->RemoveFocusChangeListener(this); | 400 focus_manager_->RemoveFocusChangeListener(this); |
401 focus_manager_ = nullptr; | 401 focus_manager_ = nullptr; |
402 if (user_card_view_->GetFocusManager()) | 402 if (user_card_view_->GetFocusManager()) |
403 user_card_view_->GetFocusManager()->ClearFocus(); | 403 user_card_view_->GetFocusManager()->ClearFocus(); |
404 add_menu_option_.reset(); | 404 add_menu_option_.reset(); |
405 } | 405 } |
406 | 406 |
407 } // namespace tray | 407 } // namespace tray |
408 } // namespace ash | 408 } // namespace ash |
OLD | NEW |