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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_
12 #include "base/compiler_specific.h"
13 #include "base/timer/timer.h"
14 #include "base/values.h"
15 #include "chrome/browser/chromeos/login/signin/token_handle_util.h"
16 #include "chrome/browser/chromeos/login/ui/login_display.h"
17 #include "chrome/browser/chromeos/login/ui/models/user_board_model.h"
18 #include "components/proximity_auth/screenlock_bridge.h"
19 #include "components/user_manager/user.h"
20 #include "components/user_manager/user_id.h"
21 #include "ui/base/user_activity/user_activity_observer.h"
23 class EasyUnlockService
;
27 class LoginDisplayWebUIHandler
;
30 // This class represents User Selection screen: user pod-based login screen.
31 class UserSelectionScreen
32 : public ui::UserActivityObserver
,
33 public proximity_auth::ScreenlockBridge::LockHandler
,
34 public UserBoardModel
{
36 explicit UserSelectionScreen(const std::string
& display_type
);
37 ~UserSelectionScreen() override
;
39 void SetLoginDisplayDelegate(LoginDisplay::Delegate
* login_display_delegate
);
40 void SetHandler(LoginDisplayWebUIHandler
* handler
);
41 void SetView(UserBoardView
* view
);
43 static const user_manager::UserList
PrepareUserListForSending(
44 const user_manager::UserList
& users
,
46 bool is_signin_to_add
);
49 virtual void Init(const user_manager::UserList
& users
, bool show_guest
);
50 const user_manager::UserList
& GetUsers() const;
51 void OnUserImageChanged(const user_manager::User
& user
);
52 void OnBeforeUserRemoved(const std::string
& username
);
53 void OnUserRemoved(const std::string
& username
);
55 void OnPasswordClearTimerExpired();
57 void HandleGetUsers();
58 void CheckUserStatus(const std::string
& user_id
);
60 // ui::UserActivityDetector implementation:
61 void OnUserActivity(const ui::Event
* event
) override
;
63 void InitEasyUnlock();
65 // proximity_auth::ScreenlockBridge::LockHandler implementation:
66 void ShowBannerMessage(const base::string16
& message
) override
;
67 void ShowUserPodCustomIcon(
68 const std::string
& user_email
,
69 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions
& icon
)
71 void HideUserPodCustomIcon(const std::string
& user_email
) override
;
73 void EnableInput() override
;
74 void SetAuthType(const std::string
& user_email
,
76 const base::string16
& auth_value
) override
;
77 AuthType
GetAuthType(const std::string
& user_email
) const override
;
78 ScreenType
GetScreenType() const override
;
80 void Unlock(const std::string
& user_email
) override
;
81 void AttemptEasySignin(const std::string
& user_email
,
82 const std::string
& secret
,
83 const std::string
& key_label
) override
;
85 // UserBoardModel implementation.
86 void SendUserList() override
;
87 void HardLockPod(const std::string
& user_id
) override
;
88 void AttemptEasyUnlock(const std::string
& user_id
) override
;
89 void RecordClickOnLockIcon(const std::string
& user_id
) override
;
91 // Fills |user_dict| with information about |user|.
92 static void FillUserDictionary(
93 user_manager::User
* user
,
95 bool is_signin_to_add
,
97 const std::vector
<std::string
>* public_session_recommended_locales
,
98 base::DictionaryValue
* user_dict
);
100 // Fills |user_dict| with |user| known preferences.
101 static void FillKnownUserPrefs(user_manager::User
* user
,
102 base::DictionaryValue
* user_dict
);
104 // Fills |user_dict| with |user| multi-profile related preferences.
105 static void FillMultiProfileUserPrefs(user_manager::User
* user
,
106 base::DictionaryValue
* user_dict
,
107 bool is_signin_to_add
);
109 // Determines if user auth status requires online sign in.
110 static bool ShouldForceOnlineSignIn(const user_manager::User
* user
);
113 LoginDisplayWebUIHandler
* handler_
;
114 LoginDisplay::Delegate
* login_display_delegate_
;
115 UserBoardView
* view_
;
117 // Map from public session user IDs to recommended locales set by policy.
118 typedef std::map
<std::string
, std::vector
<std::string
> >
119 PublicSessionRecommendedLocaleMap
;
120 PublicSessionRecommendedLocaleMap public_session_recommended_locales_
;
123 EasyUnlockService
* GetEasyUnlockServiceForUser(
124 const std::string
& user_id
) const;
126 void OnUserStatusChecked(const user_manager::UserID
& user_id
,
127 TokenHandleUtil::TokenHandleStatus status
);
129 // Whether to show guest login.
132 // Purpose of the screen (see constants in OobeUI).
133 const std::string display_type_
;
135 // Set of Users that are visible.
136 user_manager::UserList users_
;
138 // Map of usernames to their current authentication type. If a user is not
139 // contained in the map, it is using the default authentication type.
140 std::map
<std::string
, proximity_auth::ScreenlockBridge::LockHandler::AuthType
>
143 // Timer for measuring idle state duration before password clear.
144 base::OneShotTimer
<UserSelectionScreen
> password_clear_timer_
;
146 // Token handler util for checking user OAuth token status.
147 scoped_ptr
<TokenHandleUtil
> token_handle_util_
;
149 base::WeakPtrFactory
<UserSelectionScreen
> weak_factory_
;
151 DISALLOW_COPY_AND_ASSIGN(UserSelectionScreen
);
154 } // namespace chromeos
156 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_SELECTION_SCREEN_H_