Index: chrome/browser/chromeos/login/session/chrome_session_manager.cc |
diff --git a/chrome/browser/chromeos/login/session/chrome_session_manager.cc b/chrome/browser/chromeos/login/session/chrome_session_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d15d9525636e25de2600598fcf0f41e39cca0b3a |
--- /dev/null |
+++ b/chrome/browser/chromeos/login/session/chrome_session_manager.cc |
@@ -0,0 +1,104 @@ |
+// 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/chrome_session_manager.h" |
+ |
+#include "base/command_line.h" |
+#include "base/logging.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/sys_info.h" |
+#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
+#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
+#include "chrome/browser/chromeos/login/session/kiosk_auto_launcher_session_manager_delegate.h" |
+#include "chrome/browser/chromeos/login/session/login_oobe_session_manager_delegate.h" |
+#include "chrome/browser/chromeos/login/session/restore_after_crash_session_manager_delegate.h" |
+#include "chrome/browser/chromeos/login/session/stub_login_session_manager_delegate.h" |
+#include "chrome/browser/chromeos/login/users/user_manager.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chromeos/chromeos_switches.h" |
+ |
+namespace chromeos { |
+ |
+namespace { |
+ |
+bool ShouldAutoLaunchKioskApp(const base::CommandLine& command_line) { |
+ chromeos::KioskAppManager* app_manager = chromeos::KioskAppManager::Get(); |
oshima
2014/07/10 20:07:41
you're already in chromeos namespace, so you don't
Nikita (slow)
2014/07/14 16:30:11
Done.
|
+ return command_line.HasSwitch(chromeos::switches::kLoginManager) && |
+ !command_line.HasSwitch( |
+ chromeos::switches::kForceLoginManagerInTests) && |
+ app_manager->IsAutoLaunchEnabled() && |
+ chromeos::KioskAppLaunchError::Get() == |
+ chromeos::KioskAppLaunchError::NONE; |
+} |
+ |
+} // namespace |
+ |
+// static |
+scoped_ptr<session_manager::SessionManager> |
+ChromeSessionManager::CreateSessionManager( |
+ const base::CommandLine& parsed_command_line, |
+ Profile* profile, |
+ bool is_running_test) { |
+ // Tests should be able to tune login manager before showing it. Thus only |
+ // show login UI (login and out-of-box) in normal (non-testing) mode with |
+ // --login-manager switch and if test passed --force-login-manager-in-tests. |
+ bool force_login_screen_in_test = parsed_command_line.HasSwitch( |
+ chromeos::switches::kForceLoginManagerInTests); |
+ |
+ // If kLoginUser is passed this indicates that user has already |
+ // logged in and we should behave accordingly. |
+ bool immediate_login = |
+ parsed_command_line.HasSwitch(chromeos::switches::kLoginUser); |
+ |
+ std::string login_user_id = |
+ parsed_command_line.GetSwitchValueASCII(chromeos::switches::kLoginUser); |
+ |
+ if (ShouldAutoLaunchKioskApp(parsed_command_line)) { |
+ VLOG(1) << "Starting Chrome with KioskAutoLauncherSessionManagerDelegate"; |
+ return scoped_ptr<session_manager::SessionManager>( |
+ new chromeos::ChromeSessionManager( |
+ new chromeos::KioskAutoLauncherSessionManagerDelegate())); |
+ } else if (parsed_command_line.HasSwitch(chromeos::switches::kLoginManager) && |
+ (!is_running_test || force_login_screen_in_test)) { |
+ VLOG(1) << "Starting Chrome with LoginOobeSessionManagerDelegate"; |
+ return scoped_ptr<session_manager::SessionManager>( |
+ new chromeos::ChromeSessionManager( |
+ new chromeos::LoginOobeSessionManagerDelegate())); |
+ } else if (!base::SysInfo::IsRunningOnChromeOS() && |
+ login_user_id == chromeos::UserManager::kStubUser) { |
+ VLOG(1) << "Starting Chrome with StubLoginSessionManagerDelegate"; |
+ return scoped_ptr<session_manager::SessionManager>( |
+ new chromeos::ChromeSessionManager( |
+ new chromeos::StubLoginSessionManagerDelegate(profile, |
+ login_user_id))); |
+ } else if (immediate_login) { |
+ VLOG(1) << "Starting Chrome with RestoreAfterCrashSessionManagerDelegate"; |
+ // Restarting Chrome inside existing user session. Possible cases: |
+ // 1. Chrome is restarted after crash. |
+ // 2. Chrome is started in browser_tests skipping the login flow. |
+ // 3. Chrome is started on dev machine i.e. not on Chrome OS device w/o |
+ // login flow. In that case --login-user=[UserManager::kStubUser] is |
+ // added. See PreEarlyInitialization(). |
+ return scoped_ptr<session_manager::SessionManager>( |
+ new chromeos::ChromeSessionManager( |
+ new chromeos::RestoreAfterCrashSessionManagerDelegate( |
+ profile, login_user_id))); |
+ } else { |
+ VLOG(1) << "Starting Chrome with StubLoginSessionManagerDelegate"; |
+ return scoped_ptr<session_manager::SessionManager>( |
+ new chromeos::ChromeSessionManager( |
+ new chromeos::StubLoginSessionManagerDelegate(profile, |
+ login_user_id))); |
+ } |
+} |
+ |
+ChromeSessionManager::ChromeSessionManager( |
+ session_manager::SessionManagerDelegate* delegate) { |
+ Initialize(delegate); |
+} |
+ |
+ChromeSessionManager::~ChromeSessionManager() { |
+} |
+ |
+} // namespace chromeos |