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