Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/login/session/chrome_session_manager.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/sys_info.h" | |
| 11 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | |
| 12 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | |
| 13 #include "chrome/browser/chromeos/login/session/kiosk_auto_launcher_session_mana ger_delegate.h" | |
| 14 #include "chrome/browser/chromeos/login/session/login_oobe_session_manager_deleg ate.h" | |
| 15 #include "chrome/browser/chromeos/login/session/restore_after_crash_session_mana ger_delegate.h" | |
| 16 #include "chrome/browser/chromeos/login/session/stub_login_session_manager_deleg ate.h" | |
| 17 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
| 18 #include "chrome/browser/profiles/profile.h" | |
| 19 #include "chromeos/chromeos_switches.h" | |
| 20 | |
| 21 namespace chromeos { | |
| 22 | |
| 23 namespace { | |
| 24 | |
| 25 bool ShouldAutoLaunchKioskApp(const base::CommandLine& command_line) { | |
| 26 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.
| |
| 27 return command_line.HasSwitch(chromeos::switches::kLoginManager) && | |
| 28 !command_line.HasSwitch( | |
| 29 chromeos::switches::kForceLoginManagerInTests) && | |
| 30 app_manager->IsAutoLaunchEnabled() && | |
| 31 chromeos::KioskAppLaunchError::Get() == | |
| 32 chromeos::KioskAppLaunchError::NONE; | |
| 33 } | |
| 34 | |
| 35 } // namespace | |
| 36 | |
| 37 // static | |
| 38 scoped_ptr<session_manager::SessionManager> | |
| 39 ChromeSessionManager::CreateSessionManager( | |
| 40 const base::CommandLine& parsed_command_line, | |
| 41 Profile* profile, | |
| 42 bool is_running_test) { | |
| 43 // Tests should be able to tune login manager before showing it. Thus only | |
| 44 // show login UI (login and out-of-box) in normal (non-testing) mode with | |
| 45 // --login-manager switch and if test passed --force-login-manager-in-tests. | |
| 46 bool force_login_screen_in_test = parsed_command_line.HasSwitch( | |
| 47 chromeos::switches::kForceLoginManagerInTests); | |
| 48 | |
| 49 // If kLoginUser is passed this indicates that user has already | |
| 50 // logged in and we should behave accordingly. | |
| 51 bool immediate_login = | |
| 52 parsed_command_line.HasSwitch(chromeos::switches::kLoginUser); | |
| 53 | |
| 54 std::string login_user_id = | |
| 55 parsed_command_line.GetSwitchValueASCII(chromeos::switches::kLoginUser); | |
| 56 | |
| 57 if (ShouldAutoLaunchKioskApp(parsed_command_line)) { | |
| 58 VLOG(1) << "Starting Chrome with KioskAutoLauncherSessionManagerDelegate"; | |
| 59 return scoped_ptr<session_manager::SessionManager>( | |
| 60 new chromeos::ChromeSessionManager( | |
| 61 new chromeos::KioskAutoLauncherSessionManagerDelegate())); | |
| 62 } else if (parsed_command_line.HasSwitch(chromeos::switches::kLoginManager) && | |
| 63 (!is_running_test || force_login_screen_in_test)) { | |
| 64 VLOG(1) << "Starting Chrome with LoginOobeSessionManagerDelegate"; | |
| 65 return scoped_ptr<session_manager::SessionManager>( | |
| 66 new chromeos::ChromeSessionManager( | |
| 67 new chromeos::LoginOobeSessionManagerDelegate())); | |
| 68 } else if (!base::SysInfo::IsRunningOnChromeOS() && | |
| 69 login_user_id == chromeos::UserManager::kStubUser) { | |
| 70 VLOG(1) << "Starting Chrome with StubLoginSessionManagerDelegate"; | |
| 71 return scoped_ptr<session_manager::SessionManager>( | |
| 72 new chromeos::ChromeSessionManager( | |
| 73 new chromeos::StubLoginSessionManagerDelegate(profile, | |
| 74 login_user_id))); | |
| 75 } else if (immediate_login) { | |
| 76 VLOG(1) << "Starting Chrome with RestoreAfterCrashSessionManagerDelegate"; | |
| 77 // Restarting Chrome inside existing user session. Possible cases: | |
| 78 // 1. Chrome is restarted after crash. | |
| 79 // 2. Chrome is started in browser_tests skipping the login flow. | |
| 80 // 3. Chrome is started on dev machine i.e. not on Chrome OS device w/o | |
| 81 // login flow. In that case --login-user=[UserManager::kStubUser] is | |
| 82 // added. See PreEarlyInitialization(). | |
| 83 return scoped_ptr<session_manager::SessionManager>( | |
| 84 new chromeos::ChromeSessionManager( | |
| 85 new chromeos::RestoreAfterCrashSessionManagerDelegate( | |
| 86 profile, login_user_id))); | |
| 87 } else { | |
| 88 VLOG(1) << "Starting Chrome with StubLoginSessionManagerDelegate"; | |
| 89 return scoped_ptr<session_manager::SessionManager>( | |
| 90 new chromeos::ChromeSessionManager( | |
| 91 new chromeos::StubLoginSessionManagerDelegate(profile, | |
| 92 login_user_id))); | |
| 93 } | |
| 94 } | |
| 95 | |
| 96 ChromeSessionManager::ChromeSessionManager( | |
| 97 session_manager::SessionManagerDelegate* delegate) { | |
| 98 Initialize(delegate); | |
| 99 } | |
| 100 | |
| 101 ChromeSessionManager::~ChromeSessionManager() { | |
| 102 } | |
| 103 | |
| 104 } // namespace chromeos | |
| OLD | NEW |