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 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 5 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 ExistingUserController::ExistingUserController(LoginDisplayHost* host) | 136 ExistingUserController::ExistingUserController(LoginDisplayHost* host) |
137 : login_status_consumer_(NULL), | 137 : login_status_consumer_(NULL), |
138 host_(host), | 138 host_(host), |
139 login_display_(host_->CreateLoginDisplay(this)), | 139 login_display_(host_->CreateLoginDisplay(this)), |
140 num_login_attempts_(0), | 140 num_login_attempts_(0), |
141 cros_settings_(CrosSettings::Get()), | 141 cros_settings_(CrosSettings::Get()), |
142 weak_factory_(this), | 142 weak_factory_(this), |
143 offline_failed_(false), | 143 offline_failed_(false), |
144 is_login_in_progress_(false), | 144 is_login_in_progress_(false), |
145 password_changed_(false), | 145 password_changed_(false), |
146 do_auto_enrollment_(false) { | 146 do_auto_enrollment_(false), |
147 signin_screen_ready_(false) { | |
147 DCHECK(current_controller_ == NULL); | 148 DCHECK(current_controller_ == NULL); |
148 current_controller_ = this; | 149 current_controller_ = this; |
149 | 150 |
150 registrar_.Add(this, | 151 registrar_.Add(this, |
151 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 152 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
152 content::NotificationService::AllSources()); | 153 content::NotificationService::AllSources()); |
153 registrar_.Add(this, | 154 registrar_.Add(this, |
154 chrome::NOTIFICATION_USER_LIST_CHANGED, | 155 chrome::NOTIFICATION_USER_LIST_CHANGED, |
155 content::NotificationService::AllSources()); | 156 content::NotificationService::AllSources()); |
156 registrar_.Add(this, | 157 registrar_.Add(this, |
157 chrome::NOTIFICATION_AUTH_SUPPLIED, | 158 chrome::NOTIFICATION_AUTH_SUPPLIED, |
158 content::NotificationService::AllSources()); | 159 content::NotificationService::AllSources()); |
159 registrar_.Add(this, | 160 registrar_.Add(this, |
160 chrome::NOTIFICATION_SESSION_STARTED, | 161 chrome::NOTIFICATION_SESSION_STARTED, |
161 content::NotificationService::AllSources()); | 162 content::NotificationService::AllSources()); |
162 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); | 163 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); |
163 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); | 164 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); |
164 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); | 165 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); |
165 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); | 166 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); |
167 cros_settings_->AddSettingsObserver( | |
168 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
bartfab (slow)
2013/03/07 12:17:23
#include "chrome/browser/chromeos/settings/cros_se
dconnelly
2013/03/07 14:45:19
Done.
| |
169 this); | |
170 cros_settings_->AddSettingsObserver( | |
171 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
172 this); | |
166 } | 173 } |
167 | 174 |
168 void ExistingUserController::Init(const UserList& users) { | 175 void ExistingUserController::Init(const UserList& users) { |
169 time_init_ = base::Time::Now(); | 176 time_init_ = base::Time::Now(); |
170 UpdateLoginDisplay(users); | 177 UpdateLoginDisplay(users); |
178 ConfigurePublicSessionAutoLogin(); | |
171 | 179 |
172 LoginUtils::Get()->PrewarmAuthentication(); | 180 LoginUtils::Get()->PrewarmAuthentication(); |
173 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); | 181 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); |
174 } | 182 } |
175 | 183 |
176 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { | 184 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { |
177 bool show_users_on_signin; | 185 bool show_users_on_signin; |
178 UserList filtered_users; | 186 UserList filtered_users; |
179 | 187 |
180 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, | 188 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 const content::NotificationSource& source, | 238 const content::NotificationSource& source, |
231 const content::NotificationDetails& details) { | 239 const content::NotificationDetails& details) { |
232 if (type == chrome::NOTIFICATION_SESSION_STARTED) { | 240 if (type == chrome::NOTIFICATION_SESSION_STARTED) { |
233 // Stop listening to any notification once session has started. | 241 // Stop listening to any notification once session has started. |
234 // Sign in screen objects are marked for deletion with DeleteSoon so | 242 // Sign in screen objects are marked for deletion with DeleteSoon so |
235 // make sure no object would be used after session has started. | 243 // make sure no object would be used after session has started. |
236 // http://crbug.com/125276 | 244 // http://crbug.com/125276 |
237 registrar_.RemoveAll(); | 245 registrar_.RemoveAll(); |
238 return; | 246 return; |
239 } | 247 } |
248 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) { | |
249 const std::string setting = *content::Details<const std::string>( | |
250 details).ptr(); | |
251 if (setting == kAccountsPrefDeviceLocalAccountAutoLoginId || | |
252 setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay) { | |
253 ConfigurePublicSessionAutoLogin(); | |
254 } | |
255 } | |
240 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || | 256 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || |
241 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { | 257 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { |
242 if (host_ != NULL) { | 258 if (host_ != NULL) { |
243 // Signed settings or user list changed. Notify views and update them. | 259 // Signed settings or user list changed. Notify views and update them. |
244 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); | 260 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); |
245 return; | 261 return; |
246 } | 262 } |
247 } | 263 } |
248 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { | 264 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { |
249 // Possibly the user has authenticated against a proxy server and we might | 265 // Possibly the user has authenticated against a proxy server and we might |
(...skipping 29 matching lines...) Expand all Loading... | |
279 // ExistingUserController, private: | 295 // ExistingUserController, private: |
280 | 296 |
281 ExistingUserController::~ExistingUserController() { | 297 ExistingUserController::~ExistingUserController() { |
282 LoginUtils::Get()->DelegateDeleted(this); | 298 LoginUtils::Get()->DelegateDeleted(this); |
283 | 299 |
284 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, | 300 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, |
285 this); | 301 this); |
286 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); | 302 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); |
287 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); | 303 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); |
288 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); | 304 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); |
305 cros_settings_->RemoveSettingsObserver( | |
306 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
307 this); | |
308 cros_settings_->RemoveSettingsObserver( | |
309 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
310 this); | |
289 | 311 |
290 if (current_controller_ == this) { | 312 if (current_controller_ == this) { |
291 current_controller_ = NULL; | 313 current_controller_ = NULL; |
292 } else { | 314 } else { |
293 NOTREACHED() << "More than one controller are alive."; | 315 NOTREACHED() << "More than one controller are alive."; |
294 } | 316 } |
295 DCHECK(login_display_.get()); | 317 DCHECK(login_display_.get()); |
296 } | 318 } |
297 | 319 |
298 //////////////////////////////////////////////////////////////////////////////// | 320 //////////////////////////////////////////////////////////////////////////////// |
299 // ExistingUserController, LoginDisplay::Delegate implementation: | 321 // ExistingUserController, LoginDisplay::Delegate implementation: |
300 // | 322 // |
301 | 323 |
302 void ExistingUserController::CancelPasswordChangedFlow() { | 324 void ExistingUserController::CancelPasswordChangedFlow() { |
303 login_performer_.reset(NULL); | 325 login_performer_.reset(NULL); |
304 login_display_->SetUIEnabled(true); | 326 login_display_->SetUIEnabled(true); |
327 StartPublicSessionAutoLoginTimer(); | |
305 } | 328 } |
306 | 329 |
307 void ExistingUserController::CreateAccount() { | 330 void ExistingUserController::CreateAccount() { |
308 content::RecordAction(content::UserMetricsAction("Login.CreateAccount")); | 331 content::RecordAction(content::UserMetricsAction("Login.CreateAccount")); |
309 guest_mode_url_ = | 332 guest_mode_url_ = |
310 google_util::AppendGoogleLocaleParam(GURL(kCreateAccountURL)); | 333 google_util::AppendGoogleLocaleParam(GURL(kCreateAccountURL)); |
311 LoginAsGuest(); | 334 LoginAsGuest(); |
312 } | 335 } |
313 | 336 |
314 void ExistingUserController::CreateLocallyManagedUser( | 337 void ExistingUserController::CreateLocallyManagedUser( |
315 const string16& display_name, | 338 const string16& display_name, |
316 const std::string& password) { | 339 const std::string& password) { |
317 // TODO(nkostylev): Check that policy allows creation of such account type. | 340 // TODO(nkostylev): Check that policy allows creation of such account type. |
318 if (display_name.empty()) | 341 if (display_name.empty()) |
319 return; | 342 return; |
320 | 343 |
321 // Disable clicking on other windows. | 344 // Disable clicking on other windows. |
345 StopPublicSessionAutoLoginTimer(); | |
322 login_display_->SetUIEnabled(false); | 346 login_display_->SetUIEnabled(false); |
323 | 347 |
324 LoginPerformer::Delegate* delegate = this; | 348 LoginPerformer::Delegate* delegate = this; |
325 if (login_performer_delegate_.get()) | 349 if (login_performer_delegate_.get()) |
326 delegate = login_performer_delegate_.get(); | 350 delegate = login_performer_delegate_.get(); |
327 // Only one instance of LoginPerformer should exist at a time. | 351 // Only one instance of LoginPerformer should exist at a time. |
328 login_performer_.reset(NULL); | 352 login_performer_.reset(NULL); |
329 login_performer_.reset(new LoginPerformer(delegate)); | 353 login_performer_.reset(new LoginPerformer(delegate)); |
330 is_login_in_progress_ = true; | 354 is_login_in_progress_ = true; |
331 login_performer_-> | 355 login_performer_-> |
332 CreateLocallyManagedUser(display_name, password); | 356 CreateLocallyManagedUser(display_name, password); |
333 // TODO(nkostylev): A11y message. | 357 // TODO(nkostylev): A11y message. |
334 } | 358 } |
335 | 359 |
336 void ExistingUserController::CompleteLogin(const std::string& username, | 360 void ExistingUserController::CompleteLogin(const std::string& username, |
337 const std::string& password) { | 361 const std::string& password) { |
338 if (!host_) { | 362 if (!host_) { |
339 // Complete login event was generated already from UI. Ignore notification. | 363 // Complete login event was generated already from UI. Ignore notification. |
340 return; | 364 return; |
341 } | 365 } |
342 | 366 |
367 // Stop the auto-login timer when attempting login. | |
368 StopPublicSessionAutoLoginTimer(); | |
369 | |
343 // Disable UI while loading user profile. | 370 // Disable UI while loading user profile. |
344 login_display_->SetUIEnabled(false); | 371 login_display_->SetUIEnabled(false); |
345 | 372 |
346 if (!time_init_.is_null()) { | 373 if (!time_init_.is_null()) { |
347 base::TimeDelta delta = base::Time::Now() - time_init_; | 374 base::TimeDelta delta = base::Time::Now() - time_init_; |
348 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); | 375 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); |
349 time_init_ = base::Time(); // Reset to null. | 376 time_init_ = base::Time(); // Reset to null. |
350 } | 377 } |
351 | 378 |
352 host_->OnCompleteLogin(); | 379 host_->OnCompleteLogin(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 } | 416 } |
390 | 417 |
391 string16 ExistingUserController::GetConnectedNetworkName() { | 418 string16 ExistingUserController::GetConnectedNetworkName() { |
392 return GetCurrentNetworkName(); | 419 return GetCurrentNetworkName(); |
393 } | 420 } |
394 | 421 |
395 void ExistingUserController::Login(const std::string& username, | 422 void ExistingUserController::Login(const std::string& username, |
396 const std::string& password) { | 423 const std::string& password) { |
397 if (username.empty() || password.empty()) | 424 if (username.empty() || password.empty()) |
398 return; | 425 return; |
426 | |
427 // Stop the auto-login timer when attempting login. | |
428 StopPublicSessionAutoLoginTimer(); | |
429 | |
399 // Disable clicking on other windows. | 430 // Disable clicking on other windows. |
400 login_display_->SetUIEnabled(false); | 431 login_display_->SetUIEnabled(false); |
401 | 432 |
402 BootTimesLoader::Get()->RecordLoginAttempted(); | 433 BootTimesLoader::Get()->RecordLoginAttempted(); |
403 | 434 |
404 if (last_login_attempt_username_ != username) { | 435 if (last_login_attempt_username_ != username) { |
405 last_login_attempt_username_ = username; | 436 last_login_attempt_username_ = username; |
406 num_login_attempts_ = 0; | 437 num_login_attempts_ = 0; |
407 // Also reset state variables, which are used to determine password change. | 438 // Also reset state variables, which are used to determine password change. |
408 offline_failed_ = false; | 439 offline_failed_ = false; |
(...skipping 27 matching lines...) Expand all Loading... | |
436 UserManager::kLocallyManagedUserDomain) { | 467 UserManager::kLocallyManagedUserDomain) { |
437 login_performer_->LoginAsLocallyManagedUser(username, password); | 468 login_performer_->LoginAsLocallyManagedUser(username, password); |
438 } else { | 469 } else { |
439 login_performer_->PerformLogin(username, password, auth_mode); | 470 login_performer_->PerformLogin(username, password, auth_mode); |
440 } | 471 } |
441 accessibility::MaybeSpeak( | 472 accessibility::MaybeSpeak( |
442 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 473 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
443 } | 474 } |
444 | 475 |
445 void ExistingUserController::LoginAsRetailModeUser() { | 476 void ExistingUserController::LoginAsRetailModeUser() { |
477 // Stop the auto-login timer when attempting login. | |
478 StopPublicSessionAutoLoginTimer(); | |
479 | |
446 // Disable clicking on other windows. | 480 // Disable clicking on other windows. |
447 login_display_->SetUIEnabled(false); | 481 login_display_->SetUIEnabled(false); |
448 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once | 482 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once |
449 // the enterprise policy wiring is done for retail mode. | 483 // the enterprise policy wiring is done for retail mode. |
450 | 484 |
451 // Only one instance of LoginPerformer should exist at a time. | 485 // Only one instance of LoginPerformer should exist at a time. |
452 login_performer_.reset(NULL); | 486 login_performer_.reset(NULL); |
453 login_performer_.reset(new LoginPerformer(this)); | 487 login_performer_.reset(new LoginPerformer(this)); |
454 is_login_in_progress_ = true; | 488 is_login_in_progress_ = true; |
455 login_performer_->LoginRetailMode(); | 489 login_performer_->LoginRetailMode(); |
456 accessibility::MaybeSpeak( | 490 accessibility::MaybeSpeak( |
457 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); | 491 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); |
458 } | 492 } |
459 | 493 |
460 void ExistingUserController::LoginAsGuest() { | 494 void ExistingUserController::LoginAsGuest() { |
495 // Stop the auto-login timer when attempting login. | |
496 StopPublicSessionAutoLoginTimer(); | |
497 | |
461 // Disable clicking on other windows. | 498 // Disable clicking on other windows. |
462 login_display_->SetUIEnabled(false); | 499 login_display_->SetUIEnabled(false); |
463 | 500 |
464 CrosSettingsProvider::TrustedStatus status = | 501 CrosSettingsProvider::TrustedStatus status = |
465 cros_settings_->PrepareTrustedValues( | 502 cros_settings_->PrepareTrustedValues( |
466 base::Bind(&ExistingUserController::LoginAsGuest, | 503 base::Bind(&ExistingUserController::LoginAsGuest, |
467 weak_factory_.GetWeakPtr())); | 504 weak_factory_.GetWeakPtr())); |
468 // Must not proceed without signature verification. | 505 // Must not proceed without signature verification. |
469 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { | 506 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
470 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, | 507 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
471 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 508 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
472 // Reenable clicking on other windows and status area. | 509 // Reenable clicking on other windows and status area. |
473 login_display_->SetUIEnabled(true); | 510 login_display_->SetUIEnabled(true); |
511 StartPublicSessionAutoLoginTimer(); | |
474 display_email_.clear(); | 512 display_email_.clear(); |
475 return; | 513 return; |
476 } else if (status != CrosSettingsProvider::TRUSTED) { | 514 } else if (status != CrosSettingsProvider::TRUSTED) { |
477 // Value of AllowNewUser setting is still not verified. | 515 // Value of AllowNewUser setting is still not verified. |
478 // Another attempt will be invoked after verification completion. | 516 // Another attempt will be invoked after verification completion. |
479 return; | 517 return; |
480 } | 518 } |
481 | 519 |
482 bool allow_guest; | 520 bool allow_guest; |
483 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 521 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
484 if (!allow_guest) { | 522 if (!allow_guest) { |
485 // Disallowed. The UI should normally not show the guest pod but if for some | 523 // Disallowed. The UI should normally not show the guest pod but if for some |
486 // reason this has been made available to the user here is the time to tell | 524 // reason this has been made available to the user here is the time to tell |
487 // this nicely. | 525 // this nicely. |
488 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, | 526 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, |
489 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 527 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
490 // Reenable clicking on other windows and status area. | 528 // Reenable clicking on other windows and status area. |
491 login_display_->SetUIEnabled(true); | 529 login_display_->SetUIEnabled(true); |
530 StartPublicSessionAutoLoginTimer(); | |
492 display_email_.clear(); | 531 display_email_.clear(); |
493 return; | 532 return; |
494 } | 533 } |
495 | 534 |
496 // Only one instance of LoginPerformer should exist at a time. | 535 // Only one instance of LoginPerformer should exist at a time. |
497 login_performer_.reset(NULL); | 536 login_performer_.reset(NULL); |
498 login_performer_.reset(new LoginPerformer(this)); | 537 login_performer_.reset(new LoginPerformer(this)); |
499 is_login_in_progress_ = true; | 538 is_login_in_progress_ = true; |
500 login_performer_->LoginOffTheRecord(); | 539 login_performer_->LoginOffTheRecord(); |
501 accessibility::MaybeSpeak( | 540 accessibility::MaybeSpeak( |
502 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); | 541 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); |
503 } | 542 } |
504 | 543 |
505 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 544 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
506 // LoginPerformer instance has state of the user so it should exist. | 545 // LoginPerformer instance has state of the user so it should exist. |
507 if (login_performer_.get()) | 546 if (login_performer_.get()) |
508 login_performer_->RecoverEncryptedData(old_password); | 547 login_performer_->RecoverEncryptedData(old_password); |
509 } | 548 } |
510 | 549 |
511 void ExistingUserController::LoginAsPublicAccount( | 550 void ExistingUserController::LoginAsPublicAccount( |
512 const std::string& username) { | 551 const std::string& username) { |
552 // Stop the auto-login timer when attempting login. | |
553 StopPublicSessionAutoLoginTimer(); | |
554 | |
513 // Disable clicking on other windows. | 555 // Disable clicking on other windows. |
514 login_display_->SetUIEnabled(false); | 556 login_display_->SetUIEnabled(false); |
515 | 557 |
516 CrosSettingsProvider::TrustedStatus status = | 558 CrosSettingsProvider::TrustedStatus status = |
517 cros_settings_->PrepareTrustedValues( | 559 cros_settings_->PrepareTrustedValues( |
518 base::Bind(&ExistingUserController::LoginAsPublicAccount, | 560 base::Bind(&ExistingUserController::LoginAsPublicAccount, |
519 weak_factory_.GetWeakPtr(), | 561 weak_factory_.GetWeakPtr(), |
520 username)); | 562 username)); |
521 // If device policy is permanently unavailable, logging into public accounts | 563 // If device policy is permanently unavailable, logging into public accounts |
522 // is not possible. | 564 // is not possible. |
523 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { | 565 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
524 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, | 566 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
525 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 567 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
526 // Re-enable clicking on other windows. | 568 // Re-enable clicking on other windows. |
527 login_display_->SetUIEnabled(true); | 569 login_display_->SetUIEnabled(true); |
528 return; | 570 return; |
529 } | 571 } |
530 | 572 |
531 // If device policy is not verified yet, this function will be called again | 573 // If device policy is not verified yet, this function will be called again |
532 // when verification finishes. | 574 // when verification finishes. |
533 if (status != CrosSettingsProvider::TRUSTED) | 575 if (status != CrosSettingsProvider::TRUSTED) |
534 return; | 576 return; |
535 | 577 |
536 // If there is no public account with the given |username|, logging in is not | 578 // If there is no public account with the given |username|, logging in is not |
537 // possible. | 579 // possible. |
538 const User* user = UserManager::Get()->FindUser(username); | 580 const User* user = UserManager::Get()->FindUser(username); |
539 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { | 581 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { |
540 // Re-enable clicking on other windows. | 582 // Re-enable clicking on other windows. |
541 login_display_->SetUIEnabled(true); | 583 login_display_->SetUIEnabled(true); |
584 StartPublicSessionAutoLoginTimer(); | |
542 return; | 585 return; |
543 } | 586 } |
544 | 587 |
545 // Only one instance of LoginPerformer should exist at a time. | 588 // Only one instance of LoginPerformer should exist at a time. |
546 login_performer_.reset(NULL); | 589 login_performer_.reset(NULL); |
547 login_performer_.reset(new LoginPerformer(this)); | 590 login_performer_.reset(new LoginPerformer(this)); |
548 is_login_in_progress_ = true; | 591 is_login_in_progress_ = true; |
549 login_performer_->LoginAsPublicAccount(username); | 592 login_performer_->LoginAsPublicAccount(username); |
550 accessibility::MaybeSpeak( | 593 accessibility::MaybeSpeak( |
551 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); | 594 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
552 } | 595 } |
553 | 596 |
597 void ExistingUserController::OnSigninScreenReady() { | |
598 signin_screen_ready_ = true; | |
599 StartPublicSessionAutoLoginTimer(); | |
600 } | |
601 | |
554 void ExistingUserController::OnUserSelected(const std::string& username) { | 602 void ExistingUserController::OnUserSelected(const std::string& username) { |
555 login_performer_.reset(NULL); | 603 login_performer_.reset(NULL); |
556 num_login_attempts_ = 0; | 604 num_login_attempts_ = 0; |
557 } | 605 } |
558 | 606 |
559 void ExistingUserController::OnStartEnterpriseEnrollment() { | 607 void ExistingUserController::OnStartEnterpriseEnrollment() { |
560 DeviceSettingsService::Get()->GetOwnershipStatusAsync( | 608 DeviceSettingsService::Get()->GetOwnershipStatusAsync( |
561 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, | 609 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, |
562 weak_factory_.GetWeakPtr())); | 610 weak_factory_.GetWeakPtr())); |
563 } | 611 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); | 727 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); |
680 } else { | 728 } else { |
681 if (!is_known_user) | 729 if (!is_known_user) |
682 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); | 730 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); |
683 else | 731 else |
684 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 732 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
685 } | 733 } |
686 } | 734 } |
687 // Reenable clicking on other windows and status area. | 735 // Reenable clicking on other windows and status area. |
688 login_display_->SetUIEnabled(true); | 736 login_display_->SetUIEnabled(true); |
737 StartPublicSessionAutoLoginTimer(); | |
689 } | 738 } |
690 | 739 |
691 // Reset user flow to default, so that special flow will not affect next | 740 // Reset user flow to default, so that special flow will not affect next |
692 // attempt. | 741 // attempt. |
693 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); | 742 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); |
694 | 743 |
695 if (login_status_consumer_) | 744 if (login_status_consumer_) |
696 login_status_consumer_->OnLoginFailure(failure); | 745 login_status_consumer_->OnLoginFailure(failure); |
697 | 746 |
698 // Clear the recorded displayed email so it won't affect any future attempts. | 747 // Clear the recorded displayed email so it won't affect any future attempts. |
699 display_email_.clear(); | 748 display_email_.clear(); |
700 } | 749 } |
701 | 750 |
702 void ExistingUserController::OnLoginSuccess( | 751 void ExistingUserController::OnLoginSuccess( |
703 const std::string& username, | 752 const std::string& username, |
704 const std::string& password, | 753 const std::string& password, |
705 bool pending_requests, | 754 bool pending_requests, |
706 bool using_oauth) { | 755 bool using_oauth) { |
707 is_login_in_progress_ = false; | 756 is_login_in_progress_ = false; |
708 offline_failed_ = false; | 757 offline_failed_ = false; |
709 | 758 |
759 StopPublicSessionAutoLoginTimer(); | |
760 | |
710 bool has_cookies = | 761 bool has_cookies = |
711 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; | 762 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; |
712 | 763 |
713 // Login performer will be gone so cache this value to use | 764 // Login performer will be gone so cache this value to use |
714 // once profile is loaded. | 765 // once profile is loaded. |
715 password_changed_ = login_performer_->password_changed(); | 766 password_changed_ = login_performer_->password_changed(); |
716 | 767 |
717 // LoginPerformer instance will delete itself once online auth result is OK. | 768 // LoginPerformer instance will delete itself once online auth result is OK. |
718 // In case of failure it'll bring up ScreenLock and ask for | 769 // In case of failure it'll bring up ScreenLock and ask for |
719 // correct password/display error message. | 770 // correct password/display error message. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
825 // Reenable clicking on other windows and status area. | 876 // Reenable clicking on other windows and status area. |
826 login_display_->SetUIEnabled(true); | 877 login_display_->SetUIEnabled(true); |
827 login_display_->ShowSigninUI(email); | 878 login_display_->ShowSigninUI(email); |
828 | 879 |
829 if (login_status_consumer_) { | 880 if (login_status_consumer_) { |
830 login_status_consumer_->OnLoginFailure(LoginFailure( | 881 login_status_consumer_->OnLoginFailure(LoginFailure( |
831 LoginFailure::WHITELIST_CHECK_FAILED)); | 882 LoginFailure::WHITELIST_CHECK_FAILED)); |
832 } | 883 } |
833 | 884 |
834 display_email_.clear(); | 885 display_email_.clear(); |
886 | |
887 StartPublicSessionAutoLoginTimer(); | |
835 } | 888 } |
836 | 889 |
837 void ExistingUserController::PolicyLoadFailed() { | 890 void ExistingUserController::PolicyLoadFailed() { |
838 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); | 891 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); |
839 | 892 |
840 // Reenable clicking on other windows and status area. | 893 // Reenable clicking on other windows and status area. |
841 login_display_->SetUIEnabled(true); | 894 login_display_->SetUIEnabled(true); |
842 | 895 |
843 display_email_.clear(); | 896 display_email_.clear(); |
897 | |
898 // Policy load failure stops login attempts -- restart the timer. | |
899 StartPublicSessionAutoLoginTimer(); | |
844 } | 900 } |
845 | 901 |
846 void ExistingUserController::OnOnlineChecked(const std::string& username, | 902 void ExistingUserController::OnOnlineChecked(const std::string& username, |
847 bool success) { | 903 bool success) { |
848 if (success && last_login_attempt_username_ == username) { | 904 if (success && last_login_attempt_username_ == username) { |
849 online_succeeded_for_ = username; | 905 online_succeeded_for_ = username; |
850 // Wait for login attempt to end, if it hasn't yet. | 906 // Wait for login attempt to end, if it hasn't yet. |
851 if (offline_failed_ && !is_login_in_progress_) | 907 if (offline_failed_ && !is_login_in_progress_) |
852 ShowGaiaPasswordChanged(username); | 908 ShowGaiaPasswordChanged(username); |
853 } | 909 } |
854 } | 910 } |
855 | 911 |
856 //////////////////////////////////////////////////////////////////////////////// | 912 //////////////////////////////////////////////////////////////////////////////// |
857 // ExistingUserController, private: | 913 // ExistingUserController, private: |
858 | 914 |
859 void ExistingUserController::ActivateWizard(const std::string& screen_name) { | 915 void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
860 DictionaryValue* params = NULL; | 916 DictionaryValue* params = NULL; |
861 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { | 917 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { |
862 params = new DictionaryValue; | 918 params = new DictionaryValue; |
863 params->SetString("start_url", guest_mode_url_.spec()); | 919 params->SetString("start_url", guest_mode_url_.spec()); |
864 } | 920 } |
865 host_->StartWizard(screen_name, params); | 921 host_->StartWizard(screen_name, params); |
866 } | 922 } |
867 | 923 |
924 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | |
925 if (!cros_settings_->GetString( | |
926 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
927 &public_session_auto_login_username_)) { | |
928 public_session_auto_login_username_ = ""; | |
929 } | |
930 if (!cros_settings_->GetInteger( | |
931 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
932 &public_session_auto_login_delay_)) { | |
933 public_session_auto_login_delay_ = 0; | |
934 } | |
935 | |
936 if (!public_session_auto_login_username_.empty()) | |
937 StartPublicSessionAutoLoginTimer(); | |
938 else | |
939 StopPublicSessionAutoLoginTimer(); | |
940 } | |
941 | |
942 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { | |
943 // Only restart the auto-login timer if it's already running. | |
944 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { | |
945 StopPublicSessionAutoLoginTimer(); | |
946 StartPublicSessionAutoLoginTimer(); | |
947 } | |
948 } | |
949 | |
950 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { | |
951 CHECK(signin_screen_ready_ && | |
952 !is_login_in_progress_ && | |
953 !public_session_auto_login_username_.empty()); | |
954 LoginAsPublicAccount(public_session_auto_login_username_); | |
955 } | |
956 | |
957 void ExistingUserController::StopPublicSessionAutoLoginTimer() { | |
958 if (auto_login_timer_) | |
959 auto_login_timer_->Stop(); | |
960 } | |
961 | |
962 void ExistingUserController::StartPublicSessionAutoLoginTimer() { | |
963 if (!signin_screen_ready_ || | |
964 is_login_in_progress_ || | |
965 public_session_auto_login_username_.empty()) { | |
966 return; | |
967 } | |
968 | |
969 // Start the auto-login timer. | |
970 if (!auto_login_timer_) | |
971 auto_login_timer_.reset(new base::OneShotTimer<ExistingUserController>); | |
972 | |
973 auto_login_timer_->Start( | |
974 FROM_HERE, | |
975 base::TimeDelta::FromMilliseconds( | |
976 public_session_auto_login_delay_), | |
977 base::Bind( | |
978 &ExistingUserController::OnPublicSessionAutoLoginTimerFire, | |
979 weak_factory_.GetWeakPtr())); | |
980 } | |
981 | |
868 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { | 982 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
869 return host_->GetNativeWindow(); | 983 return host_->GetNativeWindow(); |
870 } | 984 } |
871 | 985 |
872 void ExistingUserController::InitializeStartUrls() const { | 986 void ExistingUserController::InitializeStartUrls() const { |
873 std::vector<std::string> start_urls; | 987 std::vector<std::string> start_urls; |
874 | 988 |
875 PrefService* prefs = g_browser_process->local_state(); | 989 PrefService* prefs = g_browser_process->local_state(); |
876 const base::ListValue *urls; | 990 const base::ListValue *urls; |
877 bool show_getstarted_guide = false; | 991 bool show_getstarted_guide = false; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1004 // changed. | 1118 // changed. |
1005 UserManager::Get()->SaveUserOAuthStatus( | 1119 UserManager::Get()->SaveUserOAuthStatus( |
1006 username, | 1120 username, |
1007 User::OAUTH2_TOKEN_STATUS_INVALID); | 1121 User::OAUTH2_TOKEN_STATUS_INVALID); |
1008 | 1122 |
1009 login_display_->SetUIEnabled(true); | 1123 login_display_->SetUIEnabled(true); |
1010 login_display_->ShowGaiaPasswordChanged(username); | 1124 login_display_->ShowGaiaPasswordChanged(username); |
1011 } | 1125 } |
1012 | 1126 |
1013 } // namespace chromeos | 1127 } // namespace chromeos |
OLD | NEW |