| 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/chrome_session_manager.h" |    5 #include "chrome/browser/chromeos/login/session/chrome_session_manager.h" | 
|    6  |    6  | 
|    7 #include <memory> |    7 #include <memory> | 
|    8  |    8  | 
|    9 #include "base/command_line.h" |    9 #include "base/command_line.h" | 
|   10 #include "base/logging.h" |   10 #include "base/logging.h" | 
|   11 #include "base/sys_info.h" |   11 #include "base/sys_info.h" | 
|   12 #include "chrome/browser/chrome_notification_types.h" |   12 #include "chrome/browser/chrome_notification_types.h" | 
|   13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |   13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 
|   14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |   14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 
|   15 #include "chrome/browser/chromeos/login/session/kiosk_auto_launcher_session_mana
     ger_delegate.h" |   15 #include "chrome/browser/chromeos/login/session/kiosk_auto_launcher_session_mana
     ger_delegate.h" | 
|   16 #include "chrome/browser/chromeos/login/session/login_oobe_session_manager_deleg
     ate.h" |   16 #include "chrome/browser/chromeos/login/session/login_oobe_session_manager_deleg
     ate.h" | 
|   17 #include "chrome/browser/chromeos/login/session/restore_after_crash_session_mana
     ger_delegate.h" |   17 #include "chrome/browser/chromeos/login/session/restore_after_crash_session_mana
     ger_delegate.h" | 
|   18 #include "chrome/browser/chromeos/login/session/stub_login_session_manager_deleg
     ate.h" |   18 #include "chrome/browser/chromeos/login/session/stub_login_session_manager_deleg
     ate.h" | 
|   19 #include "chrome/browser/profiles/profile.h" |   19 #include "chrome/browser/profiles/profile.h" | 
|   20 #include "chromeos/chromeos_switches.h" |   20 #include "chromeos/chromeos_switches.h" | 
|   21 #include "chromeos/cryptohome/cryptohome_parameters.h" |   21 #include "chromeos/cryptohome/cryptohome_parameters.h" | 
|   22 #include "chromeos/login/user_names.h" |  | 
|   23 #include "components/signin/core/account_id/account_id.h" |   22 #include "components/signin/core/account_id/account_id.h" | 
|   24 #include "components/user_manager/user_manager.h" |   23 #include "components/user_manager/user_manager.h" | 
 |   24 #include "components/user_manager/user_names.h" | 
|   25 #include "content/public/browser/notification_service.h" |   25 #include "content/public/browser/notification_service.h" | 
|   26  |   26  | 
|   27 namespace chromeos { |   27 namespace chromeos { | 
|   28  |   28  | 
|   29 namespace { |   29 namespace { | 
|   30  |   30  | 
|   31 bool ShouldAutoLaunchKioskApp(const base::CommandLine& command_line) { |   31 bool ShouldAutoLaunchKioskApp(const base::CommandLine& command_line) { | 
|   32   KioskAppManager* app_manager = KioskAppManager::Get(); |   32   KioskAppManager* app_manager = KioskAppManager::Get(); | 
|   33   return command_line.HasSwitch(switches::kLoginManager) && |   33   return command_line.HasSwitch(switches::kLoginManager) && | 
|   34          !command_line.HasSwitch(switches::kForceLoginManagerInTests) && |   34          !command_line.HasSwitch(switches::kForceLoginManagerInTests) && | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|   61     VLOG(1) << "Starting Chrome with KioskAutoLauncherSessionManagerDelegate"; |   61     VLOG(1) << "Starting Chrome with KioskAutoLauncherSessionManagerDelegate"; | 
|   62     return std::unique_ptr<session_manager::SessionManager>( |   62     return std::unique_ptr<session_manager::SessionManager>( | 
|   63         new ChromeSessionManager( |   63         new ChromeSessionManager( | 
|   64             new KioskAutoLauncherSessionManagerDelegate())); |   64             new KioskAutoLauncherSessionManagerDelegate())); | 
|   65   } else if (parsed_command_line.HasSwitch(switches::kLoginManager) && |   65   } else if (parsed_command_line.HasSwitch(switches::kLoginManager) && | 
|   66              (!is_running_test || force_login_screen_in_test)) { |   66              (!is_running_test || force_login_screen_in_test)) { | 
|   67     VLOG(1) << "Starting Chrome with LoginOobeSessionManagerDelegate"; |   67     VLOG(1) << "Starting Chrome with LoginOobeSessionManagerDelegate"; | 
|   68     return std::unique_ptr<session_manager::SessionManager>( |   68     return std::unique_ptr<session_manager::SessionManager>( | 
|   69         new ChromeSessionManager(new LoginOobeSessionManagerDelegate())); |   69         new ChromeSessionManager(new LoginOobeSessionManagerDelegate())); | 
|   70   } else if (!base::SysInfo::IsRunningOnChromeOS() && |   70   } else if (!base::SysInfo::IsRunningOnChromeOS() && | 
|   71              login_account_id == login::StubAccountId()) { |   71              login_account_id == user_manager::StubAccountId()) { | 
|   72     VLOG(1) << "Starting Chrome with StubLoginSessionManagerDelegate"; |   72     VLOG(1) << "Starting Chrome with StubLoginSessionManagerDelegate"; | 
|   73     return std::unique_ptr<session_manager::SessionManager>( |   73     return std::unique_ptr<session_manager::SessionManager>( | 
|   74         new ChromeSessionManager(new StubLoginSessionManagerDelegate( |   74         new ChromeSessionManager(new StubLoginSessionManagerDelegate( | 
|   75             profile, login_account_id.GetUserEmail()))); |   75             profile, login_account_id.GetUserEmail()))); | 
|   76   } else { |   76   } else { | 
|   77     VLOG(1) << "Starting Chrome with  RestoreAfterCrashSessionManagerDelegate"; |   77     VLOG(1) << "Starting Chrome with  RestoreAfterCrashSessionManagerDelegate"; | 
|   78     // Restarting Chrome inside existing user session. Possible cases: |   78     // Restarting Chrome inside existing user session. Possible cases: | 
|   79     // 1. Chrome is restarted after crash. |   79     // 1. Chrome is restarted after crash. | 
|   80     // 2. Chrome is restarted for Guest session. |   80     // 2. Chrome is restarted for Guest session. | 
|   81     // 3. Chrome is started in browser_tests skipping the login flow. |   81     // 3. Chrome is started in browser_tests skipping the login flow. | 
|   82     // 4. Chrome is started on dev machine i.e. not on Chrome OS device w/o |   82     // 4. Chrome is started on dev machine i.e. not on Chrome OS device w/o | 
|   83     //    login flow. In that case --login-user=[chromeos::login::kStubUser] is |   83     //    login flow. In that case | 
 |   84     //    --login-user=[user_manager::kStubUser] is | 
|   84     //    added. See PreEarlyInitialization(). |   85     //    added. See PreEarlyInitialization(). | 
|   85     return std::unique_ptr<session_manager::SessionManager>( |   86     return std::unique_ptr<session_manager::SessionManager>( | 
|   86         new ChromeSessionManager(new RestoreAfterCrashSessionManagerDelegate( |   87         new ChromeSessionManager(new RestoreAfterCrashSessionManagerDelegate( | 
|   87             profile, login_account_id.GetUserEmail()))); |   88             profile, login_account_id.GetUserEmail()))); | 
|   88   } |   89   } | 
|   89 } |   90 } | 
|   90  |   91  | 
|   91 ChromeSessionManager::ChromeSessionManager( |   92 ChromeSessionManager::ChromeSessionManager( | 
|   92     session_manager::SessionManagerDelegate* delegate) { |   93     session_manager::SessionManagerDelegate* delegate) { | 
|   93   Initialize(delegate); |   94   Initialize(delegate); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  106     user_manager->OnSessionStarted(); |  107     user_manager->OnSessionStarted(); | 
|  107  |  108  | 
|  108   content::NotificationService::current()->Notify( |  109   content::NotificationService::current()->Notify( | 
|  109       chrome::NOTIFICATION_SESSION_STARTED, |  110       chrome::NOTIFICATION_SESSION_STARTED, | 
|  110       content::Source<session_manager::SessionManager>(this), |  111       content::Source<session_manager::SessionManager>(this), | 
|  111       content::Details<const user_manager::User>( |  112       content::Details<const user_manager::User>( | 
|  112           user_manager->GetActiveUser())); |  113           user_manager->GetActiveUser())); | 
|  113 } |  114 } | 
|  114  |  115  | 
|  115 }  // namespace chromeos |  116 }  // namespace chromeos | 
| OLD | NEW |