1 // Copyright (c) 2012 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_LOGIN_DISPLAY_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_H_
11 #include "base/callback.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/chromeos/login/help_app_launcher.h"
14 #include "chrome/browser/chromeos/login/remove_user_delegate.h"
15 #include "chrome/browser/chromeos/login/user.h"
16 #include "chrome/browser/chromeos/login/user_manager.h"
17 #include "ui/gfx/image/image.h"
18 #include "ui/gfx/native_widget_types.h"
19 #include "ui/gfx/rect.h"
23 // TODO(nkostylev): Extract interface, create a BaseLoginDisplay class.
24 // An abstract class that defines login UI implementation.
25 class LoginDisplay : public RemoveUserDelegate {
27 // Supported authentication types for login.
29 // Authenticates using the user's regular password.
32 // Authenticates by forced online GAIA sign in.
35 // Authenticates with a 4 digit numeric pin.
38 // Authenticates by clicking pod when it is focused.
42 // Sign in error IDs that require detailed error screen and not just
43 // a simple error bubble.
45 // Shown in case of critical TPM error.
51 // Cancels current password changed flow.
52 virtual void CancelPasswordChangedFlow() = 0;
54 // Create new Google account.
55 virtual void CreateAccount() = 0;
57 // Complete sign process with specified |user_context|.
58 // Used for new users authenticated through an extension.
59 virtual void CompleteLogin(const UserContext& user_context) = 0;
61 // Returns name of the currently connected network.
62 virtual base::string16 GetConnectedNetworkName() = 0;
64 // Returns true if sign in is in progress.
65 virtual bool IsSigninInProgress() const = 0;
67 // Sign in using |username| and |password| specified.
68 // Used for known users only.
69 virtual void Login(const UserContext& user_context) = 0;
71 // Sign in as a retail mode user.
72 virtual void LoginAsRetailModeUser() = 0;
74 // Sign in into guest session.
75 virtual void LoginAsGuest() = 0;
77 // Decrypt cryptohome using user provided |old_password|
78 // and migrate to new password.
79 virtual void MigrateUserData(const std::string& old_password) = 0;
81 // Sign in into the public account identified by |username|.
82 virtual void LoginAsPublicAccount(const std::string& username) = 0;
84 // Login to kiosk mode for app with |app_id|.
85 virtual void LoginAsKioskApp(const std::string& app_id,
86 bool diagnostic_mode) = 0;
88 // Notify the delegate when the sign-in UI is finished loading.
89 virtual void OnSigninScreenReady() = 0;
91 // Called when existing user pod is selected in the UI.
92 virtual void OnUserSelected(const std::string& username) = 0;
94 // Called when the user requests enterprise enrollment.
95 virtual void OnStartEnterpriseEnrollment() = 0;
97 // Called when the user requests kiosk enable screen.
98 virtual void OnStartKioskEnableScreen() = 0;
100 // Called when the owner permission for kiosk app auto launch is requested.
101 virtual void OnStartKioskAutolaunchScreen() = 0;
103 // Shows wrong HWID screen.
104 virtual void ShowWrongHWIDScreen() = 0;
106 // Restarts the public-session auto-login timer if it is running.
107 virtual void ResetPublicSessionAutoLoginTimer() = 0;
109 // Ignore password change, remove existing cryptohome and
110 // force full sync of user data.
111 virtual void ResyncUserData() = 0;
113 // Sets the displayed email for the next login attempt with |CompleteLogin|.
114 // If it succeeds, user's displayed email value will be updated to |email|.
115 virtual void SetDisplayEmail(const std::string& email) = 0;
117 // Sign out the currently signed in user.
118 // Used when the lock screen is being displayed.
119 virtual void Signout() = 0;
125 // |background_bounds| determines the bounds of login UI background.
126 LoginDisplay(Delegate* delegate, const gfx::Rect& background_bounds);
127 virtual ~LoginDisplay();
129 // Clears and enables fields on user pod or GAIA frame.
130 virtual void ClearAndEnablePassword() = 0;
132 // Initializes login UI with the user pods based on list of known users and
133 // guest, new user pods if those are enabled.
134 virtual void Init(const UserList& users,
137 bool show_new_user) = 0;
139 // Notifies the login UI that the preferences defining how to visualize it to
140 // the user have changed and it needs to refresh.
141 virtual void OnPreferencesChanged() = 0;
143 // Called when user image has been changed.
144 // |user| contains updated user.
145 virtual void OnUserImageChanged(const User& user) = 0;
147 // After this call login display should be ready to be smoothly destroyed
148 // (e.g. hide throbber, etc.).
149 virtual void OnFadeOut() = 0;
151 // Called when user is successfully authenticated.
152 virtual void OnLoginSuccess(const std::string& username) = 0;
154 // Changes enabled state of the UI.
155 virtual void SetUIEnabled(bool is_enabled) = 0;
157 // Selects user entry with specified |index|.
158 // Does nothing if current user is already selected.
159 virtual void SelectPod(int index) = 0;
161 // Displays a banner on the login screen containing |message|.
162 virtual void ShowBannerMessage(const std::string& message) = 0;
164 // Shows a button with an icon inside the user pod of |username|.
165 virtual void ShowUserPodButton(const std::string& username,
166 const std::string& iconURL,
167 const base::Closure& click_callback) = 0;
169 // Hides the user pod button for a user.
170 virtual void HideUserPodButton(const std::string& username) = 0;
172 // Set the authentication type to be used on the lock screen.
173 virtual void SetAuthType(const std::string& username,
175 const std::string& initial_value) = 0;
177 // Returns the authentication type used for |username|.
178 virtual AuthType GetAuthType(const std::string& username) const = 0;
180 // Displays simple error bubble with |error_msg_id| specified.
181 // |login_attempts| shows number of login attempts made by current user.
182 // |help_topic_id| is additional help topic that is presented as link.
183 virtual void ShowError(int error_msg_id,
185 HelpAppLauncher::HelpTopic help_topic_id) = 0;
187 // Displays detailed error screen for error with ID |error_id|.
188 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0;
190 // Proceed with Gaia flow because password has changed.
191 virtual void ShowGaiaPasswordChanged(const std::string& username) = 0;
193 // Show password changed dialog. If |show_password_error| is not null
194 // user already tried to enter old password but it turned out to be incorrect.
195 virtual void ShowPasswordChangedDialog(bool show_password_error) = 0;
197 // Shows signin UI with specified email.
198 virtual void ShowSigninUI(const std::string& email) = 0;
200 // Hides or shows login UI control bar with [Shut down] / [Add user] buttons.
201 virtual void ShowControlBar(bool show) = 0;
203 gfx::Rect background_bounds() const { return background_bounds_; }
204 void set_background_bounds(const gfx::Rect& background_bounds) {
205 background_bounds_ = background_bounds;
208 Delegate* delegate() { return delegate_; }
209 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
211 gfx::NativeWindow parent_window() const { return parent_window_; }
212 void set_parent_window(gfx::NativeWindow window) { parent_window_ = window; }
214 bool is_signin_completed() const { return is_signin_completed_; }
215 void set_signin_completed(bool value) { is_signin_completed_ = value; }
217 int width() const { return background_bounds_.width(); }
220 // Login UI delegate (controller).
223 // Parent window, might be used to create dialog windows.
224 gfx::NativeWindow parent_window_;
226 // Bounds of the login UI background.
227 gfx::Rect background_bounds_;
229 // True if signin for user has completed.
230 // TODO(nkostylev): Find a better place to store this state
231 // in redesigned login stack.
232 // Login stack (and this object) will be recreated for next user sign in.
233 bool is_signin_completed_;
235 DISALLOW_COPY_AND_ASSIGN(LoginDisplay);
238 } // namespace chromeos
240 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_H_