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