Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | |
|
Nikita (slow)
2014/07/30 09:27:58
Would it be possible to encapsulate chrome/browser
bartfab (slow)
2014/08/04 13:46:49
I moved all policy-related code to a ChromeUserSel
| |
| 15 #include "chrome/browser/signin/screenlock_bridge.h" | 17 #include "chrome/browser/signin/screenlock_bridge.h" |
| 16 #include "components/user_manager/user.h" | 18 #include "components/user_manager/user.h" |
| 17 #include "ui/wm/core/user_activity_observer.h" | 19 #include "ui/wm/core/user_activity_observer.h" |
| 18 | 20 |
| 21 namespace policy { | |
| 22 class DeviceLocalAccountPolicyBroker; | |
| 23 } | |
| 24 | |
| 19 namespace chromeos { | 25 namespace chromeos { |
| 20 | 26 |
| 21 class LoginDisplayWebUIHandler; | 27 class LoginDisplayWebUIHandler; |
| 22 | 28 |
| 23 // This class represents User Selection screen: user pod-based login screen. | 29 // This class represents User Selection screen: user pod-based login screen. |
| 24 class UserSelectionScreen : public wm::UserActivityObserver { | 30 class UserSelectionScreen |
| 31 : public wm::UserActivityObserver, | |
| 32 public policy::DeviceLocalAccountPolicyService::Observer { | |
| 25 public: | 33 public: |
| 26 UserSelectionScreen(); | 34 UserSelectionScreen(); |
| 27 virtual ~UserSelectionScreen(); | 35 virtual ~UserSelectionScreen(); |
| 28 | 36 |
| 29 static const user_manager::UserList PrepareUserListForSending( | 37 static const user_manager::UserList PrepareUserListForSending( |
| 30 const user_manager::UserList& users, | 38 const user_manager::UserList& users, |
| 31 std::string owner, | 39 std::string owner, |
| 32 bool is_signin_to_add); | 40 bool is_signin_to_add); |
| 33 | 41 |
| 34 void SetHandler(LoginDisplayWebUIHandler* handler); | 42 void SetHandler(LoginDisplayWebUIHandler* handler); |
| 35 | 43 |
| 36 void Init(const user_manager::UserList& users, bool show_guest); | 44 void Init(const user_manager::UserList& users, bool show_guest); |
| 37 const user_manager::UserList& GetUsers() const; | 45 const user_manager::UserList& GetUsers() const; |
| 38 void OnUserImageChanged(const user_manager::User& user); | 46 void OnUserImageChanged(const user_manager::User& user); |
| 39 void OnBeforeUserRemoved(const std::string& username); | 47 void OnBeforeUserRemoved(const std::string& username); |
| 40 void OnUserRemoved(const std::string& username); | 48 void OnUserRemoved(const std::string& username); |
| 41 | 49 |
| 42 void OnPasswordClearTimerExpired(); | 50 void OnPasswordClearTimerExpired(); |
| 43 void SendUserList(); | 51 void SendUserList(); |
| 44 void HandleGetUsers(); | 52 void HandleGetUsers(); |
| 45 void SetAuthType(const std::string& username, | 53 void SetAuthType(const std::string& username, |
| 46 ScreenlockBridge::LockHandler::AuthType auth_type); | 54 ScreenlockBridge::LockHandler::AuthType auth_type); |
| 47 ScreenlockBridge::LockHandler::AuthType GetAuthType( | 55 ScreenlockBridge::LockHandler::AuthType GetAuthType( |
| 48 const std::string& username) const; | 56 const std::string& username) const; |
| 49 | 57 |
| 50 // wm::UserActivityDetector implementation: | 58 // wm::UserActivityDetector implementation: |
| 51 virtual void OnUserActivity(const ui::Event* event) OVERRIDE; | 59 virtual void OnUserActivity(const ui::Event* event) OVERRIDE; |
| 52 | 60 |
| 61 // policy::DeviceLocalAccountPolicyService::Observer implementation: | |
| 62 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; | |
| 63 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; | |
| 64 | |
| 53 // Fills |user_dict| with information about |user|. | 65 // Fills |user_dict| with information about |user|. |
| 54 static void FillUserDictionary( | 66 static void FillUserDictionary( |
| 55 user_manager::User* user, | 67 user_manager::User* user, |
| 56 bool is_owner, | 68 bool is_owner, |
| 57 bool is_signin_to_add, | 69 bool is_signin_to_add, |
| 58 ScreenlockBridge::LockHandler::AuthType auth_type, | 70 ScreenlockBridge::LockHandler::AuthType auth_type, |
| 59 base::DictionaryValue* user_dict); | 71 base::DictionaryValue* user_dict); |
| 60 | 72 |
| 61 // Determines if user auth status requires online sign in. | 73 // Determines if user auth status requires online sign in. |
| 62 static bool ShouldForceOnlineSignIn(const user_manager::User* user); | 74 static bool ShouldForceOnlineSignIn(const user_manager::User* user); |
| 63 | 75 |
| 64 private: | 76 private: |
| 77 // Check whether the display name set by policy for a public session has | |
| 78 // changed and if so, notify the UI. | |
| 79 void CheckForPublicSessionDisplayNameChange( | |
| 80 policy::DeviceLocalAccountPolicyBroker* broker); | |
| 81 | |
| 82 // Notify the UI that the display name for a public session has changed, | |
| 83 // taking the display name from the |User| owned by |UserManager|. | |
| 84 void SetPublicSessionDisplayName(const std::string& user_id); | |
| 85 | |
| 65 LoginDisplayWebUIHandler* handler_; | 86 LoginDisplayWebUIHandler* handler_; |
| 87 bool handler_initialized_; | |
| 88 | |
| 89 policy::DeviceLocalAccountPolicyService* device_local_account_policy_service_; | |
| 66 | 90 |
| 67 // Set of Users that are visible. | 91 // Set of Users that are visible. |
| 68 user_manager::UserList users_; | 92 user_manager::UserList users_; |
| 69 | 93 |
| 70 // Whether to show guest login. | 94 // Whether to show guest login. |
| 71 bool show_guest_; | 95 bool show_guest_; |
| 72 | 96 |
| 97 // Map from public session user IDs to their display names set by policy. | |
| 98 typedef std::map<std::string, std::string> DisplayNamesMap; | |
| 99 DisplayNamesMap public_session_display_names_; | |
| 100 | |
| 73 // Map of usernames to their current authentication type. If a user is not | 101 // Map of usernames to their current authentication type. If a user is not |
| 74 // contained in the map, it is using the default authentication type. | 102 // contained in the map, it is using the default authentication type. |
| 75 std::map<std::string, ScreenlockBridge::LockHandler::AuthType> | 103 std::map<std::string, ScreenlockBridge::LockHandler::AuthType> |
| 76 user_auth_type_map_; | 104 user_auth_type_map_; |
| 77 | 105 |
| 78 // Timer for measuring idle state duration before password clear. | 106 // Timer for measuring idle state duration before password clear. |
| 79 base::OneShotTimer<UserSelectionScreen> password_clear_timer_; | 107 base::OneShotTimer<UserSelectionScreen> password_clear_timer_; |
| 80 | 108 |
| 109 base::WeakPtrFactory<UserSelectionScreen> weak_factory_; | |
| 110 | |
| 81 DISALLOW_COPY_AND_ASSIGN(UserSelectionScreen); | 111 DISALLOW_COPY_AND_ASSIGN(UserSelectionScreen); |
| 82 }; | 112 }; |
| 83 | 113 |
| 84 } // namespace chromeos | 114 } // namespace chromeos |
| 85 | 115 |
| 86 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_ | 116 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_ |
| OLD | NEW |