| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 337 |
| 338 if (!login_performer_.get()) { | 338 if (!login_performer_.get()) { |
| 339 LoginPerformer::Delegate* delegate = this; | 339 LoginPerformer::Delegate* delegate = this; |
| 340 if (login_performer_delegate_.get()) | 340 if (login_performer_delegate_.get()) |
| 341 delegate = login_performer_delegate_.get(); | 341 delegate = login_performer_delegate_.get(); |
| 342 // Only one instance of LoginPerformer should exist at a time. | 342 // Only one instance of LoginPerformer should exist at a time. |
| 343 login_performer_.reset(new LoginPerformer(delegate)); | 343 login_performer_.reset(new LoginPerformer(delegate)); |
| 344 } | 344 } |
| 345 | 345 |
| 346 // If the device is not owned yet, successfully logged in user will be owner. | 346 // If the device is not owned yet, successfully logged in user will be owner. |
| 347 is_owner_login_ = OwnershipService::GetSharedInstance()->GetStatus(true) == | 347 is_owner_login_ = DeviceSettingsService::Get()->GetOwnershipStatus(true) == |
| 348 OwnershipService::OWNERSHIP_NONE; | 348 DeviceSettingsService::OWNERSHIP_NONE; |
| 349 | 349 |
| 350 is_login_in_progress_ = true; | 350 is_login_in_progress_ = true; |
| 351 login_performer_->CompleteLogin(username, password); | 351 login_performer_->CompleteLogin(username, password); |
| 352 accessibility::MaybeSpeak( | 352 accessibility::MaybeSpeak( |
| 353 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 353 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void ExistingUserController::Login(const std::string& username, | 356 void ExistingUserController::Login(const std::string& username, |
| 357 const std::string& password) { | 357 const std::string& password) { |
| 358 if (username.empty() || password.empty()) | 358 if (username.empty() || password.empty()) |
| 359 return; | 359 return; |
| 360 // Disable clicking on other windows. | 360 // Disable clicking on other windows. |
| 361 login_display_->SetUIEnabled(false); | 361 login_display_->SetUIEnabled(false); |
| 362 | 362 |
| 363 // If the device is not owned yet, successfully logged in user will be owner. | 363 // If the device is not owned yet, successfully logged in user will be owner. |
| 364 is_owner_login_ = OwnershipService::GetSharedInstance()->GetStatus(true) == | 364 is_owner_login_ = DeviceSettingsService::Get()->GetOwnershipStatus(true) == |
| 365 OwnershipService::OWNERSHIP_NONE; | 365 DeviceSettingsService::OWNERSHIP_NONE; |
| 366 | 366 |
| 367 BootTimesLoader::Get()->RecordLoginAttempted(); | 367 BootTimesLoader::Get()->RecordLoginAttempted(); |
| 368 | 368 |
| 369 if (last_login_attempt_username_ != username) { | 369 if (last_login_attempt_username_ != username) { |
| 370 last_login_attempt_username_ = username; | 370 last_login_attempt_username_ = username; |
| 371 num_login_attempts_ = 0; | 371 num_login_attempts_ = 0; |
| 372 // Also reset state variables, which are used to determine password change. | 372 // Also reset state variables, which are used to determine password change. |
| 373 offline_failed_ = false; | 373 offline_failed_ = false; |
| 374 online_succeeded_for_.clear(); | 374 online_succeeded_for_.clear(); |
| 375 } | 375 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 456 } |
| 457 | 457 |
| 458 void ExistingUserController::OnUserSelected(const std::string& username) { | 458 void ExistingUserController::OnUserSelected(const std::string& username) { |
| 459 login_performer_.reset(NULL); | 459 login_performer_.reset(NULL); |
| 460 num_login_attempts_ = 0; | 460 num_login_attempts_ = 0; |
| 461 } | 461 } |
| 462 | 462 |
| 463 void ExistingUserController::OnStartEnterpriseEnrollment() { | 463 void ExistingUserController::OnStartEnterpriseEnrollment() { |
| 464 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 464 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 465 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { | 465 if (command_line->HasSwitch(switches::kEnableDevicePolicy)) { |
| 466 OwnershipService::GetSharedInstance()->GetStatusAsync( | 466 DeviceSettingsService::Get()->GetOwnershipStatusAsync( |
| 467 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, | 467 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, |
| 468 weak_factory_.GetWeakPtr())); | 468 weak_factory_.GetWeakPtr())); |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 void ExistingUserController::OnEnrollmentOwnershipCheckCompleted( | 472 void ExistingUserController::OnEnrollmentOwnershipCheckCompleted( |
| 473 OwnershipService::Status status, | 473 DeviceSettingsService::OwnershipStatus status, |
| 474 bool current_user_is_owner) { | 474 bool current_user_is_owner) { |
| 475 if (status == OwnershipService::OWNERSHIP_NONE) { | 475 if (status == DeviceSettingsService::OWNERSHIP_NONE) { |
| 476 ShowEnrollmentScreen(false, std::string()); | 476 ShowEnrollmentScreen(false, std::string()); |
| 477 } else if (status == OwnershipService::OWNERSHIP_TAKEN) { | 477 } else if (status == DeviceSettingsService::OWNERSHIP_TAKEN) { |
| 478 // On a device that is already owned we might want to allow users to | 478 // On a device that is already owned we might want to allow users to |
| 479 // re-enroll if the policy information is invalid. | 479 // re-enroll if the policy information is invalid. |
| 480 CrosSettingsProvider::TrustedStatus trusted_status = | 480 CrosSettingsProvider::TrustedStatus trusted_status = |
| 481 CrosSettings::Get()->PrepareTrustedValues( | 481 CrosSettings::Get()->PrepareTrustedValues( |
| 482 base::Bind( | 482 base::Bind( |
| 483 &ExistingUserController::OnEnrollmentOwnershipCheckCompleted, | 483 &ExistingUserController::OnEnrollmentOwnershipCheckCompleted, |
| 484 weak_factory_.GetWeakPtr(), status, current_user_is_owner)); | 484 weak_factory_.GetWeakPtr(), status, current_user_is_owner)); |
| 485 if (trusted_status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) | 485 if (trusted_status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) |
| 486 ShowEnrollmentScreen(false, std::string()); | 486 ShowEnrollmentScreen(false, std::string()); |
| 487 } else { | 487 } else { |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 // Invalidate OAuth token, since it can't be correct after password is | 920 // Invalidate OAuth token, since it can't be correct after password is |
| 921 // changed. | 921 // changed. |
| 922 UserManager::Get()->SaveUserOAuthStatus(username, | 922 UserManager::Get()->SaveUserOAuthStatus(username, |
| 923 User::OAUTH_TOKEN_STATUS_INVALID); | 923 User::OAUTH_TOKEN_STATUS_INVALID); |
| 924 | 924 |
| 925 login_display_->SetUIEnabled(true); | 925 login_display_->SetUIEnabled(true); |
| 926 login_display_->ShowGaiaPasswordChanged(username); | 926 login_display_->ShowGaiaPasswordChanged(username); |
| 927 } | 927 } |
| 928 | 928 |
| 929 } // namespace chromeos | 929 } // namespace chromeos |
| OLD | NEW |