Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3310)

Unified Diff: chrome/browser/chromeos/login/session/restore_after_crash_session_manager_delegate.cc

Issue 363613004: [cros] Define session_manager component with SessionManager base class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/session/restore_after_crash_session_manager_delegate.cc
diff --git a/chrome/browser/chromeos/login/session/restore_after_crash_session_manager_delegate.cc b/chrome/browser/chromeos/login/session/restore_after_crash_session_manager_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..53cfe9f4b495f4893a032a50514af5fa328efe9b
--- /dev/null
+++ b/chrome/browser/chromeos/login/session/restore_after_crash_session_manager_delegate.cc
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/session/restore_after_crash_session_manager_delegate.h"
+
+#include "base/command_line.h"
+#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/chromeos/login/session/user_session_manager.h"
+#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_switches.h"
+#include "chromeos/audio/cras_audio_handler.h"
+#include "chromeos/chromeos_switches.h"
+#include "content/public/browser/notification_service.h"
+
+namespace chromeos {
+
+RestoreAfterCrashSessionManagerDelegate::
+ RestoreAfterCrashSessionManagerDelegate(Profile* profile,
+ const std::string& login_user_id)
+ : profile_(profile), login_user_id_(login_user_id) {
+}
+
+RestoreAfterCrashSessionManagerDelegate::
+ ~RestoreAfterCrashSessionManagerDelegate() {
+}
+
+void RestoreAfterCrashSessionManagerDelegate::Start() {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+
+ session_manager_->SetSessionState(session_manager::SESSION_STATE_ACTIVE);
+
+ // TODO(nkostylev): Identify tests that do not set this kLoginUser flag but
+ // still rely on "stub user" session. Keeping existing behavior to avoid
+ // breaking tests.
+ if (command_line->HasSwitch(chromeos::switches::kLoginUser)) {
+ // This is done in SessionManager::OnProfileCreated during normal login.
+ UserSessionManager::GetInstance()->InitRlz(profile());
+
+ // Send the PROFILE_PREPARED notification and call SessionStarted()
+ // so that the Launcher and other Profile dependent classes are created.
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
+ content::NotificationService::AllSources(),
+ content::Details<Profile>(profile()));
+
+ // This call will set session state to SESSION_STATE_ACTIVE (same one).
+ UserManager::Get()->SessionStarted();
+
+ // Now is the good time to retrieve other logged in users for this session.
+ // First user has been already marked as logged in and active in
+ // PreProfileInit(). Restore sessions for other users in the background.
+ UserSessionManager::GetInstance()->RestoreActiveSessions();
+ }
+
+ bool is_running_test = command_line->HasSwitch(::switches::kTestName) ||
+ command_line->HasSwitch(::switches::kTestType);
+
+ if (!is_running_test) {
+ // Enable CrasAudioHandler logging when chrome restarts after crashing.
+ if (chromeos::CrasAudioHandler::IsInitialized())
+ chromeos::CrasAudioHandler::Get()->LogErrors();
+
+ // We did not log in (we crashed or are debugging), so we need to
+ // restore Sync.
+ UserSessionManager::GetInstance()->RestoreAuthenticationSession(profile());
+ }
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698