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/strings/string16.h"
12 #include "chrome/browser/chromeos/login/help_app_launcher.h"
13 #include "chrome/browser/chromeos/login/remove_user_delegate.h"
14 #include "chrome/browser/chromeos/login/user.h"
15 #include "chrome/browser/chromeos/login/user_manager.h"
16 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gfx/rect.h"
21 // TODO(nkostylev): Extract interface, create a BaseLoginDisplay class.
22 // An abstract class that defines login UI implementation.
23 class LoginDisplay : public RemoveUserDelegate {
25 // Sign in error IDs that require detailed error screen and not just
26 // a simple error bubble.
28 // Shown in case of critical TPM error.
34 // Cancels current password changed flow.
35 virtual void CancelPasswordChangedFlow() = 0;
37 // Create new Google account.
38 virtual void CreateAccount() = 0;
40 // Complete sign process with specified |user_context|.
41 // Used for new users authenticated through an extension.
42 virtual void CompleteLogin(const UserContext& user_context) = 0;
44 // Returns name of the currently connected network.
45 virtual string16 GetConnectedNetworkName() = 0;
47 // Returns true if sign in is in progress.
48 virtual bool IsSigninInProgress() const = 0;
50 // Sign in using |username| and |password| specified.
51 // Used for known users only.
52 virtual void Login(const UserContext& user_context) = 0;
54 // Sign in as a retail mode user.
55 virtual void LoginAsRetailModeUser() = 0;
57 // Sign in into guest session.
58 virtual void LoginAsGuest() = 0;
60 // Decrypt cryptohome using user provided |old_password|
61 // and migrate to new password.
62 virtual void MigrateUserData(const std::string& old_password) = 0;
64 // Sign in into the public account identified by |username|.
65 virtual void LoginAsPublicAccount(const std::string& username) = 0;
67 // Login to kiosk mode for app with |app_id|.
68 virtual void LoginAsKioskApp(const std::string& app_id) = 0;
70 // Notify the delegate when the sign-in UI is finished loading.
71 virtual void OnSigninScreenReady() = 0;
73 // Called when existing user pod is selected in the UI.
74 virtual void OnUserSelected(const std::string& username) = 0;
76 // Called when the user requests enterprise enrollment.
77 virtual void OnStartEnterpriseEnrollment() = 0;
79 // Called when the user requests kiosk enable screen.
80 virtual void OnStartKioskEnableScreen() = 0;
82 // Called when the user requests device reset.
83 virtual void OnStartDeviceReset() = 0;
85 // Called when the owner permission for kiosk app auto launch is requested.
86 virtual void OnStartKioskAutolaunchScreen() = 0;
88 // Shows wrong HWID screen.
89 virtual void ShowWrongHWIDScreen() = 0;
91 // Restarts the public-session auto-login timer if it is running.
92 virtual void ResetPublicSessionAutoLoginTimer() = 0;
94 // Ignore password change, remove existing cryptohome and
95 // force full sync of user data.
96 virtual void ResyncUserData() = 0;
98 // Sets the displayed email for the next login attempt with |CompleteLogin|.
99 // If it succeeds, user's displayed email value will be updated to |email|.
100 virtual void SetDisplayEmail(const std::string& email) = 0;
102 // Sign out the currently signed in user.
103 // Used when the lock screen is being displayed.
104 virtual void Signout() = 0;
110 // |background_bounds| determines the bounds of login UI background.
111 LoginDisplay(Delegate* delegate, const gfx::Rect& background_bounds);
112 virtual ~LoginDisplay();
114 // Clears and enables fields on user pod or GAIA frame.
115 virtual void ClearAndEnablePassword() = 0;
117 // Initializes login UI with the user pods based on list of known users and
118 // guest, new user pods if those are enabled.
119 virtual void Init(const UserList& users,
122 bool show_new_user) = 0;
124 // Notifies the login UI that the preferences defining how to visualize it to
125 // the user have changed and it needs to refresh.
126 virtual void OnPreferencesChanged() = 0;
128 // Called when user image has been changed.
129 // |user| contains updated user.
130 virtual void OnUserImageChanged(const User& user) = 0;
132 // After this call login display should be ready to be smoothly destroyed
133 // (e.g. hide throbber, etc.).
134 virtual void OnFadeOut() = 0;
136 // Called when user is successfully authenticated.
137 virtual void OnLoginSuccess(const std::string& username) = 0;
139 // Changes enabled state of the UI.
140 virtual void SetUIEnabled(bool is_enabled) = 0;
142 // Selects user entry with specified |index|.
143 // Does nothing if current user is already selected.
144 virtual void SelectPod(int index) = 0;
146 // Displays simple error bubble with |error_msg_id| specified.
147 // |login_attempts| shows number of login attempts made by current user.
148 // |help_topic_id| is additional help topic that is presented as link.
149 virtual void ShowError(int error_msg_id,
151 HelpAppLauncher::HelpTopic help_topic_id) = 0;
153 // Displays detailed error screen for error with ID |error_id|.
154 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0;
156 // Proceed with Gaia flow because password has changed.
157 virtual void ShowGaiaPasswordChanged(const std::string& username) = 0;
159 // Show password changed dialog. If |show_password_error| is not null
160 // user already tried to enter old password but it turned out to be incorrect.
161 virtual void ShowPasswordChangedDialog(bool show_password_error) = 0;
163 // Shows signin UI with specified email.
164 virtual void ShowSigninUI(const std::string& email) = 0;
166 gfx::Rect background_bounds() const { return background_bounds_; }
167 void set_background_bounds(const gfx::Rect background_bounds){
168 background_bounds_ = background_bounds;
171 Delegate* delegate() { return delegate_; }
172 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
174 gfx::NativeWindow parent_window() const { return parent_window_; }
175 void set_parent_window(gfx::NativeWindow window) { parent_window_ = window; }
177 bool is_signin_completed() const { return is_signin_completed_; }
178 void set_signin_completed(bool value) { is_signin_completed_ = value; }
180 int width() const { return background_bounds_.width(); }
183 // Login UI delegate (controller).
186 // Parent window, might be used to create dialog windows.
187 gfx::NativeWindow parent_window_;
189 // Bounds of the login UI background.
190 gfx::Rect background_bounds_;
192 // True if signin for user has completed.
193 // TODO(nkostylev): Find a better place to store this state
194 // in redesigned login stack.
195 // Login stack (and this object) will be recreated for next user sign in.
196 bool is_signin_completed_;
198 DISALLOW_COPY_AND_ASSIGN(LoginDisplay);
201 } // namespace chromeos
203 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_H_