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/system/chromeos/devicetype_utils.h" | 7 #include "ash/system/chromeos/devicetype_utils.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" | 28 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
29 #include "chrome/common/channel_info.h" | 29 #include "chrome/common/channel_info.h" |
30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
31 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
32 #include "chromeos/chromeos_switches.h" | 32 #include "chromeos/chromeos_switches.h" |
33 #include "chromeos/login/auth/user_context.h" | 33 #include "chromeos/login/auth/user_context.h" |
34 #include "chromeos/settings/cros_settings_names.h" | 34 #include "chromeos/settings/cros_settings_names.h" |
35 #include "chromeos/system/devicetype.h" | 35 #include "chromeos/system/devicetype.h" |
36 #include "chromeos/system/version_loader.h" | 36 #include "chromeos/system/version_loader.h" |
37 #include "components/login/localized_values_builder.h" | 37 #include "components/login/localized_values_builder.h" |
| 38 #include "components/user_manager/known_user.h" |
38 #include "components/user_manager/user_manager.h" | 39 #include "components/user_manager/user_manager.h" |
39 #include "components/version_info/version_info.h" | 40 #include "components/version_info/version_info.h" |
40 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
41 #include "content/public/browser/render_frame_host.h" | 42 #include "content/public/browser/render_frame_host.h" |
42 #include "google_apis/gaia/gaia_auth_util.h" | 43 #include "google_apis/gaia/gaia_auth_util.h" |
43 #include "google_apis/gaia/gaia_urls.h" | 44 #include "google_apis/gaia/gaia_urls.h" |
44 #include "ui/base/ime/chromeos/input_method_manager.h" | 45 #include "ui/base/ime/chromeos/input_method_manager.h" |
45 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
46 | 47 |
47 using content::BrowserThread; | 48 using content::BrowserThread; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 if (offline_login_is_active() || | 363 if (offline_login_is_active() || |
363 IsOnline(captive_portal_status_) == IsOnline(previous_status) || | 364 IsOnline(captive_portal_status_) == IsOnline(previous_status) || |
364 disable_restrictive_proxy_check_for_test_ || | 365 disable_restrictive_proxy_check_for_test_ || |
365 GetCurrentScreen() != OobeUI::SCREEN_GAIA_SIGNIN) | 366 GetCurrentScreen() != OobeUI::SCREEN_GAIA_SIGNIN) |
366 return; | 367 return; |
367 | 368 |
368 LoadAuthExtension(true /* force */, false /* offline */); | 369 LoadAuthExtension(true /* force */, false /* offline */); |
369 } | 370 } |
370 | 371 |
371 void GaiaScreenHandler::HandleIdentifierEntered(const std::string& user_email) { | 372 void GaiaScreenHandler::HandleIdentifierEntered(const std::string& user_email) { |
372 if (!Delegate()->IsUserWhitelisted( | 373 if (!Delegate()->IsUserWhitelisted(user_manager::known_user::GetAccountId( |
373 user_manager::UserManager::Get()->GetKnownUserAccountId( | 374 user_email, std::string() /* gaia_id */))) |
374 user_email, std::string() /* gaia_id */))) | |
375 ShowWhitelistCheckFailedError(); | 375 ShowWhitelistCheckFailedError(); |
376 } | 376 } |
377 | 377 |
378 void GaiaScreenHandler::HandleWebviewLoadAborted( | 378 void GaiaScreenHandler::HandleWebviewLoadAborted( |
379 const std::string& error_reason_str) { | 379 const std::string& error_reason_str) { |
380 // TODO(nkostylev): Switch to int code once webview supports that. | 380 // TODO(nkostylev): Switch to int code once webview supports that. |
381 // http://crbug.com/470483 | 381 // http://crbug.com/470483 |
382 if (error_reason_str == "ERR_ABORTED") { | 382 if (error_reason_str == "ERR_ABORTED") { |
383 LOG(WARNING) << "Ignoring Gaia webview error: " << error_reason_str; | 383 LOG(WARNING) << "Ignoring Gaia webview error: " << error_reason_str; |
384 return; | 384 return; |
(...skipping 23 matching lines...) Expand all Loading... |
408 frame_state_ = FRAME_STATE_ERROR; | 408 frame_state_ = FRAME_STATE_ERROR; |
409 UpdateState(error_reason); | 409 UpdateState(error_reason); |
410 } | 410 } |
411 | 411 |
412 AccountId GaiaScreenHandler::GetAccountId( | 412 AccountId GaiaScreenHandler::GetAccountId( |
413 const std::string& authenticated_email, | 413 const std::string& authenticated_email, |
414 const std::string& gaia_id) const { | 414 const std::string& gaia_id) const { |
415 const std::string canonicalized_email = | 415 const std::string canonicalized_email = |
416 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email)); | 416 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email)); |
417 | 417 |
418 const AccountId account_id = user_manager::UserManager::GetKnownUserAccountId( | 418 const AccountId account_id = |
419 authenticated_email, gaia_id); | 419 user_manager::known_user::GetAccountId(authenticated_email, gaia_id); |
420 | 420 |
421 if (account_id.GetUserEmail() != canonicalized_email) { | 421 if (account_id.GetUserEmail() != canonicalized_email) { |
422 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail() | 422 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail() |
423 << "' authenticated by alias '" << canonicalized_email << "'."; | 423 << "' authenticated by alias '" << canonicalized_email << "'."; |
424 } | 424 } |
425 | 425 |
426 return account_id; | 426 return account_id; |
427 } | 427 } |
428 | 428 |
429 void GaiaScreenHandler::HandleCompleteAuthentication( | 429 void GaiaScreenHandler::HandleCompleteAuthentication( |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 (network_state_informer_->state() != NetworkStateInformer::ONLINE || | 659 (network_state_informer_->state() != NetworkStateInformer::ONLINE || |
660 gaia_silent_load_network_ != active_network_path)) { | 660 gaia_silent_load_network_ != active_network_path)) { |
661 // Network has changed. Force Gaia reload. | 661 // Network has changed. Force Gaia reload. |
662 gaia_silent_load_ = false; | 662 gaia_silent_load_ = false; |
663 } | 663 } |
664 | 664 |
665 // Note that LoadAuthExtension clears |populated_email_|. | 665 // Note that LoadAuthExtension clears |populated_email_|. |
666 if (populated_email_.empty()) { | 666 if (populated_email_.empty()) { |
667 Delegate()->LoadSigninWallpaper(); | 667 Delegate()->LoadSigninWallpaper(); |
668 } else { | 668 } else { |
669 Delegate()->LoadWallpaper( | 669 Delegate()->LoadWallpaper(user_manager::known_user::GetAccountId( |
670 user_manager::UserManager::Get()->GetKnownUserAccountId( | 670 populated_email_, std::string())); |
671 populated_email_, std::string())); | |
672 } | 671 } |
673 | 672 |
674 input_method::InputMethodManager* imm = | 673 input_method::InputMethodManager* imm = |
675 input_method::InputMethodManager::Get(); | 674 input_method::InputMethodManager::Get(); |
676 | 675 |
677 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state = | 676 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state = |
678 imm->GetActiveIMEState()->Clone(); | 677 imm->GetActiveIMEState()->Clone(); |
679 imm->SetState(gaia_ime_state); | 678 imm->SetState(gaia_ime_state); |
680 | 679 |
681 // Set Least Recently Used input method for the user. | 680 // Set Least Recently Used input method for the user. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 bool offline) { | 761 bool offline) { |
763 VLOG(1) << "LoadAuthExtension, force: " << force | 762 VLOG(1) << "LoadAuthExtension, force: " << force |
764 << ", offline: " << offline; | 763 << ", offline: " << offline; |
765 GaiaContext context; | 764 GaiaContext context; |
766 context.force_reload = force; | 765 context.force_reload = force; |
767 context.use_offline = offline; | 766 context.use_offline = offline; |
768 context.email = populated_email_; | 767 context.email = populated_email_; |
769 | 768 |
770 std::string gaia_id; | 769 std::string gaia_id; |
771 if (!context.email.empty() && | 770 if (!context.email.empty() && |
772 user_manager::UserManager::Get()->FindGaiaID( | 771 user_manager::known_user::FindGaiaID( |
773 AccountId::FromUserEmail(context.email), &gaia_id)) { | 772 AccountId::FromUserEmail(context.email), &gaia_id)) { |
774 context.gaia_id = gaia_id; | 773 context.gaia_id = gaia_id; |
775 } | 774 } |
776 | 775 |
777 if (!context.email.empty()) { | 776 if (!context.email.empty()) { |
778 context.gaps_cookie = | 777 context.gaps_cookie = user_manager::known_user::GetGAPSCookie( |
779 user_manager::UserManager::Get()->GetKnownUserGAPSCookie( | 778 AccountId::FromUserEmail(gaia::CanonicalizeEmail(context.email))); |
780 AccountId::FromUserEmail(gaia::CanonicalizeEmail(context.email))); | |
781 } | 779 } |
782 | 780 |
783 populated_email_.clear(); | 781 populated_email_.clear(); |
784 | 782 |
785 LoadGaia(context); | 783 LoadGaia(context); |
786 } | 784 } |
787 | 785 |
788 void GaiaScreenHandler::UpdateState(NetworkError::ErrorReason reason) { | 786 void GaiaScreenHandler::UpdateState(NetworkError::ErrorReason reason) { |
789 if (signin_screen_handler_) | 787 if (signin_screen_handler_) |
790 signin_screen_handler_->UpdateState(reason); | 788 signin_screen_handler_->UpdateState(reason); |
791 } | 789 } |
792 | 790 |
793 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 791 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
794 return signin_screen_handler_->delegate_; | 792 return signin_screen_handler_->delegate_; |
795 } | 793 } |
796 | 794 |
797 bool GaiaScreenHandler::IsRestrictiveProxy() const { | 795 bool GaiaScreenHandler::IsRestrictiveProxy() const { |
798 return !disable_restrictive_proxy_check_for_test_ && | 796 return !disable_restrictive_proxy_check_for_test_ && |
799 !IsOnline(captive_portal_status_); | 797 !IsOnline(captive_portal_status_); |
800 } | 798 } |
801 | 799 |
802 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { | 800 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { |
803 disable_restrictive_proxy_check_for_test_ = true; | 801 disable_restrictive_proxy_check_for_test_ = true; |
804 } | 802 } |
805 | 803 |
806 } // namespace chromeos | 804 } // namespace chromeos |
OLD | NEW |