| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 string16 ExistingUserController::GetConnectedNetworkName() { | 170 string16 ExistingUserController::GetConnectedNetworkName() { |
| 171 return GetCurrentNetworkName(CrosLibrary::Get()->GetNetworkLibrary()); | 171 return GetCurrentNetworkName(CrosLibrary::Get()->GetNetworkLibrary()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ExistingUserController::FixCaptivePortal() { | 174 void ExistingUserController::FixCaptivePortal() { |
| 175 guest_mode_url_ = GURL(kCaptivePortalLaunchURL); | 175 guest_mode_url_ = GURL(kCaptivePortalLaunchURL); |
| 176 LoginAsGuest(); | 176 LoginAsGuest(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void ExistingUserController::SetDisplayEmail(const std::string& email) { |
| 180 display_email_ = email; |
| 181 } |
| 182 |
| 179 void ExistingUserController::CompleteLogin(const std::string& username, | 183 void ExistingUserController::CompleteLogin(const std::string& username, |
| 180 const std::string& password) { | 184 const std::string& password) { |
| 181 SetOwnerUserInCryptohome(); | 185 SetOwnerUserInCryptohome(); |
| 182 | 186 |
| 183 GaiaAuthConsumer::ClientLoginResult credentials; | 187 GaiaAuthConsumer::ClientLoginResult credentials; |
| 184 if (!login_performer_.get()) { | 188 if (!login_performer_.get()) { |
| 185 LoginPerformer::Delegate* delegate = this; | 189 LoginPerformer::Delegate* delegate = this; |
| 186 if (login_performer_delegate_.get()) | 190 if (login_performer_delegate_.get()) |
| 187 delegate = login_performer_delegate_.get(); | 191 delegate = login_performer_delegate_.get(); |
| 188 // Only one instance of LoginPerformer should exist at a time. | 192 // Only one instance of LoginPerformer should exist at a time. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 362 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
| 359 } | 363 } |
| 360 } | 364 } |
| 361 | 365 |
| 362 // Reenable clicking on other windows and status area. | 366 // Reenable clicking on other windows and status area. |
| 363 login_display_->SetUIEnabled(true); | 367 login_display_->SetUIEnabled(true); |
| 364 SetStatusAreaEnabled(true); | 368 SetStatusAreaEnabled(true); |
| 365 | 369 |
| 366 if (login_status_consumer_) | 370 if (login_status_consumer_) |
| 367 login_status_consumer_->OnLoginFailure(failure); | 371 login_status_consumer_->OnLoginFailure(failure); |
| 372 |
| 373 // Clear the recorded displayed email so it won't affect any future attempts. |
| 374 display_email_.clear(); |
| 368 } | 375 } |
| 369 | 376 |
| 370 void ExistingUserController::OnLoginSuccess( | 377 void ExistingUserController::OnLoginSuccess( |
| 371 const std::string& username, | 378 const std::string& username, |
| 372 const std::string& password, | 379 const std::string& password, |
| 373 const GaiaAuthConsumer::ClientLoginResult& credentials, | 380 const GaiaAuthConsumer::ClientLoginResult& credentials, |
| 374 bool pending_requests, | 381 bool pending_requests, |
| 375 bool using_oauth) { | 382 bool using_oauth) { |
| 376 bool known_user = UserManager::Get()->IsKnownUser(username); | 383 bool known_user = UserManager::Get()->IsKnownUser(username); |
| 377 bool login_only = | 384 bool login_only = |
| 378 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 385 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 379 switches::kLoginScreen) == WizardController::kLoginScreenName; | 386 switches::kLoginScreen) == WizardController::kLoginScreenName; |
| 380 ready_for_browser_launch_ = known_user || login_only; | 387 ready_for_browser_launch_ = known_user || login_only; |
| 381 | 388 |
| 382 two_factor_credentials_ = credentials.two_factor; | 389 two_factor_credentials_ = credentials.two_factor; |
| 383 | 390 |
| 384 bool has_cookies = | 391 bool has_cookies = |
| 385 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; | 392 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; |
| 386 | 393 |
| 387 // LoginPerformer instance will delete itself once online auth result is OK. | 394 // LoginPerformer instance will delete itself once online auth result is OK. |
| 388 // In case of failure it'll bring up ScreenLock and ask for | 395 // In case of failure it'll bring up ScreenLock and ask for |
| 389 // correct password/display error message. | 396 // correct password/display error message. |
| 390 // Even in case when following online,offline protocol and returning | 397 // Even in case when following online,offline protocol and returning |
| 391 // requests_pending = false, let LoginPerformer delete itself. | 398 // requests_pending = false, let LoginPerformer delete itself. |
| 392 login_performer_->set_delegate(NULL); | 399 login_performer_->set_delegate(NULL); |
| 393 ignore_result(login_performer_.release()); | 400 ignore_result(login_performer_.release()); |
| 394 | 401 |
| 395 // Will call OnProfilePrepared() in the end. | 402 // Will call OnProfilePrepared() in the end. |
| 396 LoginUtils::Get()->PrepareProfile(username, | 403 LoginUtils::Get()->PrepareProfile(username, |
| 404 display_email_, |
| 397 password, | 405 password, |
| 398 credentials, | 406 credentials, |
| 399 pending_requests, | 407 pending_requests, |
| 400 using_oauth, | 408 using_oauth, |
| 401 has_cookies, | 409 has_cookies, |
| 402 this); | 410 this); |
| 403 | 411 |
| 412 display_email_.clear(); |
| 404 | 413 |
| 405 // Notifiy LoginDisplay to allow it provide visual feedback to user. | 414 // Notifiy LoginDisplay to allow it provide visual feedback to user. |
| 406 login_display_->OnLoginSuccess(username); | 415 login_display_->OnLoginSuccess(username); |
| 407 } | 416 } |
| 408 | 417 |
| 409 void ExistingUserController::OnProfilePrepared(Profile* profile) { | 418 void ExistingUserController::OnProfilePrepared(Profile* profile) { |
| 410 // TODO(nkostylev): May add login UI implementation callback call. | 419 // TODO(nkostylev): May add login UI implementation callback call. |
| 411 if (!ready_for_browser_launch_) { | 420 if (!ready_for_browser_launch_) { |
| 412 // Add the appropriate first-login URL. | 421 // Add the appropriate first-login URL. |
| 413 std::vector<std::string> start_urls; | 422 std::vector<std::string> start_urls; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 // doing this. See http://crosbug.com/9115 http://crosbug.com/7792 | 524 // doing this. See http://crosbug.com/9115 http://crosbug.com/7792 |
| 516 PasswordChangedView* view = new PasswordChangedView(this, false); | 525 PasswordChangedView* view = new PasswordChangedView(this, false); |
| 517 views::Widget* window = browser::CreateViewsWindow(GetNativeWindow(), | 526 views::Widget* window = browser::CreateViewsWindow(GetNativeWindow(), |
| 518 view, | 527 view, |
| 519 STYLE_GENERIC); | 528 STYLE_GENERIC); |
| 520 window->SetAlwaysOnTop(true); | 529 window->SetAlwaysOnTop(true); |
| 521 window->Show(); | 530 window->Show(); |
| 522 | 531 |
| 523 if (login_status_consumer_) | 532 if (login_status_consumer_) |
| 524 login_status_consumer_->OnPasswordChangeDetected(credentials); | 533 login_status_consumer_->OnPasswordChangeDetected(credentials); |
| 534 |
| 535 display_email_.clear(); |
| 525 } | 536 } |
| 526 | 537 |
| 527 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { | 538 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { |
| 528 ShowError(IDS_LOGIN_ERROR_WHITELIST, email); | 539 ShowError(IDS_LOGIN_ERROR_WHITELIST, email); |
| 529 | 540 |
| 530 // Reenable clicking on other windows and status area. | 541 // Reenable clicking on other windows and status area. |
| 531 login_display_->SetUIEnabled(true); | 542 login_display_->SetUIEnabled(true); |
| 532 SetStatusAreaEnabled(true); | 543 SetStatusAreaEnabled(true); |
| 544 |
| 545 display_email_.clear(); |
| 533 } | 546 } |
| 534 | 547 |
| 535 //////////////////////////////////////////////////////////////////////////////// | 548 //////////////////////////////////////////////////////////////////////////////// |
| 536 // ExistingUserController, CaptchaView::Delegate implementation: | 549 // ExistingUserController, CaptchaView::Delegate implementation: |
| 537 // | 550 // |
| 538 | 551 |
| 539 void ExistingUserController::OnCaptchaEntered(const std::string& captcha) { | 552 void ExistingUserController::OnCaptchaEntered(const std::string& captcha) { |
| 540 login_performer_->set_captcha(captcha); | 553 login_performer_->set_captcha(captcha); |
| 541 } | 554 } |
| 542 | 555 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 std::string owner; | 632 std::string owner; |
| 620 cros_settings_->GetString(kDeviceOwner, &owner); | 633 cros_settings_->GetString(kDeviceOwner, &owner); |
| 621 cryptohomed->AsyncSetOwnerUser(owner, NULL); | 634 cryptohomed->AsyncSetOwnerUser(owner, NULL); |
| 622 | 635 |
| 623 // Do not invoke AsyncDoAutomaticFreeDiskSpaceControl(NULL) here | 636 // Do not invoke AsyncDoAutomaticFreeDiskSpaceControl(NULL) here |
| 624 // so it does not delay the following mount. Cleanup will be | 637 // so it does not delay the following mount. Cleanup will be |
| 625 // started in Cryptohomed by timer. | 638 // started in Cryptohomed by timer. |
| 626 } | 639 } |
| 627 | 640 |
| 628 } // namespace chromeos | 641 } // namespace chromeos |
| OLD | NEW |