| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 373 user_manager::UserManager::Get()->GetKnownUserAccountId( | 374 user_manager::known_user::GetKnownUserAccountId( |
| 374 user_email, std::string() /* gaia_id */))) | 375 user_email, std::string() /* gaia_id */))) |
| 375 ShowWhitelistCheckFailedError(); | 376 ShowWhitelistCheckFailedError(); |
| 376 } | 377 } |
| 377 | 378 |
| 378 void GaiaScreenHandler::HandleWebviewLoadAborted( | 379 void GaiaScreenHandler::HandleWebviewLoadAborted( |
| 379 const std::string& error_reason_str) { | 380 const std::string& error_reason_str) { |
| 380 // TODO(nkostylev): Switch to int code once webview supports that. | 381 // TODO(nkostylev): Switch to int code once webview supports that. |
| 381 // http://crbug.com/470483 | 382 // http://crbug.com/470483 |
| 382 if (error_reason_str == "ERR_ABORTED") { | 383 if (error_reason_str == "ERR_ABORTED") { |
| 383 LOG(WARNING) << "Ignoring Gaia webview error: " << error_reason_str; | 384 LOG(WARNING) << "Ignoring Gaia webview error: " << error_reason_str; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 408 frame_state_ = FRAME_STATE_ERROR; | 409 frame_state_ = FRAME_STATE_ERROR; |
| 409 UpdateState(error_reason); | 410 UpdateState(error_reason); |
| 410 } | 411 } |
| 411 | 412 |
| 412 AccountId GaiaScreenHandler::GetAccountId( | 413 AccountId GaiaScreenHandler::GetAccountId( |
| 413 const std::string& authenticated_email, | 414 const std::string& authenticated_email, |
| 414 const std::string& gaia_id) const { | 415 const std::string& gaia_id) const { |
| 415 const std::string canonicalized_email = | 416 const std::string canonicalized_email = |
| 416 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email)); | 417 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email)); |
| 417 | 418 |
| 418 const AccountId account_id = user_manager::UserManager::GetKnownUserAccountId( | 419 const AccountId account_id = user_manager::known_user::GetKnownUserAccountId( |
| 419 authenticated_email, gaia_id); | 420 authenticated_email, gaia_id); |
| 420 | 421 |
| 421 if (account_id.GetUserEmail() != canonicalized_email) { | 422 if (account_id.GetUserEmail() != canonicalized_email) { |
| 422 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail() | 423 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail() |
| 423 << "' authenticated by alias '" << canonicalized_email << "'."; | 424 << "' authenticated by alias '" << canonicalized_email << "'."; |
| 424 } | 425 } |
| 425 | 426 |
| 426 return account_id; | 427 return account_id; |
| 427 } | 428 } |
| 428 | 429 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 (network_state_informer_->state() != NetworkStateInformer::ONLINE || | 660 (network_state_informer_->state() != NetworkStateInformer::ONLINE || |
| 660 gaia_silent_load_network_ != active_network_path)) { | 661 gaia_silent_load_network_ != active_network_path)) { |
| 661 // Network has changed. Force Gaia reload. | 662 // Network has changed. Force Gaia reload. |
| 662 gaia_silent_load_ = false; | 663 gaia_silent_load_ = false; |
| 663 } | 664 } |
| 664 | 665 |
| 665 // Note that LoadAuthExtension clears |populated_email_|. | 666 // Note that LoadAuthExtension clears |populated_email_|. |
| 666 if (populated_email_.empty()) { | 667 if (populated_email_.empty()) { |
| 667 Delegate()->LoadSigninWallpaper(); | 668 Delegate()->LoadSigninWallpaper(); |
| 668 } else { | 669 } else { |
| 669 Delegate()->LoadWallpaper( | 670 Delegate()->LoadWallpaper(user_manager::known_user::GetKnownUserAccountId( |
| 670 user_manager::UserManager::Get()->GetKnownUserAccountId( | 671 populated_email_, std::string())); |
| 671 populated_email_, std::string())); | |
| 672 } | 672 } |
| 673 | 673 |
| 674 input_method::InputMethodManager* imm = | 674 input_method::InputMethodManager* imm = |
| 675 input_method::InputMethodManager::Get(); | 675 input_method::InputMethodManager::Get(); |
| 676 | 676 |
| 677 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state = | 677 scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state = |
| 678 imm->GetActiveIMEState()->Clone(); | 678 imm->GetActiveIMEState()->Clone(); |
| 679 imm->SetState(gaia_ime_state); | 679 imm->SetState(gaia_ime_state); |
| 680 | 680 |
| 681 // Set Least Recently Used input method for the user. | 681 // 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) { | 762 bool offline) { |
| 763 VLOG(1) << "LoadAuthExtension, force: " << force | 763 VLOG(1) << "LoadAuthExtension, force: " << force |
| 764 << ", offline: " << offline; | 764 << ", offline: " << offline; |
| 765 GaiaContext context; | 765 GaiaContext context; |
| 766 context.force_reload = force; | 766 context.force_reload = force; |
| 767 context.use_offline = offline; | 767 context.use_offline = offline; |
| 768 context.email = populated_email_; | 768 context.email = populated_email_; |
| 769 | 769 |
| 770 std::string gaia_id; | 770 std::string gaia_id; |
| 771 if (!context.email.empty() && | 771 if (!context.email.empty() && |
| 772 user_manager::UserManager::Get()->FindGaiaID( | 772 user_manager::known_user::FindGaiaID( |
| 773 AccountId::FromUserEmail(context.email), &gaia_id)) { | 773 AccountId::FromUserEmail(context.email), &gaia_id)) { |
| 774 context.gaia_id = gaia_id; | 774 context.gaia_id = gaia_id; |
| 775 } | 775 } |
| 776 | 776 |
| 777 if (!context.email.empty()) { | 777 if (!context.email.empty()) { |
| 778 context.gaps_cookie = | 778 context.gaps_cookie = user_manager::known_user::GetKnownUserGAPSCookie( |
| 779 user_manager::UserManager::Get()->GetKnownUserGAPSCookie( | 779 AccountId::FromUserEmail(gaia::CanonicalizeEmail(context.email))); |
| 780 AccountId::FromUserEmail(gaia::CanonicalizeEmail(context.email))); | |
| 781 } | 780 } |
| 782 | 781 |
| 783 populated_email_.clear(); | 782 populated_email_.clear(); |
| 784 | 783 |
| 785 LoadGaia(context); | 784 LoadGaia(context); |
| 786 } | 785 } |
| 787 | 786 |
| 788 void GaiaScreenHandler::UpdateState(NetworkError::ErrorReason reason) { | 787 void GaiaScreenHandler::UpdateState(NetworkError::ErrorReason reason) { |
| 789 if (signin_screen_handler_) | 788 if (signin_screen_handler_) |
| 790 signin_screen_handler_->UpdateState(reason); | 789 signin_screen_handler_->UpdateState(reason); |
| 791 } | 790 } |
| 792 | 791 |
| 793 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 792 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
| 794 return signin_screen_handler_->delegate_; | 793 return signin_screen_handler_->delegate_; |
| 795 } | 794 } |
| 796 | 795 |
| 797 bool GaiaScreenHandler::IsRestrictiveProxy() const { | 796 bool GaiaScreenHandler::IsRestrictiveProxy() const { |
| 798 return !disable_restrictive_proxy_check_for_test_ && | 797 return !disable_restrictive_proxy_check_for_test_ && |
| 799 !IsOnline(captive_portal_status_); | 798 !IsOnline(captive_portal_status_); |
| 800 } | 799 } |
| 801 | 800 |
| 802 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { | 801 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { |
| 803 disable_restrictive_proxy_check_for_test_ = true; | 802 disable_restrictive_proxy_check_for_test_ = true; |
| 804 } | 803 } |
| 805 | 804 |
| 806 } // namespace chromeos | 805 } // namespace chromeos |
| OLD | NEW |