Chromium Code Reviews| 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 CHROME_BROWSER_UI_ASH_SESSION_CONTROLLER_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_SESSION_CONTROLLER_CLIENT_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_SESSION_CONTROLLER_CLIENT_H_ | 6 #define CHROME_BROWSER_UI_ASH_SESSION_CONTROLLER_CLIENT_H_ |
| 7 | 7 |
| 8 #include <vector> | |
| 9 | |
| 8 #include "ash/public/interfaces/session_controller.mojom.h" | 10 #include "ash/public/interfaces/session_controller.mojom.h" |
| 9 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 10 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" | 15 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" |
| 14 #include "components/session_manager/core/session_manager_observer.h" | 16 #include "components/session_manager/core/session_manager_observer.h" |
| 15 #include "components/user_manager/user_manager.h" | 17 #include "components/user_manager/user_manager.h" |
| 16 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 18 #include "mojo/public/cpp/bindings/binding.h" | 20 #include "mojo/public/cpp/bindings/binding.h" |
| 19 | 21 |
| 20 class Profile; | 22 class Profile; |
| 23 class PrefChangeRegistrar; | |
| 21 | 24 |
| 22 namespace ash { | 25 namespace ash { |
| 23 enum class AddUserSessionPolicy; | 26 enum class AddUserSessionPolicy; |
| 24 } | 27 } |
| 25 | 28 |
| 26 namespace user_manager { | 29 namespace user_manager { |
| 27 class User; | 30 class User; |
| 28 } | 31 } |
| 29 | 32 |
| 30 // Updates session state etc to ash via SessionController interface and handles | 33 // Updates session state etc to ash via SessionController interface and handles |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 static void DoLockScreen(); | 93 static void DoLockScreen(); |
| 91 static void DoSwitchActiveUser(const AccountId& account_id); | 94 static void DoSwitchActiveUser(const AccountId& account_id); |
| 92 static void DoCycleActiveUser(ash::CycleUserDirection direction); | 95 static void DoCycleActiveUser(ash::CycleUserDirection direction); |
| 93 | 96 |
| 94 // Flushes the mojo pipe to ash. | 97 // Flushes the mojo pipe to ash. |
| 95 static void FlushForTesting(); | 98 static void FlushForTesting(); |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 FRIEND_TEST_ALL_PREFIXES(SessionControllerClientTest, SendUserSession); | 101 FRIEND_TEST_ALL_PREFIXES(SessionControllerClientTest, SendUserSession); |
| 99 FRIEND_TEST_ALL_PREFIXES(SessionControllerClientTest, SupervisedUser); | 102 FRIEND_TEST_ALL_PREFIXES(SessionControllerClientTest, SupervisedUser); |
| 103 FRIEND_TEST_ALL_PREFIXES(SessionControllerClientTest, UserPrefsChange); | |
| 100 | 104 |
| 101 // Called when the login profile is ready. | 105 // Called when the login profile is ready. |
| 102 void OnLoginUserProfilePrepared(Profile* profile); | 106 void OnLoginUserProfilePrepared(Profile* profile); |
| 103 | 107 |
| 104 // Sends the user session info for a given profile. | 108 // Sends the user session info for a given profile. |
| 105 void SendUserSessionForProfile(Profile* profile); | 109 void SendUserSessionForProfile(Profile* profile); |
| 106 | 110 |
| 107 // Connects to the |session_controller_| interface. | 111 // Connects to the |session_controller_| interface. |
| 108 void ConnectToSessionController(); | 112 void ConnectToSessionController(); |
| 109 | 113 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 123 ash::mojom::SessionControllerPtr session_controller_; | 127 ash::mojom::SessionControllerPtr session_controller_; |
| 124 | 128 |
| 125 // Whether the primary user session info is sent to ash. | 129 // Whether the primary user session info is sent to ash. |
| 126 bool primary_user_session_sent_ = false; | 130 bool primary_user_session_sent_ = false; |
| 127 | 131 |
| 128 // If the session is for a supervised user, the profile of that user. | 132 // If the session is for a supervised user, the profile of that user. |
| 129 // Chrome OS only supports a single supervised user in a session. | 133 // Chrome OS only supports a single supervised user in a session. |
| 130 Profile* supervised_user_profile_ = nullptr; | 134 Profile* supervised_user_profile_ = nullptr; |
| 131 | 135 |
| 132 content::NotificationRegistrar registrar_; | 136 content::NotificationRegistrar registrar_; |
| 137 std::vector<std::unique_ptr<PrefChangeRegistrar>> pref_change_registrars_; | |
|
James Cook
2017/05/08 21:49:59
nit: Comment that there is one per user. (And mayb
xiyuan
2017/05/08 22:27:39
Done.
| |
| 133 | 138 |
| 134 // Used to suppress duplicate IPCs to ash. | 139 // Used to suppress duplicate IPCs to ash. |
| 135 ash::mojom::SessionInfoPtr last_sent_session_info_; | 140 ash::mojom::SessionInfoPtr last_sent_session_info_; |
| 136 ash::mojom::UserSessionPtr last_sent_user_session_; | 141 ash::mojom::UserSessionPtr last_sent_user_session_; |
| 137 | 142 |
| 138 base::WeakPtrFactory<SessionControllerClient> weak_ptr_factory_; | 143 base::WeakPtrFactory<SessionControllerClient> weak_ptr_factory_; |
| 139 | 144 |
| 140 DISALLOW_COPY_AND_ASSIGN(SessionControllerClient); | 145 DISALLOW_COPY_AND_ASSIGN(SessionControllerClient); |
| 141 }; | 146 }; |
| 142 | 147 |
| 143 #endif // CHROME_BROWSER_UI_ASH_SESSION_CONTROLLER_CLIENT_H_ | 148 #endif // CHROME_BROWSER_UI_ASH_SESSION_CONTROLLER_CLIENT_H_ |
| OLD | NEW |