OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
19 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 19 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
20 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 20 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
21 #include "chrome/browser/chromeos/login/ui/login_display.h" | 21 #include "chrome/browser/chromeos/login/ui/login_display.h" |
22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
23 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 23 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
24 #include "chromeos/login/auth/login_performer.h" | 24 #include "chromeos/login/auth/login_performer.h" |
25 #include "chromeos/login/auth/user_context.h" | 25 #include "chromeos/login/auth/user_context.h" |
26 #include "components/user_manager/user.h" | 26 #include "components/user_manager/user.h" |
| 27 #include "components/user_manager/user_id.h" |
27 #include "content/public/browser/notification_observer.h" | 28 #include "content/public/browser/notification_observer.h" |
28 #include "content/public/browser/notification_registrar.h" | 29 #include "content/public/browser/notification_registrar.h" |
29 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
31 | 32 |
32 namespace base { | 33 namespace base { |
33 class ListValue; | 34 class ListValue; |
34 } | 35 } |
35 | 36 |
36 namespace chromeos { | 37 namespace chromeos { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 bool password_changed() const; | 126 bool password_changed() const; |
126 | 127 |
127 private: | 128 private: |
128 friend class ExistingUserControllerTest; | 129 friend class ExistingUserControllerTest; |
129 friend class ExistingUserControllerAutoLoginTest; | 130 friend class ExistingUserControllerAutoLoginTest; |
130 friend class ExistingUserControllerPublicSessionTest; | 131 friend class ExistingUserControllerPublicSessionTest; |
131 friend class MockLoginPerformerDelegate; | 132 friend class MockLoginPerformerDelegate; |
132 | 133 |
133 void LoginAsGuest(); | 134 void LoginAsGuest(); |
134 void LoginAsPublicSession(const UserContext& user_context); | 135 void LoginAsPublicSession(const UserContext& user_context); |
135 void LoginAsKioskApp(const std::string& app_id, bool diagnostic_mode); | 136 void LoginAsKioskApp(const user_manager::UserID& user_id, bool diagnostic_mode
); |
136 | 137 |
137 // Retrieve public session auto-login policy and update the timer. | 138 // Retrieve public session auto-login policy and update the timer. |
138 void ConfigurePublicSessionAutoLogin(); | 139 void ConfigurePublicSessionAutoLogin(); |
139 | 140 |
140 // Trigger public session auto-login. | 141 // Trigger public session auto-login. |
141 void OnPublicSessionAutoLoginTimerFire(); | 142 void OnPublicSessionAutoLoginTimerFire(); |
142 | 143 |
143 // LoginPerformer::Delegate implementation: | 144 // LoginPerformer::Delegate implementation: |
144 void OnAuthFailure(const AuthFailure& error) override; | 145 void OnAuthFailure(const AuthFailure& error) override; |
145 void OnAuthSuccess(const UserContext& user_context) override; | 146 void OnAuthSuccess(const UserContext& user_context) override; |
146 void OnOffTheRecordAuthSuccess() override; | 147 void OnOffTheRecordAuthSuccess() override; |
147 void OnPasswordChangeDetected() override; | 148 void OnPasswordChangeDetected() override; |
148 void WhiteListCheckFailed(const std::string& email) override; | 149 void WhiteListCheckFailed(const user_manager::UserID& user_id) override; |
149 void PolicyLoadFailed() override; | 150 void PolicyLoadFailed() override; |
150 void OnOnlineChecked(const std::string& username, bool success) override; | 151 void OnOnlineChecked(const user_manager::UserID& user_id, bool success) overri
de; |
151 | 152 |
152 // UserSessionManagerDelegate implementation: | 153 // UserSessionManagerDelegate implementation: |
153 void OnProfilePrepared(Profile* profile, bool browser_launched) override; | 154 void OnProfilePrepared(Profile* profile, bool browser_launched) override; |
154 | 155 |
155 // Called when device settings change. | 156 // Called when device settings change. |
156 void DeviceSettingsChanged(); | 157 void DeviceSettingsChanged(); |
157 | 158 |
158 // Returns corresponding native window. | 159 // Returns corresponding native window. |
159 gfx::NativeWindow GetNativeWindow() const; | 160 gfx::NativeWindow GetNativeWindow() const; |
160 | 161 |
161 // Show error message. |error_id| error message ID in resources. | 162 // Show error message. |error_id| error message ID in resources. |
162 // If |details| string is not empty, it specify additional error text | 163 // If |details| string is not empty, it specify additional error text |
163 // provided by authenticator, it is not localized. | 164 // provided by authenticator, it is not localized. |
164 void ShowError(int error_id, const std::string& details); | 165 void ShowError(int error_id, const std::string& details); |
165 | 166 |
166 // Shows Gaia page because password change was detected. | 167 // Shows Gaia page because password change was detected. |
167 void ShowGaiaPasswordChanged(const std::string& username); | 168 void ShowGaiaPasswordChanged(const user_manager::UserID& user_id); |
168 | 169 |
169 // Handles result of ownership check and starts enterprise or kiosk enrollment | 170 // Handles result of ownership check and starts enterprise or kiosk enrollment |
170 // if applicable. | 171 // if applicable. |
171 void OnEnrollmentOwnershipCheckCompleted( | 172 void OnEnrollmentOwnershipCheckCompleted( |
172 DeviceSettingsService::OwnershipStatus status); | 173 DeviceSettingsService::OwnershipStatus status); |
173 | 174 |
174 // Handles result of consumer kiosk configurability check and starts | 175 // Handles result of consumer kiosk configurability check and starts |
175 // enable kiosk screen if applicable. | 176 // enable kiosk screen if applicable. |
176 void OnConsumerKioskAutoLaunchCheckCompleted( | 177 void OnConsumerKioskAutoLaunchCheckCompleted( |
177 KioskAppManager::ConsumerKioskAutoLaunchStatus status); | 178 KioskAppManager::ConsumerKioskAutoLaunchStatus status); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 242 |
242 // Callback invoked when |oauth2_token_initializer_| has finished. | 243 // Callback invoked when |oauth2_token_initializer_| has finished. |
243 void OnOAuth2TokensFetched(bool success, const UserContext& user_context); | 244 void OnOAuth2TokensFetched(bool success, const UserContext& user_context); |
244 | 245 |
245 // Public session auto-login timer. | 246 // Public session auto-login timer. |
246 scoped_ptr<base::OneShotTimer<ExistingUserController> > auto_login_timer_; | 247 scoped_ptr<base::OneShotTimer<ExistingUserController> > auto_login_timer_; |
247 | 248 |
248 // Public session auto-login timeout, in milliseconds. | 249 // Public session auto-login timeout, in milliseconds. |
249 int public_session_auto_login_delay_; | 250 int public_session_auto_login_delay_; |
250 | 251 |
251 // Username for public session auto-login. | 252 // User id for public session auto-login. |
252 std::string public_session_auto_login_username_; | 253 user_manager::UserID public_session_auto_login_user_id_; |
253 | 254 |
254 // Used to execute login operations. | 255 // Used to execute login operations. |
255 scoped_ptr<LoginPerformer> login_performer_; | 256 scoped_ptr<LoginPerformer> login_performer_; |
256 | 257 |
257 // Delegate to forward all authentication status events to. | 258 // Delegate to forward all authentication status events to. |
258 // Tests can use this to receive authentication status events. | 259 // Tests can use this to receive authentication status events. |
259 AuthStatusConsumer* auth_status_consumer_; | 260 AuthStatusConsumer* auth_status_consumer_; |
260 | 261 |
261 // Username of the last login attempt. | 262 // Username of the last login attempt. |
262 std::string last_login_attempt_username_; | 263 user_manager::UserID last_login_attempt_user_id_; |
263 | 264 |
264 // OOBE/login display host. | 265 // OOBE/login display host. |
265 LoginDisplayHost* host_; | 266 LoginDisplayHost* host_; |
266 | 267 |
267 // Login UI implementation instance. | 268 // Login UI implementation instance. |
268 scoped_ptr<LoginDisplay> login_display_; | 269 scoped_ptr<LoginDisplay> login_display_; |
269 | 270 |
270 // Number of login attempts. Used to show help link when > 1 unsuccessful | 271 // Number of login attempts. Used to show help link when > 1 unsuccessful |
271 // logins for the same user. | 272 // logins for the same user. |
272 size_t num_login_attempts_; | 273 size_t num_login_attempts_; |
(...skipping 14 matching lines...) Expand all Loading... |
287 // The displayed email for the next login attempt set by |SetDisplayEmail|. | 288 // The displayed email for the next login attempt set by |SetDisplayEmail|. |
288 std::string display_email_; | 289 std::string display_email_; |
289 | 290 |
290 // Whether offline login attempt failed. | 291 // Whether offline login attempt failed. |
291 bool offline_failed_; | 292 bool offline_failed_; |
292 | 293 |
293 // Whether login attempt is running. | 294 // Whether login attempt is running. |
294 bool is_login_in_progress_; | 295 bool is_login_in_progress_; |
295 | 296 |
296 // Whether online login attempt succeeded. | 297 // Whether online login attempt succeeded. |
297 std::string online_succeeded_for_; | 298 user_manager::UserID online_succeeded_for_; |
298 | 299 |
299 // True if password has been changed for user who is completing sign in. | 300 // True if password has been changed for user who is completing sign in. |
300 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). | 301 // Set in OnLoginSuccess. Before that use LoginPerformer::password_changed(). |
301 bool password_changed_; | 302 bool password_changed_; |
302 | 303 |
303 // Set in OnLoginSuccess. Before that use LoginPerformer::auth_mode(). | 304 // Set in OnLoginSuccess. Before that use LoginPerformer::auth_mode(). |
304 // Initialized with AUTH_MODE_EXTENSION as more restricted mode. | 305 // Initialized with AUTH_MODE_EXTENSION as more restricted mode. |
305 LoginPerformer::AuthorizationMode auth_mode_; | 306 LoginPerformer::AuthorizationMode auth_mode_; |
306 // Whether the sign-in UI is finished loading. | 307 // Whether the sign-in UI is finished loading. |
307 bool signin_screen_ready_; | 308 bool signin_screen_ready_; |
(...skipping 27 matching lines...) Expand all Loading... |
335 | 336 |
336 // Factory of callbacks. | 337 // Factory of callbacks. |
337 base::WeakPtrFactory<ExistingUserController> weak_factory_; | 338 base::WeakPtrFactory<ExistingUserController> weak_factory_; |
338 | 339 |
339 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); | 340 DISALLOW_COPY_AND_ASSIGN(ExistingUserController); |
340 }; | 341 }; |
341 | 342 |
342 } // namespace chromeos | 343 } // namespace chromeos |
343 | 344 |
344 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ | 345 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EXISTING_USER_CONTROLLER_H_ |
OLD | NEW |