Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc

Issue 2529103002: Add account_type into AccountId (Closed)
Patch Set: Fix MultiUserWindowManagerChromeOSTest.* Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(email, std::string() /* id */,
93 user_manager::known_user::GetAccountId(email, std::string())); 93 AccountType::UNKNOWN));
94 94
95 if (user && user->using_saml()) 95 if (user && user->using_saml())
96 return GAIA_SCREEN_MODE_SAML_INTERSTITIAL; 96 return GAIA_SCREEN_MODE_SAML_INTERSTITIAL;
97 } 97 }
98 98
99 return GAIA_SCREEN_MODE_DEFAULT; 99 return GAIA_SCREEN_MODE_DEFAULT;
100 } 100 }
101 101
102 std::string GetEnterpriseDomain() { 102 std::string GetEnterpriseDomain() {
103 policy::BrowserPolicyConnectorChromeOS* connector = 103 policy::BrowserPolicyConnectorChromeOS* connector =
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 IsOnline(captive_portal_status_) == IsOnline(previous_status) || 399 IsOnline(captive_portal_status_) == IsOnline(previous_status) ||
400 disable_restrictive_proxy_check_for_test_ || 400 disable_restrictive_proxy_check_for_test_ ||
401 GetCurrentScreen() != OobeScreen::SCREEN_GAIA_SIGNIN) 401 GetCurrentScreen() != OobeScreen::SCREEN_GAIA_SIGNIN)
402 return; 402 return;
403 403
404 LoadAuthExtension(true /* force */, false /* offline */); 404 LoadAuthExtension(true /* force */, false /* offline */);
405 } 405 }
406 406
407 void GaiaScreenHandler::HandleIdentifierEntered(const std::string& user_email) { 407 void GaiaScreenHandler::HandleIdentifierEntered(const std::string& user_email) {
408 if (!Delegate()->IsUserWhitelisted(user_manager::known_user::GetAccountId( 408 if (!Delegate()->IsUserWhitelisted(user_manager::known_user::GetAccountId(
409 user_email, std::string() /* gaia_id */))) 409 user_email, std::string() /* id */, AccountType::UNKNOWN)))
410 ShowWhitelistCheckFailedError(); 410 ShowWhitelistCheckFailedError();
411 } 411 }
412 412
413 void GaiaScreenHandler::HandleAuthExtensionLoaded() { 413 void GaiaScreenHandler::HandleAuthExtensionLoaded() {
414 VLOG(1) << "Auth extension finished loading"; 414 VLOG(1) << "Auth extension finished loading";
415 auth_extension_being_loaded_ = false; 415 auth_extension_being_loaded_ = false;
416 } 416 }
417 417
418 void GaiaScreenHandler::HandleWebviewLoadAborted( 418 void GaiaScreenHandler::HandleWebviewLoadAborted(
419 const std::string& error_reason_str) { 419 const std::string& error_reason_str) {
(...skipping 24 matching lines...) Expand all
444 444
445 LOG(ERROR) << "Gaia webview error: " << error_reason_str; 445 LOG(ERROR) << "Gaia webview error: " << error_reason_str;
446 NetworkError::ErrorReason error_reason = 446 NetworkError::ErrorReason error_reason =
447 NetworkError::ERROR_REASON_FRAME_ERROR; 447 NetworkError::ERROR_REASON_FRAME_ERROR;
448 frame_state_ = FRAME_STATE_ERROR; 448 frame_state_ = FRAME_STATE_ERROR;
449 UpdateState(error_reason); 449 UpdateState(error_reason);
450 } 450 }
451 451
452 AccountId GaiaScreenHandler::GetAccountId( 452 AccountId GaiaScreenHandler::GetAccountId(
453 const std::string& authenticated_email, 453 const std::string& authenticated_email,
454 const std::string& gaia_id) const { 454 const std::string& id,
455 const AccountType& account_type) const {
455 const std::string canonicalized_email = 456 const std::string canonicalized_email =
456 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email)); 457 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email));
457 458
458 const AccountId account_id = 459 const AccountId account_id = user_manager::known_user::GetAccountId(
459 user_manager::known_user::GetAccountId(authenticated_email, gaia_id); 460 authenticated_email, id, account_type);
460 461
461 if (account_id.GetUserEmail() != canonicalized_email) { 462 if (account_id.GetUserEmail() != canonicalized_email) {
462 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail() 463 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail()
463 << "' authenticated by alias '" << canonicalized_email << "'."; 464 << "' authenticated by alias '" << canonicalized_email << "'.";
464 } 465 }
465 466
466 return account_id; 467 return account_id;
467 } 468 }
468 469
469 void GaiaScreenHandler::HandleCompleteAuthentication( 470 void GaiaScreenHandler::HandleCompleteAuthentication(
470 const std::string& gaia_id, 471 const std::string& gaia_id,
471 const std::string& email, 472 const std::string& email,
472 const std::string& password, 473 const std::string& password,
473 const std::string& auth_code, 474 const std::string& auth_code,
474 bool using_saml, 475 bool using_saml,
475 const std::string& gaps_cookie) { 476 const std::string& gaps_cookie) {
476 if (!Delegate()) 477 if (!Delegate())
477 return; 478 return;
478 479
479 DCHECK(!email.empty()); 480 DCHECK(!email.empty());
480 DCHECK(!gaia_id.empty()); 481 DCHECK(!gaia_id.empty());
481 const std::string sanitized_email = gaia::SanitizeEmail(email); 482 const std::string sanitized_email = gaia::SanitizeEmail(email);
482 Delegate()->SetDisplayEmail(sanitized_email); 483 Delegate()->SetDisplayEmail(sanitized_email);
483 484
484 UserContext user_context(GetAccountId(email, gaia_id)); 485 UserContext user_context(GetAccountId(email, gaia_id, AccountType::GOOGLE));
485 user_context.SetKey(Key(password)); 486 user_context.SetKey(Key(password));
486 user_context.SetAuthCode(auth_code); 487 user_context.SetAuthCode(auth_code);
487 user_context.SetAuthFlow(using_saml 488 user_context.SetAuthFlow(using_saml
488 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML 489 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML
489 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); 490 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML);
490 user_context.SetGAPSCookie(gaps_cookie); 491 user_context.SetGAPSCookie(gaps_cookie);
491 Delegate()->CompleteLogin(user_context); 492 Delegate()->CompleteLogin(user_context);
492 } 493 }
493 494
494 void GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly( 495 void GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (!Delegate()) 560 if (!Delegate())
560 return; 561 return;
561 562
562 if (using_saml && !using_saml_api_) 563 if (using_saml && !using_saml_api_)
563 RecordSAMLScrapingVerificationResultInHistogram(true); 564 RecordSAMLScrapingVerificationResultInHistogram(true);
564 565
565 DCHECK(!typed_email.empty()); 566 DCHECK(!typed_email.empty());
566 DCHECK(!gaia_id.empty()); 567 DCHECK(!gaia_id.empty());
567 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); 568 const std::string sanitized_email = gaia::SanitizeEmail(typed_email);
568 Delegate()->SetDisplayEmail(sanitized_email); 569 Delegate()->SetDisplayEmail(sanitized_email);
569 UserContext user_context(GetAccountId(typed_email, gaia_id)); 570 UserContext user_context(
571 GetAccountId(typed_email, gaia_id, AccountType::GOOGLE));
570 user_context.SetKey(Key(password)); 572 user_context.SetKey(Key(password));
571 user_context.SetAuthFlow(using_saml 573 user_context.SetAuthFlow(using_saml
572 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML 574 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML
573 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); 575 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML);
574 Delegate()->CompleteLogin(user_context); 576 Delegate()->CompleteLogin(user_context);
575 577
576 if (test_expects_complete_login_) { 578 if (test_expects_complete_login_) {
577 VLOG(2) << "Complete test login for " << typed_email 579 VLOG(2) << "Complete test login for " << typed_email
578 << ", requested=" << test_user_; 580 << ", requested=" << test_user_;
579 581
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 gaia_silent_load_network_ != active_network_path)) { 700 gaia_silent_load_network_ != active_network_path)) {
699 // Network has changed. Force Gaia reload. 701 // Network has changed. Force Gaia reload.
700 gaia_silent_load_ = false; 702 gaia_silent_load_ = false;
701 } 703 }
702 704
703 // Note that LoadAuthExtension clears |populated_email_|. 705 // Note that LoadAuthExtension clears |populated_email_|.
704 if (populated_email_.empty()) { 706 if (populated_email_.empty()) {
705 Delegate()->LoadSigninWallpaper(); 707 Delegate()->LoadSigninWallpaper();
706 } else { 708 } else {
707 Delegate()->LoadWallpaper(user_manager::known_user::GetAccountId( 709 Delegate()->LoadWallpaper(user_manager::known_user::GetAccountId(
708 populated_email_, std::string())); 710 populated_email_, std::string() /* id */, AccountType::UNKNOWN));
709 } 711 }
710 712
711 input_method::InputMethodManager* imm = 713 input_method::InputMethodManager* imm =
712 input_method::InputMethodManager::Get(); 714 input_method::InputMethodManager::Get();
713 715
714 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state = 716 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state =
715 imm->GetActiveIMEState()->Clone(); 717 imm->GetActiveIMEState()->Clone();
716 imm->SetState(gaia_ime_state); 718 imm->SetState(gaia_ime_state);
717 719
718 // Set Least Recently Used input method for the user. 720 // Set Least Recently Used input method for the user.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 bool GaiaScreenHandler::IsRestrictiveProxy() const { 843 bool GaiaScreenHandler::IsRestrictiveProxy() const {
842 return !disable_restrictive_proxy_check_for_test_ && 844 return !disable_restrictive_proxy_check_for_test_ &&
843 !IsOnline(captive_portal_status_); 845 !IsOnline(captive_portal_status_);
844 } 846 }
845 847
846 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { 848 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() {
847 disable_restrictive_proxy_check_for_test_ = true; 849 disable_restrictive_proxy_check_for_test_ = true;
848 } 850 }
849 851
850 } // namespace chromeos 852 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698