| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 is_login_in_progress_ = true; | 327 is_login_in_progress_ = true; |
| 328 login_performer_->CompleteLogin(username, password); | 328 login_performer_->CompleteLogin(username, password); |
| 329 accessibility::MaybeSpeak( | 329 accessibility::MaybeSpeak( |
| 330 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 330 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void ExistingUserController::Login(const std::string& username, | 333 void ExistingUserController::Login(const std::string& username, |
| 334 const std::string& password) { | 334 const std::string& password) { |
| 335 if (username.empty() || password.empty()) | 335 if (username.empty() || password.empty()) |
| 336 return; | 336 return; |
| 337 SetStatusAreaEnabled(false); | |
| 338 // Disable clicking on other windows. | 337 // Disable clicking on other windows. |
| 339 login_display_->SetUIEnabled(false); | 338 login_display_->SetUIEnabled(false); |
| 340 | 339 |
| 341 // If the device is not owned yet, successfully logged in user will be owner. | 340 // If the device is not owned yet, successfully logged in user will be owner. |
| 342 is_owner_login_ = OwnershipService::GetSharedInstance()->GetStatus(true) == | 341 is_owner_login_ = OwnershipService::GetSharedInstance()->GetStatus(true) == |
| 343 OwnershipService::OWNERSHIP_NONE; | 342 OwnershipService::OWNERSHIP_NONE; |
| 344 | 343 |
| 345 BootTimesLoader::Get()->RecordLoginAttempted(); | 344 BootTimesLoader::Get()->RecordLoginAttempted(); |
| 346 | 345 |
| 347 if (last_login_attempt_username_ != username) { | 346 if (last_login_attempt_username_ != username) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 363 login_performer_.reset(NULL); | 362 login_performer_.reset(NULL); |
| 364 login_performer_.reset(new LoginPerformer(delegate)); | 363 login_performer_.reset(new LoginPerformer(delegate)); |
| 365 } | 364 } |
| 366 is_login_in_progress_ = true; | 365 is_login_in_progress_ = true; |
| 367 login_performer_->Login(username, password); | 366 login_performer_->Login(username, password); |
| 368 accessibility::MaybeSpeak( | 367 accessibility::MaybeSpeak( |
| 369 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 368 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
| 370 } | 369 } |
| 371 | 370 |
| 372 void ExistingUserController::LoginAsDemoUser() { | 371 void ExistingUserController::LoginAsDemoUser() { |
| 373 SetStatusAreaEnabled(false); | |
| 374 // Disable clicking on other windows. | 372 // Disable clicking on other windows. |
| 375 login_display_->SetUIEnabled(false); | 373 login_display_->SetUIEnabled(false); |
| 376 // TODO(rkc): Add a CHECK to make sure demo logins are allowed once | 374 // TODO(rkc): Add a CHECK to make sure demo logins are allowed once |
| 377 // the enterprise policy wiring is done for kiosk mode. | 375 // the enterprise policy wiring is done for kiosk mode. |
| 378 | 376 |
| 379 // Only one instance of LoginPerformer should exist at a time. | 377 // Only one instance of LoginPerformer should exist at a time. |
| 380 login_performer_.reset(NULL); | 378 login_performer_.reset(NULL); |
| 381 login_performer_.reset(new LoginPerformer(this)); | 379 login_performer_.reset(new LoginPerformer(this)); |
| 382 is_login_in_progress_ = true; | 380 is_login_in_progress_ = true; |
| 383 login_performer_->LoginDemoUser(); | 381 login_performer_->LoginDemoUser(); |
| 384 accessibility::MaybeSpeak( | 382 accessibility::MaybeSpeak( |
| 385 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); | 383 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); |
| 386 } | 384 } |
| 387 | 385 |
| 388 | 386 |
| 389 | 387 |
| 390 void ExistingUserController::LoginAsGuest() { | 388 void ExistingUserController::LoginAsGuest() { |
| 391 SetStatusAreaEnabled(false); | |
| 392 // Disable clicking on other windows. | 389 // Disable clicking on other windows. |
| 393 login_display_->SetUIEnabled(false); | 390 login_display_->SetUIEnabled(false); |
| 394 | 391 |
| 395 // Check allow_guest in case this call is fired from key accelerator. | 392 // Check allow_guest in case this call is fired from key accelerator. |
| 396 // Must not proceed without signature verification. | 393 // Must not proceed without signature verification. |
| 397 if (!cros_settings_->PrepareTrustedValues( | 394 if (!cros_settings_->PrepareTrustedValues( |
| 398 base::Bind(&ExistingUserController::LoginAsGuest, | 395 base::Bind(&ExistingUserController::LoginAsGuest, |
| 399 weak_factory_.GetWeakPtr()))) { | 396 weak_factory_.GetWeakPtr()))) { |
| 400 // Value of AllowGuest setting is still not verified. | 397 // Value of AllowGuest setting is still not verified. |
| 401 // Another attempt will be invoked again after verification completion. | 398 // Another attempt will be invoked again after verification completion. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); | 495 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); |
| 499 } else { | 496 } else { |
| 500 if (!is_known_user) | 497 if (!is_known_user) |
| 501 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); | 498 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); |
| 502 else | 499 else |
| 503 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 500 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
| 504 } | 501 } |
| 505 } | 502 } |
| 506 // Reenable clicking on other windows and status area. | 503 // Reenable clicking on other windows and status area. |
| 507 login_display_->SetUIEnabled(true); | 504 login_display_->SetUIEnabled(true); |
| 508 SetStatusAreaEnabled(true); | |
| 509 } | 505 } |
| 510 | 506 |
| 511 if (login_status_consumer_) | 507 if (login_status_consumer_) |
| 512 login_status_consumer_->OnLoginFailure(failure); | 508 login_status_consumer_->OnLoginFailure(failure); |
| 513 | 509 |
| 514 // Clear the recorded displayed email so it won't affect any future attempts. | 510 // Clear the recorded displayed email so it won't affect any future attempts. |
| 515 display_email_.clear(); | 511 display_email_.clear(); |
| 516 } | 512 } |
| 517 | 513 |
| 518 void ExistingUserController::OnLoginSuccess( | 514 void ExistingUserController::OnLoginSuccess( |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 login_status_consumer_->OnPasswordChangeDetected(); | 625 login_status_consumer_->OnPasswordChangeDetected(); |
| 630 | 626 |
| 631 display_email_.clear(); | 627 display_email_.clear(); |
| 632 } | 628 } |
| 633 | 629 |
| 634 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { | 630 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { |
| 635 ShowError(IDS_LOGIN_ERROR_WHITELIST, email); | 631 ShowError(IDS_LOGIN_ERROR_WHITELIST, email); |
| 636 | 632 |
| 637 // Reenable clicking on other windows and status area. | 633 // Reenable clicking on other windows and status area. |
| 638 login_display_->SetUIEnabled(true); | 634 login_display_->SetUIEnabled(true); |
| 639 SetStatusAreaEnabled(true); | |
| 640 | 635 |
| 641 display_email_.clear(); | 636 display_email_.clear(); |
| 642 } | 637 } |
| 643 | 638 |
| 644 void ExistingUserController::OnOnlineChecked(const std::string& username, | 639 void ExistingUserController::OnOnlineChecked(const std::string& username, |
| 645 bool success) { | 640 bool success) { |
| 646 if (success && last_login_attempt_username_ == username) { | 641 if (success && last_login_attempt_username_ == username) { |
| 647 online_succeeded_for_ = username; | 642 online_succeeded_for_ = username; |
| 648 // Wait for login attempt to end, if it hasn't yet. | 643 // Wait for login attempt to end, if it hasn't yet. |
| 649 if (offline_failed_ && !is_login_in_progress_) | 644 if (offline_failed_ && !is_login_in_progress_) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 customization->GetInitialStartPage(locale); | 735 customization->GetInitialStartPage(locale); |
| 741 if (!initial_start_page.empty()) | 736 if (!initial_start_page.empty()) |
| 742 start_urls.push_back(initial_start_page); | 737 start_urls.push_back(initial_start_page); |
| 743 customization->ApplyCustomization(); | 738 customization->ApplyCustomization(); |
| 744 } | 739 } |
| 745 | 740 |
| 746 for (size_t i = 0; i < start_urls.size(); ++i) | 741 for (size_t i = 0; i < start_urls.size(); ++i) |
| 747 CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); | 742 CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); |
| 748 } | 743 } |
| 749 | 744 |
| 750 void ExistingUserController::SetStatusAreaEnabled(bool enable) { | |
| 751 if (!host_) | |
| 752 return; | |
| 753 host_->SetStatusAreaEnabled(enable); | |
| 754 } | |
| 755 | |
| 756 void ExistingUserController::ShowError(int error_id, | 745 void ExistingUserController::ShowError(int error_id, |
| 757 const std::string& details) { | 746 const std::string& details) { |
| 758 // TODO(dpolukhin): show detailed error info. |details| string contains | 747 // TODO(dpolukhin): show detailed error info. |details| string contains |
| 759 // low level error info that is not localized and even is not user friendly. | 748 // low level error info that is not localized and even is not user friendly. |
| 760 // For now just ignore it because error_text contains all required information | 749 // For now just ignore it because error_text contains all required information |
| 761 // for end users, developers can see details string in Chrome logs. | 750 // for end users, developers can see details string in Chrome logs. |
| 762 VLOG(1) << details; | 751 VLOG(1) << details; |
| 763 HelpAppLauncher::HelpTopic help_topic_id; | 752 HelpAppLauncher::HelpTopic help_topic_id; |
| 764 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 753 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 765 bool is_offline = !network_library || !network_library->Connected(); | 754 bool is_offline = !network_library || !network_library->Connected(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 784 } | 773 } |
| 785 | 774 |
| 786 void ExistingUserController::ShowGaiaPasswordChanged( | 775 void ExistingUserController::ShowGaiaPasswordChanged( |
| 787 const std::string& username) { | 776 const std::string& username) { |
| 788 // Invalidate OAuth token, since it can't be correct after password is | 777 // Invalidate OAuth token, since it can't be correct after password is |
| 789 // changed. | 778 // changed. |
| 790 UserManager::Get()->SaveUserOAuthStatus(username, | 779 UserManager::Get()->SaveUserOAuthStatus(username, |
| 791 User::OAUTH_TOKEN_STATUS_INVALID); | 780 User::OAUTH_TOKEN_STATUS_INVALID); |
| 792 | 781 |
| 793 login_display_->SetUIEnabled(true); | 782 login_display_->SetUIEnabled(true); |
| 794 SetStatusAreaEnabled(true); | |
| 795 login_display_->ShowGaiaPasswordChanged(username); | 783 login_display_->ShowGaiaPasswordChanged(username); |
| 796 } | 784 } |
| 797 | 785 |
| 798 } // namespace chromeos | 786 } // namespace chromeos |
| OLD | NEW |