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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "ui/views/painter.h" | 43 #include "ui/views/painter.h" |
44 | 44 |
45 namespace ash { | 45 namespace ash { |
46 namespace tray { | 46 namespace tray { |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
50 // Switch to a user with the given |user_index|. | 50 // Switch to a user with the given |user_index|. |
51 void SwitchUser(UserIndex user_index) { | 51 void SwitchUser(UserIndex user_index) { |
52 // Do not switch users when the log screen is presented. | 52 // Do not switch users when the log screen is presented. |
53 SessionController* controller = WmShell::Get()->session_controller(); | 53 SessionController* controller = Shell::Get()->session_controller(); |
54 if (controller->IsUserSessionBlocked()) | 54 if (controller->IsUserSessionBlocked()) |
55 return; | 55 return; |
56 | 56 |
57 // |user_index| must be in range (0, number_of_user). Note 0 is excluded | 57 // |user_index| must be in range (0, number_of_user). Note 0 is excluded |
58 // because it represents the active user and SwitchUser should not be called | 58 // because it represents the active user and SwitchUser should not be called |
59 // for such case. | 59 // for such case. |
60 DCHECK_GT(user_index, 0); | 60 DCHECK_GT(user_index, 0); |
61 DCHECK_LT(user_index, controller->NumberOfLoggedInUsers()); | 61 DCHECK_LT(user_index, controller->NumberOfLoggedInUsers()); |
62 | 62 |
63 MultiProfileUMA::RecordSwitchActiveUser( | 63 MultiProfileUMA::RecordSwitchActiveUser( |
64 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_TRAY); | 64 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_TRAY); |
65 controller->SwitchActiveUser( | 65 controller->SwitchActiveUser( |
66 controller->GetUserSession(user_index)->account_id); | 66 controller->GetUserSession(user_index)->account_id); |
67 } | 67 } |
68 | 68 |
69 bool IsMultiProfileSupportedAndUserActive() { | 69 bool IsMultiProfileSupportedAndUserActive() { |
70 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() && | 70 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() && |
71 !WmShell::Get()->session_controller()->IsUserSessionBlocked(); | 71 !Shell::Get()->session_controller()->IsUserSessionBlocked(); |
72 } | 72 } |
73 | 73 |
74 // Creates the view shown in the user switcher popup ("AddUserMenuOption"). | 74 // Creates the view shown in the user switcher popup ("AddUserMenuOption"). |
75 views::View* CreateAddUserView(AddUserSessionPolicy policy, | 75 views::View* CreateAddUserView(AddUserSessionPolicy policy, |
76 views::ButtonListener* listener) { | 76 views::ButtonListener* listener) { |
77 auto* view = new views::View; | 77 auto* view = new views::View; |
78 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2; | 78 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2; |
79 auto* layout = | 79 auto* layout = |
80 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 80 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
81 kTrayPopupLabelHorizontalPadding + icon_padding); | 81 kTrayPopupLabelHorizontalPadding + icon_padding); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 345 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
346 params.name = "AddUserMenuOption"; | 346 params.name = "AddUserMenuOption"; |
347 WmWindow::Get(GetWidget()->GetNativeWindow()) | 347 WmWindow::Get(GetWidget()->GetNativeWindow()) |
348 ->GetRootWindowController() | 348 ->GetRootWindowController() |
349 ->ConfigureWidgetInitParamsForContainer( | 349 ->ConfigureWidgetInitParamsForContainer( |
350 add_menu_option_.get(), kShellWindowId_DragImageAndTooltipContainer, | 350 add_menu_option_.get(), kShellWindowId_DragImageAndTooltipContainer, |
351 ¶ms); | 351 ¶ms); |
352 add_menu_option_->Init(params); | 352 add_menu_option_->Init(params); |
353 | 353 |
354 const AddUserSessionPolicy add_user_policy = | 354 const AddUserSessionPolicy add_user_policy = |
355 WmShell::Get()->session_controller()->GetAddUserPolicy(); | 355 Shell::Get()->session_controller()->GetAddUserPolicy(); |
356 add_user_enabled_ = add_user_policy == AddUserSessionPolicy::ALLOWED; | 356 add_user_enabled_ = add_user_policy == AddUserSessionPolicy::ALLOWED; |
357 | 357 |
358 // Position the widget on top of the user card view (which is still in the | 358 // Position the widget on top of the user card view (which is still in the |
359 // system menu). The top half of the widget will be transparent to allow | 359 // system menu). The top half of the widget will be transparent to allow |
360 // the active user to show through. | 360 // the active user to show through. |
361 gfx::Rect bounds = user_card_view_->GetBoundsInScreen(); | 361 gfx::Rect bounds = user_card_view_->GetBoundsInScreen(); |
362 bounds.set_width(bounds.width() + kSeparatorWidth); | 362 bounds.set_width(bounds.width() + kSeparatorWidth); |
363 int row_height = bounds.height(); | 363 int row_height = bounds.height(); |
364 | 364 |
365 views::View* container = new AddUserWidgetContents( | 365 views::View* container = new AddUserWidgetContents( |
(...skipping 30 matching lines...) Expand all Loading... |
396 return; | 396 return; |
397 focus_manager_->RemoveFocusChangeListener(this); | 397 focus_manager_->RemoveFocusChangeListener(this); |
398 focus_manager_ = nullptr; | 398 focus_manager_ = nullptr; |
399 if (user_card_view_->GetFocusManager()) | 399 if (user_card_view_->GetFocusManager()) |
400 user_card_view_->GetFocusManager()->ClearFocus(); | 400 user_card_view_->GetFocusManager()->ClearFocus(); |
401 add_menu_option_.reset(); | 401 add_menu_option_.reset(); |
402 } | 402 } |
403 | 403 |
404 } // namespace tray | 404 } // namespace tray |
405 } // namespace ash | 405 } // namespace ash |
OLD | NEW |