| 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/restore_after_crash_session_mana
ger_delegate.h" | 5 #include "chrome/browser/chromeos/login/session/restore_after_crash_session_init
ializer.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | 9 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 10 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 10 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 12 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "chromeos/audio/cras_audio_handler.h" | 15 #include "chromeos/audio/cras_audio_handler.h" |
| 16 #include "chromeos/chromeos_switches.h" | 16 #include "chromeos/chromeos_switches.h" |
| 17 #include "components/arc/arc_bridge_service.h" | 17 #include "components/arc/arc_bridge_service.h" |
| 18 #include "components/arc/arc_service_manager.h" | 18 #include "components/arc/arc_service_manager.h" |
| 19 #include "components/prefs/pref_member.h" | 19 #include "components/prefs/pref_member.h" |
| 20 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
| 21 #include "components/session_manager/core/session_manager.h" |
| 21 #include "components/user_manager/user_manager.h" | 22 #include "components/user_manager/user_manager.h" |
| 22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 24 | 25 |
| 25 namespace chromeos { | 26 namespace chromeos { |
| 26 | 27 |
| 27 RestoreAfterCrashSessionManagerDelegate:: | 28 RestoreAfterCrashSessionInitializer::RestoreAfterCrashSessionInitializer( |
| 28 RestoreAfterCrashSessionManagerDelegate(Profile* profile, | 29 Profile* profile, |
| 29 const std::string& login_user_id) | 30 const std::string& login_user_id) |
| 30 : profile_(profile), login_user_id_(login_user_id) {} | 31 : profile_(profile), login_user_id_(login_user_id) {} |
| 31 | 32 |
| 32 RestoreAfterCrashSessionManagerDelegate:: | 33 RestoreAfterCrashSessionInitializer::~RestoreAfterCrashSessionInitializer() {} |
| 33 ~RestoreAfterCrashSessionManagerDelegate() {} | |
| 34 | 34 |
| 35 void RestoreAfterCrashSessionManagerDelegate::Start() { | 35 void RestoreAfterCrashSessionInitializer::Start() { |
| 36 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 36 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 37 | 37 |
| 38 session_manager_->SetSessionState(session_manager::SessionState::ACTIVE); | 38 session_manager::SessionManager::Get()->SetSessionState( |
| 39 session_manager::SessionState::ACTIVE); |
| 39 | 40 |
| 40 // TODO(nkostylev): Identify tests that do not set this kLoginUser flag but | 41 // TODO(nkostylev): Identify tests that do not set this kLoginUser flag but |
| 41 // still rely on "stub user" session. Keeping existing behavior to avoid | 42 // still rely on "stub user" session. Keeping existing behavior to avoid |
| 42 // breaking tests. | 43 // breaking tests. |
| 43 if (command_line->HasSwitch(chromeos::switches::kLoginUser)) { | 44 if (command_line->HasSwitch(chromeos::switches::kLoginUser)) { |
| 44 // This is done in SessionManager::OnProfileCreated during normal login. | 45 // This is done in SessionManager::OnProfileCreated during normal login. |
| 45 UserSessionManager* user_session_mgr = UserSessionManager::GetInstance(); | 46 UserSessionManager* user_session_mgr = UserSessionManager::GetInstance(); |
| 46 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 47 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 47 const user_manager::User* user = user_manager->GetActiveUser(); | 48 const user_manager::User* user = user_manager->GetActiveUser(); |
| 48 if (!user) { | 49 if (!user) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 70 } | 71 } |
| 71 | 72 |
| 72 // Send the PROFILE_PREPARED notification and call SessionStarted() | 73 // Send the PROFILE_PREPARED notification and call SessionStarted() |
| 73 // so that the Launcher and other Profile dependent classes are created. | 74 // so that the Launcher and other Profile dependent classes are created. |
| 74 content::NotificationService::current()->Notify( | 75 content::NotificationService::current()->Notify( |
| 75 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 76 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 76 content::NotificationService::AllSources(), | 77 content::NotificationService::AllSources(), |
| 77 content::Details<Profile>(profile())); | 78 content::Details<Profile>(profile())); |
| 78 | 79 |
| 79 // This call will set session state to SESSION_STATE_ACTIVE (same one). | 80 // This call will set session state to SESSION_STATE_ACTIVE (same one). |
| 80 session_manager_->SessionStarted(); | 81 session_manager::SessionManager::Get()->SessionStarted(); |
| 81 | 82 |
| 82 // Now is the good time to retrieve other logged in users for this session. | 83 // Now is the good time to retrieve other logged in users for this session. |
| 83 // First user has been already marked as logged in and active in | 84 // First user has been already marked as logged in and active in |
| 84 // PreProfileInit(). Restore sessions for other users in the background. | 85 // PreProfileInit(). Restore sessions for other users in the background. |
| 85 user_session_mgr->RestoreActiveSessions(); | 86 user_session_mgr->RestoreActiveSessions(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 bool is_running_test = command_line->HasSwitch(::switches::kTestName) || | 89 bool is_running_test = command_line->HasSwitch(::switches::kTestName) || |
| 89 command_line->HasSwitch(::switches::kTestType); | 90 command_line->HasSwitch(::switches::kTestType); |
| 90 | 91 |
| 91 if (!is_running_test) { | 92 if (!is_running_test) { |
| 92 // Enable CrasAudioHandler logging when chrome restarts after crashing. | 93 // Enable CrasAudioHandler logging when chrome restarts after crashing. |
| 93 if (chromeos::CrasAudioHandler::IsInitialized()) | 94 if (chromeos::CrasAudioHandler::IsInitialized()) |
| 94 chromeos::CrasAudioHandler::Get()->LogErrors(); | 95 chromeos::CrasAudioHandler::Get()->LogErrors(); |
| 95 | 96 |
| 96 // We did not log in (we crashed or are debugging), so we need to | 97 // We did not log in (we crashed or are debugging), so we need to |
| 97 // restore Sync. | 98 // restore Sync. |
| 98 UserSessionManager::GetInstance()->RestoreAuthenticationSession(profile()); | 99 UserSessionManager::GetInstance()->RestoreAuthenticationSession(profile()); |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 | 102 |
| 102 } // namespace chromeos | 103 } // namespace chromeos |
| OLD | NEW |