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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/prefs/pref_member.h" | 14 #include "base/prefs/pref_member.h" |
15 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
18 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
19 #include "base/task_runner_util.h" | 19 #include "base/task_runner_util.h" |
20 #include "base/threading/worker_pool.h" | 20 #include "base/threading/worker_pool.h" |
21 #include "chrome/browser/app_mode/app_mode_utils.h" | 21 #include "chrome/browser/app_mode/app_mode_utils.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 23 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
24 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
25 #include "chrome/browser/chromeos/base/locale_util.h" | 25 #include "chrome/browser/chromeos/base/locale_util.h" |
26 #include "chrome/browser/chromeos/boot_times_loader.h" | 26 #include "chrome/browser/chromeos/boot_times_loader.h" |
27 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 27 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
28 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" | 28 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" |
| 29 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" |
29 #include "chrome/browser/chromeos/login/profile_auth_data.h" | 30 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
30 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" | 31 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" |
31 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory
.h" | 32 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory
.h" |
32 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" | 33 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
33 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 34 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
34 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 35 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
35 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 36 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
36 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 37 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
37 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 38 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
38 #include "chrome/browser/chromeos/settings/cros_settings.h" | 39 #include "chrome/browser/chromeos/settings/cros_settings.h" |
39 #include "chrome/browser/first_run/first_run.h" | 40 #include "chrome/browser/first_run/first_run.h" |
40 #include "chrome/browser/google/google_brand_chromeos.h" | 41 #include "chrome/browser/google/google_brand_chromeos.h" |
41 #include "chrome/browser/lifetime/application_lifetime.h" | 42 #include "chrome/browser/lifetime/application_lifetime.h" |
42 #include "chrome/browser/net/crl_set_fetcher.h" | 43 #include "chrome/browser/net/crl_set_fetcher.h" |
43 #include "chrome/browser/net/nss_context.h" | 44 #include "chrome/browser/net/nss_context.h" |
44 #include "chrome/browser/profiles/profile.h" | 45 #include "chrome/browser/profiles/profile.h" |
45 #include "chrome/browser/profiles/profile_manager.h" | 46 #include "chrome/browser/profiles/profile_manager.h" |
46 #include "chrome/browser/rlz/rlz.h" | 47 #include "chrome/browser/rlz/rlz.h" |
| 48 #include "chrome/browser/signin/easy_unlock_service.h" |
47 #include "chrome/browser/signin/signin_manager_factory.h" | 49 #include "chrome/browser/signin/signin_manager_factory.h" |
48 #include "chrome/common/chrome_switches.h" | 50 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/logging_chrome.h" | 51 #include "chrome/common/logging_chrome.h" |
50 #include "chrome/common/pref_names.h" | 52 #include "chrome/common/pref_names.h" |
51 #include "chromeos/cert_loader.h" | 53 #include "chromeos/cert_loader.h" |
52 #include "chromeos/chromeos_switches.h" | 54 #include "chromeos/chromeos_switches.h" |
53 #include "chromeos/cryptohome/cryptohome_util.h" | 55 #include "chromeos/cryptohome/cryptohome_util.h" |
54 #include "chromeos/dbus/cryptohome_client.h" | 56 #include "chromeos/dbus/cryptohome_client.h" |
55 #include "chromeos/dbus/dbus_thread_manager.h" | 57 #include "chromeos/dbus/dbus_thread_manager.h" |
56 #include "chromeos/dbus/session_manager_client.h" | 58 #include "chromeos/dbus/session_manager_client.h" |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 } | 787 } |
786 | 788 |
787 // TODO(nkostylev): This pointer should probably never be NULL, but it looks | 789 // TODO(nkostylev): This pointer should probably never be NULL, but it looks |
788 // like LoginUtilsImpl::OnProfileCreated() may be getting called before | 790 // like LoginUtilsImpl::OnProfileCreated() may be getting called before |
789 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is | 791 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is |
790 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace | 792 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace |
791 // this 'if' statement with a CHECK(delegate_) once the underlying issue is | 793 // this 'if' statement with a CHECK(delegate_) once the underlying issue is |
792 // resolved. | 794 // resolved. |
793 if (delegate_) | 795 if (delegate_) |
794 delegate_->OnProfilePrepared(profile); | 796 delegate_->OnProfilePrepared(profile); |
| 797 |
| 798 UpdateEasyUnlockKeys(profile); |
795 } | 799 } |
796 | 800 |
797 void UserSessionManager::InitSessionRestoreStrategy() { | 801 void UserSessionManager::InitSessionRestoreStrategy() { |
798 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 802 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
799 bool in_app_mode = chrome::IsRunningInForcedAppMode(); | 803 bool in_app_mode = chrome::IsRunningInForcedAppMode(); |
800 | 804 |
801 // Are we in kiosk app mode? | 805 // Are we in kiosk app mode? |
802 if (in_app_mode) { | 806 if (in_app_mode) { |
803 if (command_line->HasSwitch(::switches::kAppModeOAuth2Token)) { | 807 if (command_line->HasSwitch(::switches::kAppModeOAuth2Token)) { |
804 oauth2_refresh_token_ = command_line->GetSwitchValueASCII( | 808 oauth2_refresh_token_ = command_line->GetSwitchValueASCII( |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 } | 988 } |
985 | 989 |
986 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { | 990 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { |
987 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 991 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
988 user_sessions_restored_ = true; | 992 user_sessions_restored_ = true; |
989 FOR_EACH_OBSERVER(chromeos::UserSessionStateObserver, | 993 FOR_EACH_OBSERVER(chromeos::UserSessionStateObserver, |
990 session_state_observer_list_, | 994 session_state_observer_list_, |
991 PendingUserSessionsRestoreFinished()); | 995 PendingUserSessionsRestoreFinished()); |
992 } | 996 } |
993 | 997 |
| 998 void UserSessionManager::UpdateEasyUnlockKeys(Profile* user_profile) { |
| 999 if (!CommandLine::ForCurrentProcess() |
| 1000 ->HasSwitch(chromeos::switches::kEnableEasySignin)) { |
| 1001 return; |
| 1002 } |
| 1003 |
| 1004 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); |
| 1005 |
| 1006 const base::ListValue* device_list = NULL; |
| 1007 if (EasyUnlockService::Get(user_profile)) |
| 1008 device_list = EasyUnlockService::Get(user_profile)->GetRemoteDevices(); |
| 1009 |
| 1010 if (device_list) { |
| 1011 easy_unlock_key_manager_->RefreshKeys( |
| 1012 user_context_, |
| 1013 *device_list, |
| 1014 EasyUnlockKeyManager::CreateKeysCallback()); |
| 1015 } else { |
| 1016 easy_unlock_key_manager_->RemoveKeys( |
| 1017 user_context_, |
| 1018 EasyUnlockKeyManager::RemoveKeysCallback()); |
| 1019 } |
| 1020 } |
| 1021 |
994 void UserSessionManager::ActiveUserChanged( | 1022 void UserSessionManager::ActiveUserChanged( |
995 const user_manager::User* active_user) { | 1023 const user_manager::User* active_user) { |
996 Profile* profile = ProfileHelper::Get()->GetProfileByUser(active_user); | 1024 Profile* profile = ProfileHelper::Get()->GetProfileByUser(active_user); |
997 // If profile has not yet been initialized, delay initialization of IME. | 1025 // If profile has not yet been initialized, delay initialization of IME. |
998 if (!profile) | 1026 if (!profile) |
999 return; | 1027 return; |
1000 | 1028 |
1001 input_method::InputMethodManager* manager = | 1029 input_method::InputMethodManager* manager = |
1002 input_method::InputMethodManager::Get(); | 1030 input_method::InputMethodManager::Get(); |
1003 manager->SetState( | 1031 manager->SetState( |
1004 GetDefaultIMEState(ProfileHelper::Get()->GetProfileByUser(active_user))); | 1032 GetDefaultIMEState(ProfileHelper::Get()->GetProfileByUser(active_user))); |
1005 } | 1033 } |
1006 | 1034 |
1007 scoped_refptr<input_method::InputMethodManager::State> | 1035 scoped_refptr<input_method::InputMethodManager::State> |
1008 UserSessionManager::GetDefaultIMEState(Profile* profile) { | 1036 UserSessionManager::GetDefaultIMEState(Profile* profile) { |
1009 scoped_refptr<input_method::InputMethodManager::State> state = | 1037 scoped_refptr<input_method::InputMethodManager::State> state = |
1010 default_ime_states_[profile]; | 1038 default_ime_states_[profile]; |
1011 if (!state) { | 1039 if (!state) { |
1012 // Profile can be NULL in tests. | 1040 // Profile can be NULL in tests. |
1013 state = input_method::InputMethodManager::Get()->CreateNewState(profile); | 1041 state = input_method::InputMethodManager::Get()->CreateNewState(profile); |
1014 default_ime_states_[profile] = state; | 1042 default_ime_states_[profile] = state; |
1015 } | 1043 } |
1016 return state; | 1044 return state; |
1017 } | 1045 } |
1018 | 1046 |
1019 } // namespace chromeos | 1047 } // namespace chromeos |
OLD | NEW |