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

Side by Side Diff: ash/common/system/user/user_view.cc

Issue 2734933004: ash: Use SessionController instead of SessionStateDelegate (Closed)
Patch Set: rebase Created 3 years, 9 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 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"
11 #include "ash/common/session/session_state_delegate.h" 11 #include "ash/common/session/session_controller.h"
12 #include "ash/common/shell_delegate.h" 12 #include "ash/common/shell_delegate.h"
13 #include "ash/common/system/tray/system_tray.h" 13 #include "ash/common/system/tray/system_tray.h"
14 #include "ash/common/system/tray/system_tray_controller.h" 14 #include "ash/common/system/tray/system_tray_controller.h"
15 #include "ash/common/system/tray/system_tray_delegate.h" 15 #include "ash/common/system/tray/system_tray_delegate.h"
16 #include "ash/common/system/tray/tray_constants.h" 16 #include "ash/common/system/tray/tray_constants.h"
17 #include "ash/common/system/tray/tray_popup_item_style.h" 17 #include "ash/common/system/tray/tray_popup_item_style.h"
18 #include "ash/common/system/tray/tray_popup_utils.h" 18 #include "ash/common/system/tray/tray_popup_utils.h"
19 #include "ash/common/system/user/button_from_view.h" 19 #include "ash/common/system/user/button_from_view.h"
20 #include "ash/common/system/user/login_status.h" 20 #include "ash/common/system/user/login_status.h"
21 #include "ash/common/system/user/rounded_image_view.h" 21 #include "ash/common/system/user/rounded_image_view.h"
(...skipping 21 matching lines...) Expand all
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 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); 53 SessionController* controller = WmShell::Get()->session_controller();
54 if (delegate->IsUserSessionBlocked()) 54 if (controller->IsUserSessionBlocked())
55 return; 55 return;
56 56
57 DCHECK(user_index > 0); 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
59 // for such case.
60 DCHECK_GT(user_index, 0);
61 DCHECK_LT(user_index, controller->NumberOfLoggedInUsers());
62
58 MultiProfileUMA::RecordSwitchActiveUser( 63 MultiProfileUMA::RecordSwitchActiveUser(
59 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_TRAY); 64 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_TRAY);
60 delegate->SwitchActiveUser(delegate->GetUserInfo(user_index)->GetAccountId()); 65 controller->SwitchActiveUser(
66 controller->GetUserSession(user_index)->account_id);
61 } 67 }
62 68
63 bool IsMultiProfileSupportedAndUserActive() { 69 bool IsMultiProfileSupportedAndUserActive() {
64 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() && 70 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() &&
65 !WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked(); 71 !WmShell::Get()->session_controller()->IsUserSessionBlocked();
66 } 72 }
67 73
68 // Creates the view shown in the user switcher popup ("AddUserMenuOption"). 74 // Creates the view shown in the user switcher popup ("AddUserMenuOption").
69 views::View* CreateAddUserView(AddUserSessionPolicy policy, 75 views::View* CreateAddUserView(AddUserSessionPolicy policy,
70 views::ButtonListener* listener) { 76 views::ButtonListener* listener) {
71 auto* view = new views::View; 77 auto* view = new views::View;
72 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2; 78 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2;
73 auto* layout = 79 auto* layout =
74 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 80 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
75 kTrayPopupLabelHorizontalPadding + icon_padding); 81 kTrayPopupLabelHorizontalPadding + icon_padding);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 344 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
339 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 345 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
340 params.name = "AddUserMenuOption"; 346 params.name = "AddUserMenuOption";
341 WmWindow::Get(GetWidget()->GetNativeWindow()) 347 WmWindow::Get(GetWidget()->GetNativeWindow())
342 ->GetRootWindowController() 348 ->GetRootWindowController()
343 ->ConfigureWidgetInitParamsForContainer( 349 ->ConfigureWidgetInitParamsForContainer(
344 add_menu_option_.get(), kShellWindowId_DragImageAndTooltipContainer, 350 add_menu_option_.get(), kShellWindowId_DragImageAndTooltipContainer,
345 &params); 351 &params);
346 add_menu_option_->Init(params); 352 add_menu_option_->Init(params);
347 353
348 const SessionStateDelegate* delegate =
349 WmShell::Get()->GetSessionStateDelegate();
350 const AddUserSessionPolicy add_user_policy = 354 const AddUserSessionPolicy add_user_policy =
351 delegate->GetAddUserSessionPolicy(); 355 WmShell::Get()->session_controller()->GetAddUserPolicy();
352 add_user_enabled_ = add_user_policy == AddUserSessionPolicy::ALLOWED; 356 add_user_enabled_ = add_user_policy == AddUserSessionPolicy::ALLOWED;
353 357
354 // 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
355 // 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
356 // the active user to show through. 360 // the active user to show through.
357 gfx::Rect bounds = user_card_view_->GetBoundsInScreen(); 361 gfx::Rect bounds = user_card_view_->GetBoundsInScreen();
358 bounds.set_width(bounds.width() + kSeparatorWidth); 362 bounds.set_width(bounds.width() + kSeparatorWidth);
359 int row_height = bounds.height(); 363 int row_height = bounds.height();
360 364
361 views::View* container = new AddUserWidgetContents( 365 views::View* container = new AddUserWidgetContents(
(...skipping 30 matching lines...) Expand all
392 return; 396 return;
393 focus_manager_->RemoveFocusChangeListener(this); 397 focus_manager_->RemoveFocusChangeListener(this);
394 focus_manager_ = nullptr; 398 focus_manager_ = nullptr;
395 if (user_card_view_->GetFocusManager()) 399 if (user_card_view_->GetFocusManager())
396 user_card_view_->GetFocusManager()->ClearFocus(); 400 user_card_view_->GetFocusManager()->ClearFocus();
397 add_menu_option_.reset(); 401 add_menu_option_.reset();
398 } 402 }
399 403
400 } // namespace tray 404 } // namespace tray
401 } // namespace ash 405 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698