| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/webui/chromeos/login/gaia_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" |
| 6 | 6 |
| 7 #include "ash/common/system/chromeos/devicetype_utils.h" | 7 #include "ash/common/system/chromeos/devicetype_utils.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 int authentication_behavior = 0; | 81 int authentication_behavior = 0; |
| 82 CrosSettings::Get()->GetInteger(kLoginAuthenticationBehavior, | 82 CrosSettings::Get()->GetInteger(kLoginAuthenticationBehavior, |
| 83 &authentication_behavior); | 83 &authentication_behavior); |
| 84 if (authentication_behavior == | 84 if (authentication_behavior == |
| 85 em::LoginAuthenticationBehaviorProto::SAML_INTERSTITIAL) { | 85 em::LoginAuthenticationBehaviorProto::SAML_INTERSTITIAL) { |
| 86 if (email.empty()) | 86 if (email.empty()) |
| 87 return GAIA_SCREEN_MODE_SAML_INTERSTITIAL; | 87 return GAIA_SCREEN_MODE_SAML_INTERSTITIAL; |
| 88 | 88 |
| 89 // If there's a populated email, we must check first that this user is using | 89 // If there's a populated email, we must check first that this user is using |
| 90 // SAML in order to decide whether to show the interstitial page. | 90 // SAML in order to decide whether to show the interstitial page. |
| 91 const user_manager::User* user = | 91 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
| 92 user_manager::UserManager::Get()->FindUser( | 92 user_manager::known_user::GetAccountId( |
| 93 user_manager::known_user::GetAccountId(email, std::string())); | 93 email, std::string() /* gaia_id */, |
| 94 std::string() /* account_type */)); |
| 94 | 95 |
| 95 if (user && user->using_saml()) | 96 if (user && user->using_saml()) |
| 96 return GAIA_SCREEN_MODE_SAML_INTERSTITIAL; | 97 return GAIA_SCREEN_MODE_SAML_INTERSTITIAL; |
| 97 } | 98 } |
| 98 | 99 |
| 99 return GAIA_SCREEN_MODE_DEFAULT; | 100 return GAIA_SCREEN_MODE_DEFAULT; |
| 100 } | 101 } |
| 101 | 102 |
| 102 std::string GetEnterpriseDomain() { | 103 std::string GetEnterpriseDomain() { |
| 103 policy::BrowserPolicyConnectorChromeOS* connector = | 104 policy::BrowserPolicyConnectorChromeOS* connector = |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 IsOnline(captive_portal_status_) == IsOnline(previous_status) || | 400 IsOnline(captive_portal_status_) == IsOnline(previous_status) || |
| 400 disable_restrictive_proxy_check_for_test_ || | 401 disable_restrictive_proxy_check_for_test_ || |
| 401 GetCurrentScreen() != OobeScreen::SCREEN_GAIA_SIGNIN) | 402 GetCurrentScreen() != OobeScreen::SCREEN_GAIA_SIGNIN) |
| 402 return; | 403 return; |
| 403 | 404 |
| 404 LoadAuthExtension(true /* force */, false /* offline */); | 405 LoadAuthExtension(true /* force */, false /* offline */); |
| 405 } | 406 } |
| 406 | 407 |
| 407 void GaiaScreenHandler::HandleIdentifierEntered(const std::string& user_email) { | 408 void GaiaScreenHandler::HandleIdentifierEntered(const std::string& user_email) { |
| 408 if (!Delegate()->IsUserWhitelisted(user_manager::known_user::GetAccountId( | 409 if (!Delegate()->IsUserWhitelisted(user_manager::known_user::GetAccountId( |
| 409 user_email, std::string() /* gaia_id */))) | 410 user_email, std::string() /* gaia_id */, |
| 411 std::string() /* account_type */))) |
| 410 ShowWhitelistCheckFailedError(); | 412 ShowWhitelistCheckFailedError(); |
| 411 } | 413 } |
| 412 | 414 |
| 413 void GaiaScreenHandler::HandleAuthExtensionLoaded() { | 415 void GaiaScreenHandler::HandleAuthExtensionLoaded() { |
| 414 VLOG(1) << "Auth extension finished loading"; | 416 VLOG(1) << "Auth extension finished loading"; |
| 415 auth_extension_being_loaded_ = false; | 417 auth_extension_being_loaded_ = false; |
| 416 } | 418 } |
| 417 | 419 |
| 418 void GaiaScreenHandler::HandleWebviewLoadAborted( | 420 void GaiaScreenHandler::HandleWebviewLoadAborted( |
| 419 const std::string& error_reason_str) { | 421 const std::string& error_reason_str) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 444 | 446 |
| 445 LOG(ERROR) << "Gaia webview error: " << error_reason_str; | 447 LOG(ERROR) << "Gaia webview error: " << error_reason_str; |
| 446 NetworkError::ErrorReason error_reason = | 448 NetworkError::ErrorReason error_reason = |
| 447 NetworkError::ERROR_REASON_FRAME_ERROR; | 449 NetworkError::ERROR_REASON_FRAME_ERROR; |
| 448 frame_state_ = FRAME_STATE_ERROR; | 450 frame_state_ = FRAME_STATE_ERROR; |
| 449 UpdateState(error_reason); | 451 UpdateState(error_reason); |
| 450 } | 452 } |
| 451 | 453 |
| 452 AccountId GaiaScreenHandler::GetAccountId( | 454 AccountId GaiaScreenHandler::GetAccountId( |
| 453 const std::string& authenticated_email, | 455 const std::string& authenticated_email, |
| 454 const std::string& gaia_id) const { | 456 const std::string& gaia_id, |
| 457 const std::string& account_type) const { |
| 455 const std::string canonicalized_email = | 458 const std::string canonicalized_email = |
| 456 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email)); | 459 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email)); |
| 457 | 460 |
| 458 const AccountId account_id = | 461 const AccountId account_id = user_manager::known_user::GetAccountId( |
| 459 user_manager::known_user::GetAccountId(authenticated_email, gaia_id); | 462 authenticated_email, gaia_id, account_type); |
| 460 | 463 |
| 461 if (account_id.GetUserEmail() != canonicalized_email) { | 464 if (account_id.GetUserEmail() != canonicalized_email) { |
| 462 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail() | 465 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail() |
| 463 << "' authenticated by alias '" << canonicalized_email << "'."; | 466 << "' authenticated by alias '" << canonicalized_email << "'."; |
| 464 } | 467 } |
| 465 | 468 |
| 466 return account_id; | 469 return account_id; |
| 467 } | 470 } |
| 468 | 471 |
| 469 void GaiaScreenHandler::HandleCompleteAuthentication( | 472 void GaiaScreenHandler::HandleCompleteAuthentication( |
| 470 const std::string& gaia_id, | 473 const std::string& gaia_id, |
| 471 const std::string& email, | 474 const std::string& email, |
| 472 const std::string& password, | 475 const std::string& password, |
| 473 const std::string& auth_code, | 476 const std::string& auth_code, |
| 474 bool using_saml, | 477 bool using_saml, |
| 475 const std::string& gaps_cookie) { | 478 const std::string& gaps_cookie) { |
| 476 if (!Delegate()) | 479 if (!Delegate()) |
| 477 return; | 480 return; |
| 478 | 481 |
| 479 DCHECK(!email.empty()); | 482 DCHECK(!email.empty()); |
| 480 DCHECK(!gaia_id.empty()); | 483 DCHECK(!gaia_id.empty()); |
| 481 const std::string sanitized_email = gaia::SanitizeEmail(email); | 484 const std::string sanitized_email = gaia::SanitizeEmail(email); |
| 482 Delegate()->SetDisplayEmail(sanitized_email); | 485 Delegate()->SetDisplayEmail(sanitized_email); |
| 483 | 486 |
| 484 UserContext user_context(GetAccountId(email, gaia_id)); | 487 UserContext user_context(GetAccountId(email, gaia_id, AccountId::kGoogle)); |
| 485 user_context.SetKey(Key(password)); | 488 user_context.SetKey(Key(password)); |
| 486 user_context.SetAuthCode(auth_code); | 489 user_context.SetAuthCode(auth_code); |
| 487 user_context.SetAuthFlow(using_saml | 490 user_context.SetAuthFlow(using_saml |
| 488 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML | 491 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML |
| 489 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); | 492 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); |
| 490 user_context.SetGAPSCookie(gaps_cookie); | 493 user_context.SetGAPSCookie(gaps_cookie); |
| 491 Delegate()->CompleteLogin(user_context); | 494 Delegate()->CompleteLogin(user_context); |
| 492 } | 495 } |
| 493 | 496 |
| 494 void GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly( | 497 void GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 if (!Delegate()) | 562 if (!Delegate()) |
| 560 return; | 563 return; |
| 561 | 564 |
| 562 if (using_saml && !using_saml_api_) | 565 if (using_saml && !using_saml_api_) |
| 563 RecordSAMLScrapingVerificationResultInHistogram(true); | 566 RecordSAMLScrapingVerificationResultInHistogram(true); |
| 564 | 567 |
| 565 DCHECK(!typed_email.empty()); | 568 DCHECK(!typed_email.empty()); |
| 566 DCHECK(!gaia_id.empty()); | 569 DCHECK(!gaia_id.empty()); |
| 567 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); | 570 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); |
| 568 Delegate()->SetDisplayEmail(sanitized_email); | 571 Delegate()->SetDisplayEmail(sanitized_email); |
| 569 UserContext user_context(GetAccountId(typed_email, gaia_id)); | 572 UserContext user_context( |
| 573 GetAccountId(typed_email, gaia_id, AccountId::kGoogle)); |
| 570 user_context.SetKey(Key(password)); | 574 user_context.SetKey(Key(password)); |
| 571 user_context.SetAuthFlow(using_saml | 575 user_context.SetAuthFlow(using_saml |
| 572 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML | 576 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML |
| 573 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); | 577 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); |
| 574 Delegate()->CompleteLogin(user_context); | 578 Delegate()->CompleteLogin(user_context); |
| 575 | 579 |
| 576 if (test_expects_complete_login_) { | 580 if (test_expects_complete_login_) { |
| 577 VLOG(2) << "Complete test login for " << typed_email | 581 VLOG(2) << "Complete test login for " << typed_email |
| 578 << ", requested=" << test_user_; | 582 << ", requested=" << test_user_; |
| 579 | 583 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 gaia_silent_load_network_ != active_network_path)) { | 702 gaia_silent_load_network_ != active_network_path)) { |
| 699 // Network has changed. Force Gaia reload. | 703 // Network has changed. Force Gaia reload. |
| 700 gaia_silent_load_ = false; | 704 gaia_silent_load_ = false; |
| 701 } | 705 } |
| 702 | 706 |
| 703 // Note that LoadAuthExtension clears |populated_email_|. | 707 // Note that LoadAuthExtension clears |populated_email_|. |
| 704 if (populated_email_.empty()) { | 708 if (populated_email_.empty()) { |
| 705 Delegate()->LoadSigninWallpaper(); | 709 Delegate()->LoadSigninWallpaper(); |
| 706 } else { | 710 } else { |
| 707 Delegate()->LoadWallpaper(user_manager::known_user::GetAccountId( | 711 Delegate()->LoadWallpaper(user_manager::known_user::GetAccountId( |
| 708 populated_email_, std::string())); | 712 populated_email_, std::string() /* gaia_id */, |
| 713 std::string() /* account_type */)); |
| 709 } | 714 } |
| 710 | 715 |
| 711 input_method::InputMethodManager* imm = | 716 input_method::InputMethodManager* imm = |
| 712 input_method::InputMethodManager::Get(); | 717 input_method::InputMethodManager::Get(); |
| 713 | 718 |
| 714 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state = | 719 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state = |
| 715 imm->GetActiveIMEState()->Clone(); | 720 imm->GetActiveIMEState()->Clone(); |
| 716 imm->SetState(gaia_ime_state); | 721 imm->SetState(gaia_ime_state); |
| 717 | 722 |
| 718 // Set Least Recently Used input method for the user. | 723 // Set Least Recently Used input method for the user. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 bool GaiaScreenHandler::IsRestrictiveProxy() const { | 846 bool GaiaScreenHandler::IsRestrictiveProxy() const { |
| 842 return !disable_restrictive_proxy_check_for_test_ && | 847 return !disable_restrictive_proxy_check_for_test_ && |
| 843 !IsOnline(captive_portal_status_); | 848 !IsOnline(captive_portal_status_); |
| 844 } | 849 } |
| 845 | 850 |
| 846 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { | 851 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { |
| 847 disable_restrictive_proxy_check_for_test_ = true; | 852 disable_restrictive_proxy_check_for_test_ = true; |
| 848 } | 853 } |
| 849 | 854 |
| 850 } // namespace chromeos | 855 } // namespace chromeos |
| OLD | NEW |