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

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

Issue 2593133002: Revert of Add account_type into AccountId (Closed)
Patch Set: Created 4 years 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 = user_manager::UserManager::Get()->FindUser( 91 const user_manager::User* user =
92 user_manager::known_user::GetAccountId(email, std::string() /* id */, 92 user_manager::UserManager::Get()->FindUser(
93 AccountType::UNKNOWN)); 93 user_manager::known_user::GetAccountId(email, std::string()));
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() /* id */, AccountType::UNKNOWN))) 409 user_email, std::string() /* gaia_id */)))
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& id, 454 const std::string& gaia_id) const {
455 const AccountType& account_type) const {
456 const std::string canonicalized_email = 455 const std::string canonicalized_email =
457 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email)); 456 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email));
458 457
459 const AccountId account_id = user_manager::known_user::GetAccountId( 458 const AccountId account_id =
460 authenticated_email, id, account_type); 459 user_manager::known_user::GetAccountId(authenticated_email, gaia_id);
461 460
462 if (account_id.GetUserEmail() != canonicalized_email) { 461 if (account_id.GetUserEmail() != canonicalized_email) {
463 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail() 462 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail()
464 << "' authenticated by alias '" << canonicalized_email << "'."; 463 << "' authenticated by alias '" << canonicalized_email << "'.";
465 } 464 }
466 465
467 return account_id; 466 return account_id;
468 } 467 }
469 468
470 void GaiaScreenHandler::HandleCompleteAuthentication( 469 void GaiaScreenHandler::HandleCompleteAuthentication(
471 const std::string& gaia_id, 470 const std::string& gaia_id,
472 const std::string& email, 471 const std::string& email,
473 const std::string& password, 472 const std::string& password,
474 const std::string& auth_code, 473 const std::string& auth_code,
475 bool using_saml, 474 bool using_saml,
476 const std::string& gaps_cookie) { 475 const std::string& gaps_cookie) {
477 if (!Delegate()) 476 if (!Delegate())
478 return; 477 return;
479 478
480 DCHECK(!email.empty()); 479 DCHECK(!email.empty());
481 DCHECK(!gaia_id.empty()); 480 DCHECK(!gaia_id.empty());
482 const std::string sanitized_email = gaia::SanitizeEmail(email); 481 const std::string sanitized_email = gaia::SanitizeEmail(email);
483 Delegate()->SetDisplayEmail(sanitized_email); 482 Delegate()->SetDisplayEmail(sanitized_email);
484 483
485 UserContext user_context(GetAccountId(email, gaia_id, AccountType::GOOGLE)); 484 UserContext user_context(GetAccountId(email, gaia_id));
486 user_context.SetKey(Key(password)); 485 user_context.SetKey(Key(password));
487 user_context.SetAuthCode(auth_code); 486 user_context.SetAuthCode(auth_code);
488 user_context.SetAuthFlow(using_saml 487 user_context.SetAuthFlow(using_saml
489 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML 488 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML
490 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); 489 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML);
491 user_context.SetGAPSCookie(gaps_cookie); 490 user_context.SetGAPSCookie(gaps_cookie);
492 Delegate()->CompleteLogin(user_context); 491 Delegate()->CompleteLogin(user_context);
493 } 492 }
494 493
495 void GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly( 494 void GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 if (!Delegate()) 559 if (!Delegate())
561 return; 560 return;
562 561
563 if (using_saml && !using_saml_api_) 562 if (using_saml && !using_saml_api_)
564 RecordSAMLScrapingVerificationResultInHistogram(true); 563 RecordSAMLScrapingVerificationResultInHistogram(true);
565 564
566 DCHECK(!typed_email.empty()); 565 DCHECK(!typed_email.empty());
567 DCHECK(!gaia_id.empty()); 566 DCHECK(!gaia_id.empty());
568 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); 567 const std::string sanitized_email = gaia::SanitizeEmail(typed_email);
569 Delegate()->SetDisplayEmail(sanitized_email); 568 Delegate()->SetDisplayEmail(sanitized_email);
570 UserContext user_context( 569 UserContext user_context(GetAccountId(typed_email, gaia_id));
571 GetAccountId(typed_email, gaia_id, AccountType::GOOGLE));
572 user_context.SetKey(Key(password)); 570 user_context.SetKey(Key(password));
573 user_context.SetAuthFlow(using_saml 571 user_context.SetAuthFlow(using_saml
574 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML 572 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML
575 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); 573 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML);
576 Delegate()->CompleteLogin(user_context); 574 Delegate()->CompleteLogin(user_context);
577 575
578 if (test_expects_complete_login_) { 576 if (test_expects_complete_login_) {
579 VLOG(2) << "Complete test login for " << typed_email 577 VLOG(2) << "Complete test login for " << typed_email
580 << ", requested=" << test_user_; 578 << ", requested=" << test_user_;
581 579
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 gaia_silent_load_network_ != active_network_path)) { 698 gaia_silent_load_network_ != active_network_path)) {
701 // Network has changed. Force Gaia reload. 699 // Network has changed. Force Gaia reload.
702 gaia_silent_load_ = false; 700 gaia_silent_load_ = false;
703 } 701 }
704 702
705 // Note that LoadAuthExtension clears |populated_email_|. 703 // Note that LoadAuthExtension clears |populated_email_|.
706 if (populated_email_.empty()) { 704 if (populated_email_.empty()) {
707 Delegate()->LoadSigninWallpaper(); 705 Delegate()->LoadSigninWallpaper();
708 } else { 706 } else {
709 Delegate()->LoadWallpaper(user_manager::known_user::GetAccountId( 707 Delegate()->LoadWallpaper(user_manager::known_user::GetAccountId(
710 populated_email_, std::string() /* id */, AccountType::UNKNOWN)); 708 populated_email_, std::string()));
711 } 709 }
712 710
713 input_method::InputMethodManager* imm = 711 input_method::InputMethodManager* imm =
714 input_method::InputMethodManager::Get(); 712 input_method::InputMethodManager::Get();
715 713
716 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state = 714 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state =
717 imm->GetActiveIMEState()->Clone(); 715 imm->GetActiveIMEState()->Clone();
718 imm->SetState(gaia_ime_state); 716 imm->SetState(gaia_ime_state);
719 717
720 // Set Least Recently Used input method for the user. 718 // Set Least Recently Used input method for the user.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 bool GaiaScreenHandler::IsRestrictiveProxy() const { 841 bool GaiaScreenHandler::IsRestrictiveProxy() const {
844 return !disable_restrictive_proxy_check_for_test_ && 842 return !disable_restrictive_proxy_check_for_test_ &&
845 !IsOnline(captive_portal_status_); 843 !IsOnline(captive_portal_status_);
846 } 844 }
847 845
848 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { 846 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() {
849 disable_restrictive_proxy_check_for_test_ = true; 847 disable_restrictive_proxy_check_for_test_ = true;
850 } 848 }
851 849
852 } // namespace chromeos 850 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698