| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 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" | |
| 20 | |
| 21 namespace chromeos { | |
| 22 | |
| 23 // TODO(nkostylev): Extract interface, create a BaseLoginDisplay class. | |
| 24 // An abstract class that defines login UI implementation. | |
| 25 class LoginDisplay : public RemoveUserDelegate { | |
| 26 public: | |
| 27 // Supported authentication types for login. | |
| 28 enum AuthType { | |
| 29 // Authenticates using the user's regular password. | |
| 30 OFFLINE_PASSWORD, | |
| 31 | |
| 32 // Authenticates by forced online GAIA sign in. | |
| 33 ONLINE_SIGN_IN, | |
| 34 | |
| 35 // Authenticates with a 4 digit numeric pin. | |
| 36 NUMERIC_PIN, | |
| 37 | |
| 38 // Authenticates by clicking pod when it is focused. | |
| 39 USER_CLICK, | |
| 40 }; | |
| 41 | |
| 42 // Sign in error IDs that require detailed error screen and not just | |
| 43 // a simple error bubble. | |
| 44 enum SigninError { | |
| 45 // Shown in case of critical TPM error. | |
| 46 TPM_ERROR, | |
| 47 }; | |
| 48 | |
| 49 class Delegate { | |
| 50 public: | |
| 51 // Cancels current password changed flow. | |
| 52 virtual void CancelPasswordChangedFlow() = 0; | |
| 53 | |
| 54 // Create new Google account. | |
| 55 virtual void CreateAccount() = 0; | |
| 56 | |
| 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; | |
| 60 | |
| 61 // Returns name of the currently connected network. | |
| 62 virtual base::string16 GetConnectedNetworkName() = 0; | |
| 63 | |
| 64 // Returns true if sign in is in progress. | |
| 65 virtual bool IsSigninInProgress() const = 0; | |
| 66 | |
| 67 // Sign in using |username| and |password| specified. | |
| 68 // Used for known users only. | |
| 69 virtual void Login(const UserContext& user_context) = 0; | |
| 70 | |
| 71 // Sign in as a retail mode user. | |
| 72 virtual void LoginAsRetailModeUser() = 0; | |
| 73 | |
| 74 // Sign in into guest session. | |
| 75 virtual void LoginAsGuest() = 0; | |
| 76 | |
| 77 // Decrypt cryptohome using user provided |old_password| | |
| 78 // and migrate to new password. | |
| 79 virtual void MigrateUserData(const std::string& old_password) = 0; | |
| 80 | |
| 81 // Sign in into the public account identified by |username|. | |
| 82 virtual void LoginAsPublicAccount(const std::string& username) = 0; | |
| 83 | |
| 84 // Login to kiosk mode for app with |app_id|. | |
| 85 virtual void LoginAsKioskApp(const std::string& app_id, | |
| 86 bool diagnostic_mode) = 0; | |
| 87 | |
| 88 // Notify the delegate when the sign-in UI is finished loading. | |
| 89 virtual void OnSigninScreenReady() = 0; | |
| 90 | |
| 91 // Called when existing user pod is selected in the UI. | |
| 92 virtual void OnUserSelected(const std::string& username) = 0; | |
| 93 | |
| 94 // Called when the user requests enterprise enrollment. | |
| 95 virtual void OnStartEnterpriseEnrollment() = 0; | |
| 96 | |
| 97 // Called when the user requests kiosk enable screen. | |
| 98 virtual void OnStartKioskEnableScreen() = 0; | |
| 99 | |
| 100 // Called when the owner permission for kiosk app auto launch is requested. | |
| 101 virtual void OnStartKioskAutolaunchScreen() = 0; | |
| 102 | |
| 103 // Shows wrong HWID screen. | |
| 104 virtual void ShowWrongHWIDScreen() = 0; | |
| 105 | |
| 106 // Restarts the public-session auto-login timer if it is running. | |
| 107 virtual void ResetPublicSessionAutoLoginTimer() = 0; | |
| 108 | |
| 109 // Ignore password change, remove existing cryptohome and | |
| 110 // force full sync of user data. | |
| 111 virtual void ResyncUserData() = 0; | |
| 112 | |
| 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; | |
| 116 | |
| 117 // Sign out the currently signed in user. | |
| 118 // Used when the lock screen is being displayed. | |
| 119 virtual void Signout() = 0; | |
| 120 | |
| 121 protected: | |
| 122 virtual ~Delegate(); | |
| 123 }; | |
| 124 | |
| 125 // |background_bounds| determines the bounds of login UI background. | |
| 126 LoginDisplay(Delegate* delegate, const gfx::Rect& background_bounds); | |
| 127 virtual ~LoginDisplay(); | |
| 128 | |
| 129 // Clears and enables fields on user pod or GAIA frame. | |
| 130 virtual void ClearAndEnablePassword() = 0; | |
| 131 | |
| 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, | |
| 135 bool show_guest, | |
| 136 bool show_users, | |
| 137 bool show_new_user) = 0; | |
| 138 | |
| 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; | |
| 142 | |
| 143 // Called when user image has been changed. | |
| 144 // |user| contains updated user. | |
| 145 virtual void OnUserImageChanged(const User& user) = 0; | |
| 146 | |
| 147 // After this call login display should be ready to be smoothly destroyed | |
| 148 // (e.g. hide throbber, etc.). | |
| 149 virtual void OnFadeOut() = 0; | |
| 150 | |
| 151 // Called when user is successfully authenticated. | |
| 152 virtual void OnLoginSuccess(const std::string& username) = 0; | |
| 153 | |
| 154 // Changes enabled state of the UI. | |
| 155 virtual void SetUIEnabled(bool is_enabled) = 0; | |
| 156 | |
| 157 // Selects user entry with specified |index|. | |
| 158 // Does nothing if current user is already selected. | |
| 159 virtual void SelectPod(int index) = 0; | |
| 160 | |
| 161 // Displays a banner on the login screen containing |message|. | |
| 162 virtual void ShowBannerMessage(const std::string& message) = 0; | |
| 163 | |
| 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; | |
| 168 | |
| 169 // Hides the user pod button for a user. | |
| 170 virtual void HideUserPodButton(const std::string& username) = 0; | |
| 171 | |
| 172 // Set the authentication type to be used on the lock screen. | |
| 173 virtual void SetAuthType(const std::string& username, | |
| 174 AuthType auth_type, | |
| 175 const std::string& initial_value) = 0; | |
| 176 | |
| 177 // Returns the authentication type used for |username|. | |
| 178 virtual AuthType GetAuthType(const std::string& username) const = 0; | |
| 179 | |
| 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, | |
| 184 int login_attempts, | |
| 185 HelpAppLauncher::HelpTopic help_topic_id) = 0; | |
| 186 | |
| 187 // Displays detailed error screen for error with ID |error_id|. | |
| 188 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0; | |
| 189 | |
| 190 // Proceed with Gaia flow because password has changed. | |
| 191 virtual void ShowGaiaPasswordChanged(const std::string& username) = 0; | |
| 192 | |
| 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; | |
| 196 | |
| 197 // Shows signin UI with specified email. | |
| 198 virtual void ShowSigninUI(const std::string& email) = 0; | |
| 199 | |
| 200 // Hides or shows login UI control bar with [Shut down] / [Add user] buttons. | |
| 201 virtual void ShowControlBar(bool show) = 0; | |
| 202 | |
| 203 gfx::Rect background_bounds() const { return background_bounds_; } | |
| 204 void set_background_bounds(const gfx::Rect& background_bounds) { | |
| 205 background_bounds_ = background_bounds; | |
| 206 } | |
| 207 | |
| 208 Delegate* delegate() { return delegate_; } | |
| 209 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | |
| 210 | |
| 211 gfx::NativeWindow parent_window() const { return parent_window_; } | |
| 212 void set_parent_window(gfx::NativeWindow window) { parent_window_ = window; } | |
| 213 | |
| 214 bool is_signin_completed() const { return is_signin_completed_; } | |
| 215 void set_signin_completed(bool value) { is_signin_completed_ = value; } | |
| 216 | |
| 217 int width() const { return background_bounds_.width(); } | |
| 218 | |
| 219 protected: | |
| 220 // Login UI delegate (controller). | |
| 221 Delegate* delegate_; | |
| 222 | |
| 223 // Parent window, might be used to create dialog windows. | |
| 224 gfx::NativeWindow parent_window_; | |
| 225 | |
| 226 // Bounds of the login UI background. | |
| 227 gfx::Rect background_bounds_; | |
| 228 | |
| 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_; | |
| 234 | |
| 235 DISALLOW_COPY_AND_ASSIGN(LoginDisplay); | |
| 236 }; | |
| 237 | |
| 238 } // namespace chromeos | |
| 239 | |
| 240 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_H_ | |
| OLD | NEW |