| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/login/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 case Profile::CREATE_STATUS_CANCELED: | 644 case Profile::CREATE_STATUS_CANCELED: |
| 645 case Profile::MAX_CREATE_STATUS: | 645 case Profile::MAX_CREATE_STATUS: |
| 646 NOTREACHED(); | 646 NOTREACHED(); |
| 647 break; | 647 break; |
| 648 } | 648 } |
| 649 } | 649 } |
| 650 | 650 |
| 651 void UserSessionManager::InitProfilePreferences( | 651 void UserSessionManager::InitProfilePreferences( |
| 652 Profile* profile, | 652 Profile* profile, |
| 653 const UserContext& user_context) { | 653 const UserContext& user_context) { |
| 654 user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile); |
| 655 if (user->is_active()) { |
| 656 input_method::InputMethodManager* manager = |
| 657 input_method::InputMethodManager::Get(); |
| 658 manager->SetState(GetDefaultIMEState(profile)); |
| 659 } |
| 654 if (user_manager::UserManager::Get()->IsCurrentUserNew()) { | 660 if (user_manager::UserManager::Get()->IsCurrentUserNew()) { |
| 655 SetFirstLoginPrefs(profile, | 661 SetFirstLoginPrefs(profile, |
| 656 user_context.GetPublicSessionLocale(), | 662 user_context.GetPublicSessionLocale(), |
| 657 user_context.GetPublicSessionInputMethod()); | 663 user_context.GetPublicSessionInputMethod()); |
| 658 } | 664 } |
| 659 | 665 |
| 660 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { | 666 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { |
| 661 user_manager::User* active_user = | 667 user_manager::User* active_user = |
| 662 user_manager::UserManager::Get()->GetActiveUser(); | 668 user_manager::UserManager::Get()->GetActiveUser(); |
| 663 std::string supervised_user_sync_id = | 669 std::string supervised_user_sync_id = |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { | 992 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { |
| 987 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 993 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 988 user_sessions_restored_ = true; | 994 user_sessions_restored_ = true; |
| 989 FOR_EACH_OBSERVER(chromeos::UserSessionStateObserver, | 995 FOR_EACH_OBSERVER(chromeos::UserSessionStateObserver, |
| 990 session_state_observer_list_, | 996 session_state_observer_list_, |
| 991 PendingUserSessionsRestoreFinished()); | 997 PendingUserSessionsRestoreFinished()); |
| 992 } | 998 } |
| 993 | 999 |
| 994 void UserSessionManager::ActiveUserChanged( | 1000 void UserSessionManager::ActiveUserChanged( |
| 995 const user_manager::User* active_user) { | 1001 const user_manager::User* active_user) { |
| 1002 Profile* profile = ProfileHelper::Get()->GetProfileByUser(active_user); |
| 1003 // If profile has not yet been initialized, delay initialization of IME. |
| 1004 if (!profile) |
| 1005 return; |
| 1006 |
| 996 input_method::InputMethodManager* manager = | 1007 input_method::InputMethodManager* manager = |
| 997 input_method::InputMethodManager::Get(); | 1008 input_method::InputMethodManager::Get(); |
| 998 manager->SetState( | 1009 manager->SetState( |
| 999 GetDefaultIMEState(ProfileHelper::Get()->GetProfileByUser(active_user))); | 1010 GetDefaultIMEState(ProfileHelper::Get()->GetProfileByUser(active_user))); |
| 1000 } | 1011 } |
| 1001 | 1012 |
| 1002 scoped_refptr<input_method::InputMethodManager::State> | 1013 scoped_refptr<input_method::InputMethodManager::State> |
| 1003 UserSessionManager::GetDefaultIMEState(Profile* profile) { | 1014 UserSessionManager::GetDefaultIMEState(Profile* profile) { |
| 1004 scoped_refptr<input_method::InputMethodManager::State> state = | 1015 scoped_refptr<input_method::InputMethodManager::State> state = |
| 1005 default_ime_states_[profile]; | 1016 default_ime_states_[profile]; |
| 1006 if (!state) { | 1017 if (!state) { |
| 1007 // Profile can be NULL in tests. | 1018 // Profile can be NULL in tests. |
| 1008 state = input_method::InputMethodManager::Get()->CreateNewState(profile); | 1019 state = input_method::InputMethodManager::Get()->CreateNewState(profile); |
| 1009 default_ime_states_[profile] = state; | 1020 default_ime_states_[profile] = state; |
| 1010 } | 1021 } |
| 1011 return state; | 1022 return state; |
| 1012 } | 1023 } |
| 1013 | 1024 |
| 1014 } // namespace chromeos | 1025 } // namespace chromeos |
| OLD | NEW |