- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / login_display.h
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/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"
18
19 namespace chromeos {
20
21 // TODO(nkostylev): Extract interface, create a BaseLoginDisplay class.
22 // An abstract class that defines login UI implementation.
23 class LoginDisplay : public RemoveUserDelegate {
24  public:
25   // Sign in error IDs that require detailed error screen and not just
26   // a simple error bubble.
27   enum SigninError {
28     // Shown in case of critical TPM error.
29     TPM_ERROR,
30   };
31
32   class Delegate {
33    public:
34     // Cancels current password changed flow.
35     virtual void CancelPasswordChangedFlow() = 0;
36
37     // Create new Google account.
38     virtual void CreateAccount() = 0;
39
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;
43
44     // Returns name of the currently connected network.
45     virtual string16 GetConnectedNetworkName() = 0;
46
47     // Returns true if sign in is in progress.
48     virtual bool IsSigninInProgress() const = 0;
49
50     // Sign in using |username| and |password| specified.
51     // Used for known users only.
52     virtual void Login(const UserContext& user_context) = 0;
53
54     // Sign in as a retail mode user.
55     virtual void LoginAsRetailModeUser() = 0;
56
57     // Sign in into guest session.
58     virtual void LoginAsGuest() = 0;
59
60     // Decrypt cryptohome using user provided |old_password|
61     // and migrate to new password.
62     virtual void MigrateUserData(const std::string& old_password) = 0;
63
64     // Sign in into the public account identified by |username|.
65     virtual void LoginAsPublicAccount(const std::string& username) = 0;
66
67     // Login to kiosk mode for app with |app_id|.
68     virtual void LoginAsKioskApp(const std::string& app_id) = 0;
69
70     // Notify the delegate when the sign-in UI is finished loading.
71     virtual void OnSigninScreenReady() = 0;
72
73     // Called when existing user pod is selected in the UI.
74     virtual void OnUserSelected(const std::string& username) = 0;
75
76     // Called when the user requests enterprise enrollment.
77     virtual void OnStartEnterpriseEnrollment() = 0;
78
79     // Called when the user requests kiosk enable screen.
80     virtual void OnStartKioskEnableScreen() = 0;
81
82     // Called when the user requests device reset.
83     virtual void OnStartDeviceReset() = 0;
84
85     // Called when the owner permission for kiosk app auto launch is requested.
86     virtual void OnStartKioskAutolaunchScreen() = 0;
87
88     // Shows wrong HWID screen.
89     virtual void ShowWrongHWIDScreen() = 0;
90
91     // Restarts the public-session auto-login timer if it is running.
92     virtual void ResetPublicSessionAutoLoginTimer() = 0;
93
94     // Ignore password change, remove existing cryptohome and
95     // force full sync of user data.
96     virtual void ResyncUserData() = 0;
97
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;
101
102     // Sign out the currently signed in user.
103     // Used when the lock screen is being displayed.
104     virtual void Signout() = 0;
105
106    protected:
107     virtual ~Delegate();
108   };
109
110   // |background_bounds| determines the bounds of login UI background.
111   LoginDisplay(Delegate* delegate, const gfx::Rect& background_bounds);
112   virtual ~LoginDisplay();
113
114   // Clears and enables fields on user pod or GAIA frame.
115   virtual void ClearAndEnablePassword() = 0;
116
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,
120                     bool show_guest,
121                     bool show_users,
122                     bool show_new_user) = 0;
123
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;
127
128   // Called when user image has been changed.
129   // |user| contains updated user.
130   virtual void OnUserImageChanged(const User& user) = 0;
131
132   // After this call login display should be ready to be smoothly destroyed
133   // (e.g. hide throbber, etc.).
134   virtual void OnFadeOut() = 0;
135
136   // Called when user is successfully authenticated.
137   virtual void OnLoginSuccess(const std::string& username) = 0;
138
139   // Changes enabled state of the UI.
140   virtual void SetUIEnabled(bool is_enabled) = 0;
141
142   // Selects user entry with specified |index|.
143   // Does nothing if current user is already selected.
144   virtual void SelectPod(int index) = 0;
145
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,
150                          int login_attempts,
151                          HelpAppLauncher::HelpTopic help_topic_id) = 0;
152
153   // Displays detailed error screen for error with ID |error_id|.
154   virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0;
155
156   // Proceed with Gaia flow because password has changed.
157   virtual void ShowGaiaPasswordChanged(const std::string& username) = 0;
158
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;
162
163   // Shows signin UI with specified email.
164   virtual void ShowSigninUI(const std::string& email) = 0;
165
166   gfx::Rect background_bounds() const { return background_bounds_; }
167   void set_background_bounds(const gfx::Rect background_bounds){
168     background_bounds_ = background_bounds;
169   }
170
171   Delegate* delegate() { return delegate_; }
172   void set_delegate(Delegate* delegate) { delegate_ = delegate; }
173
174   gfx::NativeWindow parent_window() const { return parent_window_; }
175   void set_parent_window(gfx::NativeWindow window) { parent_window_ = window; }
176
177   bool is_signin_completed() const { return is_signin_completed_; }
178   void set_signin_completed(bool value) { is_signin_completed_ = value; }
179
180   int width() const { return background_bounds_.width(); }
181
182  protected:
183   // Login UI delegate (controller).
184   Delegate* delegate_;
185
186   // Parent window, might be used to create dialog windows.
187   gfx::NativeWindow parent_window_;
188
189   // Bounds of the login UI background.
190   gfx::Rect background_bounds_;
191
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_;
197
198   DISALLOW_COPY_AND_ASSIGN(LoginDisplay);
199 };
200
201 }  // namespace chromeos
202
203 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_DISPLAY_H_