| 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 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/chromeos/login/screens/base_screen.h" |
| 16 #include "chrome/browser/chromeos/login/signin/token_handle_util.h" | 17 #include "chrome/browser/chromeos/login/signin/token_handle_util.h" |
| 17 #include "chrome/browser/chromeos/login/ui/login_display.h" | 18 #include "chrome/browser/chromeos/login/ui/login_display.h" |
| 18 #include "chrome/browser/chromeos/login/ui/models/user_board_model.h" | |
| 19 #include "components/proximity_auth/screenlock_bridge.h" | 19 #include "components/proximity_auth/screenlock_bridge.h" |
| 20 #include "components/signin/core/account_id/account_id.h" | 20 #include "components/signin/core/account_id/account_id.h" |
| 21 #include "components/user_manager/user.h" | 21 #include "components/user_manager/user.h" |
| 22 #include "ui/base/user_activity/user_activity_observer.h" | 22 #include "ui/base/user_activity/user_activity_observer.h" |
| 23 | 23 |
| 24 class AccountId; | 24 class AccountId; |
| 25 class EasyUnlockService; | 25 class EasyUnlockService; |
| 26 | 26 |
| 27 namespace chromeos { | 27 namespace chromeos { |
| 28 | 28 |
| 29 class LoginDisplayWebUIHandler; | 29 class LoginDisplayWebUIHandler; |
| 30 class UserBoardView; | 30 class UserBoardView; |
| 31 | 31 |
| 32 // This class represents User Selection screen: user pod-based login screen. | 32 // This class represents User Selection screen: user pod-based login screen. |
| 33 class UserSelectionScreen | 33 class UserSelectionScreen |
| 34 : public ui::UserActivityObserver, | 34 : public ui::UserActivityObserver, |
| 35 public proximity_auth::ScreenlockBridge::LockHandler, | 35 public proximity_auth::ScreenlockBridge::LockHandler, |
| 36 public UserBoardModel { | 36 public BaseScreen { |
| 37 public: | 37 public: |
| 38 explicit UserSelectionScreen(const std::string& display_type); | 38 explicit UserSelectionScreen(const std::string& display_type); |
| 39 ~UserSelectionScreen() override; | 39 ~UserSelectionScreen() override; |
| 40 | 40 |
| 41 void SetLoginDisplayDelegate(LoginDisplay::Delegate* login_display_delegate); | 41 void SetLoginDisplayDelegate(LoginDisplay::Delegate* login_display_delegate); |
| 42 void SetHandler(LoginDisplayWebUIHandler* handler); | 42 void SetHandler(LoginDisplayWebUIHandler* handler); |
| 43 void SetView(UserBoardView* view); | 43 void SetView(UserBoardView* view); |
| 44 | 44 |
| 45 static const user_manager::UserList PrepareUserListForSending( | 45 static const user_manager::UserList PrepareUserListForSending( |
| 46 const user_manager::UserList& users, | 46 const user_manager::UserList& users, |
| 47 const AccountId& owner, | 47 const AccountId& owner, |
| 48 bool is_signin_to_add); | 48 bool is_signin_to_add); |
| 49 | 49 |
| 50 virtual void Init(const user_manager::UserList& users, bool show_guest); | 50 virtual void Init(const user_manager::UserList& users, bool show_guest); |
| 51 void OnUserImageChanged(const user_manager::User& user); | 51 void OnUserImageChanged(const user_manager::User& user); |
| 52 void OnBeforeUserRemoved(const AccountId& account_id); | 52 void OnBeforeUserRemoved(const AccountId& account_id); |
| 53 void OnUserRemoved(const AccountId& account_id); | 53 void OnUserRemoved(const AccountId& account_id); |
| 54 | 54 |
| 55 void OnPasswordClearTimerExpired(); | 55 void OnPasswordClearTimerExpired(); |
| 56 | 56 |
| 57 void HandleGetUsers(); | 57 void HandleGetUsers(); |
| 58 void CheckUserStatus(const AccountId& account_id); | 58 void CheckUserStatus(const AccountId& account_id); |
| 59 | 59 |
| 60 // Build list of users and send it to the webui. |
| 61 virtual void SendUserList(); |
| 62 |
| 63 // Methods for easy unlock support. |
| 64 void HardLockPod(const AccountId& account_id); |
| 65 void AttemptEasyUnlock(const AccountId& account_id); |
| 66 void RecordClickOnLockIcon(const AccountId& account_id); |
| 67 |
| 60 // ui::UserActivityDetector implementation: | 68 // ui::UserActivityDetector implementation: |
| 61 void OnUserActivity(const ui::Event* event) override; | 69 void OnUserActivity(const ui::Event* event) override; |
| 62 | 70 |
| 63 void InitEasyUnlock(); | 71 void InitEasyUnlock(); |
| 64 | 72 |
| 65 // proximity_auth::ScreenlockBridge::LockHandler implementation: | 73 // proximity_auth::ScreenlockBridge::LockHandler implementation: |
| 66 void ShowBannerMessage(const base::string16& message) override; | 74 void ShowBannerMessage(const base::string16& message) override; |
| 67 void ShowUserPodCustomIcon( | 75 void ShowUserPodCustomIcon( |
| 68 const AccountId& account_id, | 76 const AccountId& account_id, |
| 69 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon) | 77 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon) |
| 70 override; | 78 override; |
| 71 void HideUserPodCustomIcon(const AccountId& account_id) override; | 79 void HideUserPodCustomIcon(const AccountId& account_id) override; |
| 72 | 80 |
| 73 void EnableInput() override; | 81 void EnableInput() override; |
| 74 void SetAuthType(const AccountId& account_id, | 82 void SetAuthType(const AccountId& account_id, |
| 75 AuthType auth_type, | 83 AuthType auth_type, |
| 76 const base::string16& auth_value) override; | 84 const base::string16& auth_value) override; |
| 77 AuthType GetAuthType(const AccountId& account_id) const override; | 85 AuthType GetAuthType(const AccountId& account_id) const override; |
| 78 ScreenType GetScreenType() const override; | 86 ScreenType GetScreenType() const override; |
| 79 | 87 |
| 80 void Unlock(const AccountId& account_id) override; | 88 void Unlock(const AccountId& account_id) override; |
| 81 void AttemptEasySignin(const AccountId& account_id, | 89 void AttemptEasySignin(const AccountId& account_id, |
| 82 const std::string& secret, | 90 const std::string& secret, |
| 83 const std::string& key_label) override; | 91 const std::string& key_label) override; |
| 84 | 92 |
| 85 // UserBoardModel implementation. | 93 // BaseScreen implementation: |
| 86 void SendUserList() override; | 94 void Show() override; |
| 87 void HardLockPod(const AccountId& account_id) override; | 95 void Hide() override; |
| 88 void AttemptEasyUnlock(const AccountId& account_id) override; | |
| 89 void RecordClickOnLockIcon(const AccountId& account_id) override; | |
| 90 | 96 |
| 91 // Fills |user_dict| with information about |user|. | 97 // Fills |user_dict| with information about |user|. |
| 92 static void FillUserDictionary( | 98 static void FillUserDictionary( |
| 93 user_manager::User* user, | 99 user_manager::User* user, |
| 94 bool is_owner, | 100 bool is_owner, |
| 95 bool is_signin_to_add, | 101 bool is_signin_to_add, |
| 96 AuthType auth_type, | 102 AuthType auth_type, |
| 97 const std::vector<std::string>* public_session_recommended_locales, | 103 const std::vector<std::string>* public_session_recommended_locales, |
| 98 base::DictionaryValue* user_dict); | 104 base::DictionaryValue* user_dict); |
| 99 | 105 |
| 100 // Fills |user_dict| with |user| known preferences. | 106 // Fills |user_dict| with |user| known preferences. |
| 101 static void FillKnownUserPrefs(user_manager::User* user, | 107 static void FillKnownUserPrefs(user_manager::User* user, |
| 102 base::DictionaryValue* user_dict); | 108 base::DictionaryValue* user_dict); |
| 103 | 109 |
| 104 // Fills |user_dict| with |user| multi-profile related preferences. | 110 // Fills |user_dict| with |user| multi-profile related preferences. |
| 105 static void FillMultiProfileUserPrefs(user_manager::User* user, | 111 static void FillMultiProfileUserPrefs(user_manager::User* user, |
| 106 base::DictionaryValue* user_dict, | 112 base::DictionaryValue* user_dict, |
| 107 bool is_signin_to_add); | 113 bool is_signin_to_add); |
| 108 | 114 |
| 109 // Determines if user auth status requires online sign in. | 115 // Determines if user auth status requires online sign in. |
| 110 static bool ShouldForceOnlineSignIn(const user_manager::User* user); | 116 static bool ShouldForceOnlineSignIn(const user_manager::User* user); |
| 111 | 117 |
| 112 protected: | 118 protected: |
| 113 LoginDisplayWebUIHandler* handler_; | 119 UserBoardView* view_ = nullptr; |
| 114 LoginDisplay::Delegate* login_display_delegate_; | |
| 115 UserBoardView* view_; | |
| 116 | 120 |
| 117 // Map from public session account IDs to recommended locales set by policy. | 121 // Map from public session account IDs to recommended locales set by policy. |
| 118 typedef std::map<AccountId, std::vector<std::string> > | 122 std::map<AccountId, std::vector<std::string>> |
| 119 PublicSessionRecommendedLocaleMap; | 123 public_session_recommended_locales_; |
| 120 PublicSessionRecommendedLocaleMap public_session_recommended_locales_; | |
| 121 | 124 |
| 122 private: | 125 private: |
| 123 EasyUnlockService* GetEasyUnlockServiceForUser( | 126 EasyUnlockService* GetEasyUnlockServiceForUser( |
| 124 const AccountId& account_id) const; | 127 const AccountId& account_id) const; |
| 125 | 128 |
| 126 void OnUserStatusChecked(const AccountId& account_id, | 129 void OnUserStatusChecked(const AccountId& account_id, |
| 127 TokenHandleUtil::TokenHandleStatus status); | 130 TokenHandleUtil::TokenHandleStatus status); |
| 128 | 131 |
| 132 LoginDisplayWebUIHandler* handler_ = nullptr; |
| 133 LoginDisplay::Delegate* login_display_delegate_ = nullptr; |
| 134 |
| 129 // Whether to show guest login. | 135 // Whether to show guest login. |
| 130 bool show_guest_; | 136 bool show_guest_ = false; |
| 131 | 137 |
| 132 // Purpose of the screen (see constants in OobeUI). | 138 // Purpose of the screen (see constants in OobeUI). |
| 133 const std::string display_type_; | 139 const std::string display_type_; |
| 134 | 140 |
| 135 // Set of Users that are visible. | 141 // Set of Users that are visible. |
| 136 user_manager::UserList users_; | 142 user_manager::UserList users_; |
| 137 | 143 |
| 138 // Map of accounnt ids to their current authentication type. If a user is not | 144 // Map of accounnt ids to their current authentication type. If a user is not |
| 139 // contained in the map, it is using the default authentication type. | 145 // contained in the map, it is using the default authentication type. |
| 140 std::map<AccountId, proximity_auth::ScreenlockBridge::LockHandler::AuthType> | 146 std::map<AccountId, proximity_auth::ScreenlockBridge::LockHandler::AuthType> |
| 141 user_auth_type_map_; | 147 user_auth_type_map_; |
| 142 | 148 |
| 143 // Timer for measuring idle state duration before password clear. | 149 // Timer for measuring idle state duration before password clear. |
| 144 base::OneShotTimer password_clear_timer_; | 150 base::OneShotTimer password_clear_timer_; |
| 145 | 151 |
| 146 // Token handler util for checking user OAuth token status. | 152 // Token handler util for checking user OAuth token status. |
| 147 std::unique_ptr<TokenHandleUtil> token_handle_util_; | 153 std::unique_ptr<TokenHandleUtil> token_handle_util_; |
| 148 | 154 |
| 149 base::WeakPtrFactory<UserSelectionScreen> weak_factory_; | 155 base::WeakPtrFactory<UserSelectionScreen> weak_factory_; |
| 150 | 156 |
| 151 DISALLOW_COPY_AND_ASSIGN(UserSelectionScreen); | 157 DISALLOW_COPY_AND_ASSIGN(UserSelectionScreen); |
| 152 }; | 158 }; |
| 153 | 159 |
| 154 } // namespace chromeos | 160 } // namespace chromeos |
| 155 | 161 |
| 156 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_ | 162 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_ |
| OLD | NEW |