OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chrome_browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/chromeos/chromeos_version.h" | 14 #include "base/chromeos/chromeos_version.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/linux_util.h" | 18 #include "base/linux_util.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 25 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
26 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
28 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 28 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
29 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 29 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
30 #include "chrome/browser/chromeos/app_mode/kiosk_app_launcher.h" | |
31 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 30 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
32 #include "chrome/browser/chromeos/boot_times_loader.h" | 31 #include "chrome/browser/chromeos/boot_times_loader.h" |
33 #include "chrome/browser/chromeos/contacts/contact_manager.h" | 32 #include "chrome/browser/chromeos/contacts/contact_manager.h" |
34 #include "chrome/browser/chromeos/cros/cert_library.h" | 33 #include "chrome/browser/chromeos/cros/cert_library.h" |
35 #include "chrome/browser/chromeos/cros/network_library.h" | 34 #include "chrome/browser/chromeos/cros/network_library.h" |
36 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" | 35 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" |
37 #include "chrome/browser/chromeos/display/display_configuration_observer.h" | 36 #include "chrome/browser/chromeos/display/display_configuration_observer.h" |
38 #include "chrome/browser/chromeos/extensions/default_app_order.h" | 37 #include "chrome/browser/chromeos/extensions/default_app_order.h" |
39 #include "chrome/browser/chromeos/external_metrics.h" | 38 #include "chrome/browser/chromeos/external_metrics.h" |
40 #include "chrome/browser/chromeos/imageburner/burn_manager.h" | 39 #include "chrome/browser/chromeos/imageburner/burn_manager.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 }; | 194 }; |
196 | 195 |
197 bool ShouldAutoLaunchKioskApp(const CommandLine& command_line) { | 196 bool ShouldAutoLaunchKioskApp(const CommandLine& command_line) { |
198 KioskAppManager* app_manager = KioskAppManager::Get(); | 197 KioskAppManager* app_manager = KioskAppManager::Get(); |
199 return command_line.HasSwitch(switches::kLoginManager) && | 198 return command_line.HasSwitch(switches::kLoginManager) && |
200 !command_line.HasSwitch(switches::kForceLoginManagerInTests) && | 199 !command_line.HasSwitch(switches::kForceLoginManagerInTests) && |
201 app_manager->IsAutoLaunchEnabled() && | 200 app_manager->IsAutoLaunchEnabled() && |
202 KioskAppLaunchError::Get() == KioskAppLaunchError::NONE; | 201 KioskAppLaunchError::Get() == KioskAppLaunchError::NONE; |
203 } | 202 } |
204 | 203 |
| 204 void RunAutoLaunchKioskApp() { |
| 205 ShowLoginWizard(chromeos::WizardController::kAppLaunchSplashScreenName); |
| 206 |
| 207 // Login screen is skipped but 'login-prompt-visible' signal is still needed. |
| 208 LOG(INFO) << "Kiosk app auto launch >> login-prompt-visible"; |
| 209 DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 210 EmitLoginPromptVisible(); |
| 211 } |
| 212 |
205 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, | 213 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, |
206 Profile* profile) { | 214 Profile* profile) { |
207 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { | 215 if (ShouldAutoLaunchKioskApp(parsed_command_line)) { |
| 216 RunAutoLaunchKioskApp(); |
| 217 } else if (parsed_command_line.HasSwitch(switches::kLoginManager)) { |
208 const std::string first_screen = | 218 const std::string first_screen = |
209 parsed_command_line.HasSwitch(switches::kLoginScreen) ? | 219 parsed_command_line.HasSwitch(switches::kLoginScreen) ? |
210 WizardController::kLoginScreenName : std::string(); | 220 WizardController::kLoginScreenName : std::string(); |
211 ShowLoginWizard(first_screen); | 221 ShowLoginWizard(first_screen); |
212 | 222 |
213 if (KioskModeSettings::Get()->IsKioskModeEnabled()) | 223 if (KioskModeSettings::Get()->IsKioskModeEnabled()) |
214 InitializeKioskModeScreensaver(); | 224 InitializeKioskModeScreensaver(); |
215 | 225 |
216 // Reset reboot after update flag when login screen is shown. | 226 // Reset reboot after update flag when login screen is shown. |
217 if (!g_browser_process->browser_policy_connector()-> | 227 if (!g_browser_process->browser_policy_connector()-> |
218 IsEnterpriseManaged()) { | 228 IsEnterpriseManaged()) { |
219 PrefService* local_state = g_browser_process->local_state(); | 229 PrefService* local_state = g_browser_process->local_state(); |
220 local_state->ClearPref(prefs::kRebootAfterUpdate); | 230 local_state->ClearPref(prefs::kRebootAfterUpdate); |
221 } | 231 } |
222 } else if (parsed_command_line.HasSwitch(switches::kLoginUser) && | 232 } else if (parsed_command_line.HasSwitch(switches::kLoginUser) && |
223 parsed_command_line.HasSwitch(switches::kLoginPassword)) { | 233 parsed_command_line.HasSwitch(switches::kLoginPassword)) { |
224 BootTimesLoader::Get()->RecordLoginAttempted(); | 234 BootTimesLoader::Get()->RecordLoginAttempted(); |
225 new StubLogin( | 235 new StubLogin( |
226 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser), | 236 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser), |
227 parsed_command_line.GetSwitchValueASCII(switches::kLoginPassword)); | 237 parsed_command_line.GetSwitchValueASCII(switches::kLoginPassword)); |
228 } else { | 238 } else { |
229 if (!parsed_command_line.HasSwitch(::switches::kTestName)) { | 239 if (!parsed_command_line.HasSwitch(::switches::kTestName)) { |
230 // We did not log in (we crashed or are debugging), so we need to | 240 // We did not log in (we crashed or are debugging), so we need to |
231 // restore Sync. | 241 // restore Sync. |
232 LoginUtils::Get()->RestoreAuthenticationSession(profile); | 242 LoginUtils::Get()->RestoreAuthenticationSession(profile); |
233 } | 243 } |
234 } | 244 } |
235 } | 245 } |
236 | 246 |
237 void RunAutoLaunchKioskApp() { | |
238 // KioskAppLauncher deletes itself when done. | |
239 (new KioskAppLauncher(KioskAppManager::Get(), | |
240 KioskAppManager::Get()->GetAutoLaunchApp()))->Start(); | |
241 | |
242 // Login screen is skipped but 'login-prompt-visible' signal is still needed. | |
243 LOG(INFO) << "Kiosk app auto launch >> login-prompt-visible"; | |
244 DBusThreadManager::Get()->GetSessionManagerClient()-> | |
245 EmitLoginPromptVisible(); | |
246 } | |
247 | |
248 } // namespace | 247 } // namespace |
249 | 248 |
250 namespace internal { | 249 namespace internal { |
251 | 250 |
252 // Wrapper class for initializing dbus related services and shutting them | 251 // Wrapper class for initializing dbus related services and shutting them |
253 // down. This gets instantiated in a scoped_ptr so that shutdown methods in the | 252 // down. This gets instantiated in a scoped_ptr so that shutdown methods in the |
254 // destructor will get called if and only if this has been instantiated. | 253 // destructor will get called if and only if this has been instantiated. |
255 class DBusServices { | 254 class DBusServices { |
256 public: | 255 public: |
257 explicit DBusServices(const content::MainFunctionParams& parameters) | 256 explicit DBusServices(const content::MainFunctionParams& parameters) |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 // statistics early in PreEarlyInitialization() then the crossystem tool | 589 // statistics early in PreEarlyInitialization() then the crossystem tool |
591 // sometimes hangs for unknown reasons, see http://crbug.com/167671. | 590 // sometimes hangs for unknown reasons, see http://crbug.com/167671. |
592 // Also we must start loading no later than this point, because login manager | 591 // Also we must start loading no later than this point, because login manager |
593 // may call GetMachineStatistic() during startup, see crbug.com/170635. | 592 // may call GetMachineStatistic() during startup, see crbug.com/170635. |
594 system::StatisticsProvider::GetInstance()->StartLoadingMachineStatistics(); | 593 system::StatisticsProvider::GetInstance()->StartLoadingMachineStatistics(); |
595 | 594 |
596 // Tests should be able to tune login manager before showing it. | 595 // Tests should be able to tune login manager before showing it. |
597 // Thus only show login manager in normal (non-testing) mode. | 596 // Thus only show login manager in normal (non-testing) mode. |
598 if (!parameters().ui_task || | 597 if (!parameters().ui_task || |
599 parsed_command_line().HasSwitch(switches::kForceLoginManagerInTests)) { | 598 parsed_command_line().HasSwitch(switches::kForceLoginManagerInTests)) { |
600 if (ShouldAutoLaunchKioskApp(parsed_command_line())) { | 599 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); |
601 RunAutoLaunchKioskApp(); | |
602 } else { | |
603 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); | |
604 } | |
605 } | 600 } |
606 | 601 |
607 // These observers must be initialized after the profile because | 602 // These observers must be initialized after the profile because |
608 // they use the profile to dispatch extension events. | 603 // they use the profile to dispatch extension events. |
609 // | 604 // |
610 // Initialize the brightness observer so that we'll display an onscreen | 605 // Initialize the brightness observer so that we'll display an onscreen |
611 // indication of brightness changes during login. | 606 // indication of brightness changes during login. |
612 brightness_observer_.reset(new BrightnessObserver()); | 607 brightness_observer_.reset(new BrightnessObserver()); |
613 resume_observer_.reset(new ResumeObserver()); | 608 resume_observer_.reset(new ResumeObserver()); |
614 screen_lock_observer_.reset(new ScreenLockObserver()); | 609 screen_lock_observer_.reset(new ScreenLockObserver()); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 | 797 |
803 // Destroy DeviceSettingsService after g_browser_process. | 798 // Destroy DeviceSettingsService after g_browser_process. |
804 DeviceSettingsService::Shutdown(); | 799 DeviceSettingsService::Shutdown(); |
805 } | 800 } |
806 | 801 |
807 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { | 802 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { |
808 default_pinned_apps_field_trial::SetupTrial(); | 803 default_pinned_apps_field_trial::SetupTrial(); |
809 } | 804 } |
810 | 805 |
811 } // namespace chromeos | 806 } // namespace chromeos |
OLD | NEW |