| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ | 5 #ifndef ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ |
| 6 #define ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ | 6 #define ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/ash_export.h" | 12 #include "ash/ash_export.h" |
| 13 #include "ash/public/cpp/session_types.h" | 13 #include "ash/public/cpp/session_types.h" |
| 14 #include "ash/public/interfaces/session_controller.mojom.h" | 14 #include "ash/public/interfaces/session_controller.mojom.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "mojo/public/cpp/bindings/binding_set.h" | 17 #include "mojo/public/cpp/bindings/binding_set.h" |
| 18 | 18 |
| 19 class AccountId; | 19 class AccountId; |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 | 22 |
| 23 enum class LoginStatus; |
| 23 class SessionStateObserver; | 24 class SessionStateObserver; |
| 24 | 25 |
| 25 // Implements mojom::SessionController to cache session related info such as | 26 // Implements mojom::SessionController to cache session related info such as |
| 26 // session state, meta data about user sessions to support synchronous | 27 // session state, meta data about user sessions to support synchronous |
| 27 // queries for ash. It is targeted as a replacement for SessionStateDelegate. | 28 // queries for ash. It is targeted as a replacement for SessionStateDelegate. |
| 28 class ASH_EXPORT SessionController | 29 class ASH_EXPORT SessionController |
| 29 : NON_EXPORTED_BASE(public mojom::SessionController) { | 30 : NON_EXPORTED_BASE(public mojom::SessionController) { |
| 30 public: | 31 public: |
| 31 SessionController(); | 32 SessionController(); |
| 32 ~SessionController() override; | 33 ~SessionController() override; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // already signed in). | 79 // already signed in). |
| 79 void SwitchActiveUser(const AccountId& account_id); | 80 void SwitchActiveUser(const AccountId& account_id); |
| 80 | 81 |
| 81 // Switches the active user to the next or previous user, with the same | 82 // Switches the active user to the next or previous user, with the same |
| 82 // ordering as user sessions are created. | 83 // ordering as user sessions are created. |
| 83 void CycleActiveUser(CycleUserDirection direction); | 84 void CycleActiveUser(CycleUserDirection direction); |
| 84 | 85 |
| 85 void AddSessionStateObserver(SessionStateObserver* observer); | 86 void AddSessionStateObserver(SessionStateObserver* observer); |
| 86 void RemoveSessionStateObserver(SessionStateObserver* observer); | 87 void RemoveSessionStateObserver(SessionStateObserver* observer); |
| 87 | 88 |
| 89 // Returns the legacy ash notion of login status. |
| 90 // NOTE: Prefer GetSessionState() in new code. |
| 91 LoginStatus GetLoginStatus() const; |
| 92 |
| 88 // mojom::SessionController | 93 // mojom::SessionController |
| 89 void SetClient(mojom::SessionControllerClientPtr client) override; | 94 void SetClient(mojom::SessionControllerClientPtr client) override; |
| 90 void SetSessionInfo(mojom::SessionInfoPtr info) override; | 95 void SetSessionInfo(mojom::SessionInfoPtr info) override; |
| 91 void UpdateUserSession(mojom::UserSessionPtr user_session) override; | 96 void UpdateUserSession(mojom::UserSessionPtr user_session) override; |
| 92 void SetUserSessionOrder( | 97 void SetUserSessionOrder( |
| 93 const std::vector<uint32_t>& user_session_order) override; | 98 const std::vector<uint32_t>& user_session_order) override; |
| 94 | 99 |
| 95 private: | 100 private: |
| 96 void SetSessionState(session_manager::SessionState state); | 101 void SetSessionState(session_manager::SessionState state); |
| 97 void AddUserSession(mojom::UserSessionPtr user_session); | 102 void AddUserSession(mojom::UserSessionPtr user_session); |
| 98 | 103 |
| 104 // Helper that returns login status when the session state is ACTIVE. |
| 105 LoginStatus GetLoginStatusForActiveSession() const; |
| 106 |
| 99 // Bindings for mojom::SessionController interface. | 107 // Bindings for mojom::SessionController interface. |
| 100 mojo::BindingSet<mojom::SessionController> bindings_; | 108 mojo::BindingSet<mojom::SessionController> bindings_; |
| 101 | 109 |
| 102 // Client interface to session manager code (chrome). | 110 // Client interface to session manager code (chrome). |
| 103 mojom::SessionControllerClientPtr client_; | 111 mojom::SessionControllerClientPtr client_; |
| 104 | 112 |
| 105 // Cached session info. | 113 // Cached session info. |
| 106 bool can_lock_ = false; | 114 bool can_lock_ = false; |
| 107 bool should_lock_screen_automatically_ = false; | 115 bool should_lock_screen_automatically_ = false; |
| 108 AddUserSessionPolicy add_user_session_policy_ = AddUserSessionPolicy::ALLOWED; | 116 AddUserSessionPolicy add_user_session_policy_ = AddUserSessionPolicy::ALLOWED; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 119 uint32_t active_session_id_ = 0u; | 127 uint32_t active_session_id_ = 0u; |
| 120 | 128 |
| 121 base::ObserverList<ash::SessionStateObserver> observers_; | 129 base::ObserverList<ash::SessionStateObserver> observers_; |
| 122 | 130 |
| 123 DISALLOW_COPY_AND_ASSIGN(SessionController); | 131 DISALLOW_COPY_AND_ASSIGN(SessionController); |
| 124 }; | 132 }; |
| 125 | 133 |
| 126 } // namespace ash | 134 } // namespace ash |
| 127 | 135 |
| 128 #endif // ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ | 136 #endif // ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ |
| OLD | NEW |