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. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UI_LOGIN_DISPLAY_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_UI_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/signin_specifics.h" 15 #include "components/user_manager/remove_user_delegate.h" 16 #include "components/user_manager/user.h" 17 #include "components/user_manager/user_manager.h" 18 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/native_widget_types.h" 20 #include "ui/gfx/rect.h" 21 22 namespace chromeos { 23 24 class UserContext; 25 26 // TODO(nkostylev): Extract interface, create a BaseLoginDisplay class. 27 // An abstract class that defines login UI implementation. 28 class LoginDisplay : public user_manager::RemoveUserDelegate { 29 public: 30 // Sign in error IDs that require detailed error screen and not just 31 // a simple error bubble. 32 enum SigninError { 33 // Shown in case of critical TPM error. 34 TPM_ERROR, 35 }; 36 37 class Delegate { 38 public: 39 // Cancels current password changed flow. 40 virtual void CancelPasswordChangedFlow() = 0; 41 42 // Ignore password change, remove existing cryptohome and 43 // force full sync of user data. 44 virtual void ResyncUserData() = 0; 45 46 // Decrypt cryptohome using user provided |old_password| 47 // and migrate to new password. 48 virtual void MigrateUserData(const std::string& old_password) = 0; 49 50 // Sign in using |username| and |password| specified. 51 // Used for known users only. 52 virtual void Login(const UserContext& user_context, 53 const SigninSpecifics& specifics) = 0; 54 55 // Returns true if sign in is in progress. 56 virtual bool IsSigninInProgress() const = 0; 57 58 // Sign out the currently signed in user. 59 // Used when the lock screen is being displayed. 60 virtual void Signout() = 0; 61 62 // Create new Google account. 63 virtual void CreateAccount() = 0; 64 65 // Complete sign process with specified |user_context|. 66 // Used for new users authenticated through an extension. 67 virtual void CompleteLogin(const UserContext& user_context) = 0; 68 69 // Notify the delegate when the sign-in UI is finished loading. 70 virtual void OnSigninScreenReady() = 0; 71 72 // Called when the user requests enterprise enrollment. 73 virtual void OnStartEnterpriseEnrollment() = 0; 74 75 // Called when the user requests kiosk enable screen. 76 virtual void OnStartKioskEnableScreen() = 0; 77 78 // Called when the owner permission for kiosk app auto launch is requested. 79 virtual void OnStartKioskAutolaunchScreen() = 0; 80 81 // Shows wrong HWID screen. 82 virtual void ShowWrongHWIDScreen() = 0; 83 84 // Sets the displayed email for the next login attempt with |CompleteLogin|. 85 // If it succeeds, user's displayed email value will be updated to |email|. 86 virtual void SetDisplayEmail(const std::string& email) = 0; 87 88 // Returns name of the currently connected network, for error message, 89 virtual base::string16 GetConnectedNetworkName() = 0; 90 91 // Restarts the public-session auto-login timer if it is running. 92 virtual void ResetPublicSessionAutoLoginTimer() = 0; 93 94 protected: 95 virtual ~Delegate(); 96 }; 97 98 // |background_bounds| determines the bounds of login UI background. 99 LoginDisplay(Delegate* delegate, const gfx::Rect& background_bounds); 100 virtual ~LoginDisplay(); 101 102 // Clears and enables fields on user pod or GAIA frame. 103 virtual void ClearAndEnablePassword() = 0; 104 105 // Initializes login UI with the user pods based on list of known users and 106 // guest, new user pods if those are enabled. 107 virtual void Init(const user_manager::UserList& users, 108 bool show_guest, 109 bool show_users, 110 bool show_new_user) = 0; 111 112 // Notifies the login UI that the preferences defining how to visualize it to 113 // the user have changed and it needs to refresh. 114 virtual void OnPreferencesChanged() = 0; 115 116 // Called when user image has been changed. 117 // |user| contains updated user. 118 virtual void OnUserImageChanged(const user_manager::User& user) = 0; 119 120 // Changes enabled state of the UI. 121 virtual void SetUIEnabled(bool is_enabled) = 0; 122 123 // Displays simple error bubble with |error_msg_id| specified. 124 // |login_attempts| shows number of login attempts made by current user. 125 // |help_topic_id| is additional help topic that is presented as link. 126 virtual void ShowError(int error_msg_id, 127 int login_attempts, 128 HelpAppLauncher::HelpTopic help_topic_id) = 0; 129 130 // Displays detailed error screen for error with ID |error_id|. 131 virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0; 132 133 // Proceed with Gaia flow because password has changed. 134 virtual void ShowGaiaPasswordChanged(const std::string& username) = 0; 135 136 // Show password changed dialog. If |show_password_error| is not null 137 // user already tried to enter old password but it turned out to be incorrect. 138 virtual void ShowPasswordChangedDialog(bool show_password_error) = 0; 139 140 // Shows signin UI with specified email. 141 virtual void ShowSigninUI(const std::string& email) = 0; 142 background_bounds()143 gfx::Rect background_bounds() const { return background_bounds_; } set_background_bounds(const gfx::Rect & background_bounds)144 void set_background_bounds(const gfx::Rect& background_bounds) { 145 background_bounds_ = background_bounds; 146 } 147 delegate()148 Delegate* delegate() { return delegate_; } set_delegate(Delegate * delegate)149 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 150 parent_window()151 gfx::NativeWindow parent_window() const { return parent_window_; } set_parent_window(gfx::NativeWindow window)152 void set_parent_window(gfx::NativeWindow window) { parent_window_ = window; } 153 is_signin_completed()154 bool is_signin_completed() const { return is_signin_completed_; } set_signin_completed(bool value)155 void set_signin_completed(bool value) { is_signin_completed_ = value; } 156 width()157 int width() const { return background_bounds_.width(); } 158 159 protected: 160 // Login UI delegate (controller). 161 Delegate* delegate_; 162 163 // Parent window, might be used to create dialog windows. 164 gfx::NativeWindow parent_window_; 165 166 // Bounds of the login UI background. 167 gfx::Rect background_bounds_; 168 169 // True if signin for user has completed. 170 // TODO(nkostylev): Find a better place to store this state 171 // in redesigned login stack. 172 // Login stack (and this object) will be recreated for next user sign in. 173 bool is_signin_completed_; 174 175 DISALLOW_COPY_AND_ASSIGN(LoginDisplay); 176 }; 177 178 } // namespace chromeos 179 180 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_LOGIN_DISPLAY_H_ 181