OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/login/app_launch_controller.h" | 5 #include "chrome/browser/chromeos/login/app_launch_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // AppLaunchController | 143 // AppLaunchController |
144 | 144 |
145 AppLaunchController::AppLaunchController(const std::string& app_id, | 145 AppLaunchController::AppLaunchController(const std::string& app_id, |
146 bool diagnostic_mode, | 146 bool diagnostic_mode, |
147 LoginDisplayHost* host, | 147 LoginDisplayHost* host, |
148 OobeUI* oobe_ui) | 148 OobeUI* oobe_ui) |
149 : app_id_(app_id), | 149 : app_id_(app_id), |
150 diagnostic_mode_(diagnostic_mode), | 150 diagnostic_mode_(diagnostic_mode), |
151 host_(host), | 151 host_(host), |
152 oobe_ui_(oobe_ui), | 152 oobe_ui_(oobe_ui), |
153 app_launch_splash_screen_actor_( | 153 app_launch_splash_screen_view_(oobe_ui_->GetAppLaunchSplashScreenView()) { |
154 oobe_ui_->GetAppLaunchSplashScreenActor()) {} | 154 } |
155 | 155 |
156 AppLaunchController::~AppLaunchController() { | 156 AppLaunchController::~AppLaunchController() { |
157 app_launch_splash_screen_actor_->SetDelegate(NULL); | 157 app_launch_splash_screen_view_->SetDelegate(NULL); |
158 } | 158 } |
159 | 159 |
160 void AppLaunchController::StartAppLaunch(bool is_auto_launch) { | 160 void AppLaunchController::StartAppLaunch(bool is_auto_launch) { |
161 DVLOG(1) << "Starting kiosk mode..."; | 161 DVLOG(1) << "Starting kiosk mode..."; |
162 | 162 |
163 RecordKioskLaunchUMA(is_auto_launch); | 163 RecordKioskLaunchUMA(is_auto_launch); |
164 | 164 |
165 // Ensure WebUILoginView is enabled so that bailout shortcut key works. | 165 // Ensure WebUILoginView is enabled so that bailout shortcut key works. |
166 host_->GetWebUILoginView()->SetUIEnabled(true); | 166 host_->GetWebUILoginView()->SetUIEnabled(true); |
167 | 167 |
168 webui_visible_ = host_->GetWebUILoginView()->webui_visible(); | 168 webui_visible_ = host_->GetWebUILoginView()->webui_visible(); |
169 if (!webui_visible_) { | 169 if (!webui_visible_) { |
170 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 170 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
171 content::NotificationService::AllSources()); | 171 content::NotificationService::AllSources()); |
172 } | 172 } |
173 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue(); | 173 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue(); |
174 | 174 |
175 // TODO(tengs): Add a loading profile app launch state. | 175 // TODO(tengs): Add a loading profile app launch state. |
176 app_launch_splash_screen_actor_->SetDelegate(this); | 176 app_launch_splash_screen_view_->SetDelegate(this); |
177 app_launch_splash_screen_actor_->Show(app_id_); | 177 app_launch_splash_screen_view_->Show(app_id_); |
178 | 178 |
179 KioskAppManager::App app; | 179 KioskAppManager::App app; |
180 CHECK(KioskAppManager::Get()); | 180 CHECK(KioskAppManager::Get()); |
181 CHECK(KioskAppManager::Get()->GetApp(app_id_, &app)); | 181 CHECK(KioskAppManager::Get()->GetApp(app_id_, &app)); |
182 | 182 |
183 int auto_launch_delay = -1; | 183 int auto_launch_delay = -1; |
184 if (is_auto_launch) { | 184 if (is_auto_launch) { |
185 if (!CrosSettings::Get()->GetInteger( | 185 if (!CrosSettings::Get()->GetInteger( |
186 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 186 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
187 &auto_launch_delay)) { | 187 &auto_launch_delay)) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return; | 273 return; |
274 | 274 |
275 OnLaunchFailed(KioskAppLaunchError::USER_CANCEL); | 275 OnLaunchFailed(KioskAppLaunchError::USER_CANCEL); |
276 } | 276 } |
277 | 277 |
278 void AppLaunchController::OnNetworkConfigRequested(bool requested) { | 278 void AppLaunchController::OnNetworkConfigRequested(bool requested) { |
279 network_config_requested_ = requested; | 279 network_config_requested_ = requested; |
280 if (requested) { | 280 if (requested) { |
281 MaybeShowNetworkConfigureUI(); | 281 MaybeShowNetworkConfigureUI(); |
282 } else { | 282 } else { |
283 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 283 app_launch_splash_screen_view_->UpdateAppLaunchState( |
284 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_PREPARING_NETWORK); | 284 AppLaunchSplashScreenView::APP_LAUNCH_STATE_PREPARING_NETWORK); |
285 startup_app_launcher_->RestartLauncher(); | 285 startup_app_launcher_->RestartLauncher(); |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 void AppLaunchController::OnNetworkStateChanged(bool online) { | 289 void AppLaunchController::OnNetworkStateChanged(bool online) { |
290 if (!waiting_for_network_) | 290 if (!waiting_for_network_) |
291 return; | 291 return; |
292 | 292 |
293 if (online && !network_config_requested_) | 293 if (online && !network_config_requested_) |
294 startup_app_launcher_->ContinueWithNetworkReady(); | 294 startup_app_launcher_->ContinueWithNetworkReady(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 return !IsEnterpriseManaged(); | 375 return !IsEnterpriseManaged(); |
376 } | 376 } |
377 | 377 |
378 void AppLaunchController::MaybeShowNetworkConfigureUI() { | 378 void AppLaunchController::MaybeShowNetworkConfigureUI() { |
379 if (CanConfigureNetwork()) { | 379 if (CanConfigureNetwork()) { |
380 if (NeedOwnerAuthToConfigureNetwork()) { | 380 if (NeedOwnerAuthToConfigureNetwork()) { |
381 if (network_config_requested_) | 381 if (network_config_requested_) |
382 OnConfigureNetwork(); | 382 OnConfigureNetwork(); |
383 else | 383 else |
384 app_launch_splash_screen_actor_->ToggleNetworkConfig(true); | 384 app_launch_splash_screen_view_->ToggleNetworkConfig(true); |
385 } else { | 385 } else { |
386 ShowNetworkConfigureUIWhenReady(); | 386 ShowNetworkConfigureUIWhenReady(); |
387 } | 387 } |
388 } else { | 388 } else { |
389 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 389 app_launch_splash_screen_view_->UpdateAppLaunchState( |
390 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT); | 390 AppLaunchSplashScreenView::APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 void AppLaunchController::ShowNetworkConfigureUIWhenReady() { | 394 void AppLaunchController::ShowNetworkConfigureUIWhenReady() { |
395 if (!profile_) { | 395 if (!profile_) { |
396 show_network_config_ui_after_profile_load_ = true; | 396 show_network_config_ui_after_profile_load_ = true; |
397 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 397 app_launch_splash_screen_view_->UpdateAppLaunchState( |
398 AppLaunchSplashScreenActor:: | 398 AppLaunchSplashScreenView:: |
399 APP_LAUNCH_STATE_SHOWING_NETWORK_CONFIGURE_UI); | 399 APP_LAUNCH_STATE_SHOWING_NETWORK_CONFIGURE_UI); |
400 return; | 400 return; |
401 } | 401 } |
402 | 402 |
403 show_network_config_ui_after_profile_load_ = false; | 403 show_network_config_ui_after_profile_load_ = false; |
404 showing_network_dialog_ = true; | 404 showing_network_dialog_ = true; |
405 app_launch_splash_screen_actor_->ShowNetworkConfigureUI(); | 405 app_launch_splash_screen_view_->ShowNetworkConfigureUI(); |
406 } | 406 } |
407 | 407 |
408 void AppLaunchController::InitializeNetwork() { | 408 void AppLaunchController::InitializeNetwork() { |
409 // Show the network configuration dialog if network is not initialized | 409 // Show the network configuration dialog if network is not initialized |
410 // after a brief wait time. | 410 // after a brief wait time. |
411 waiting_for_network_ = true; | 411 waiting_for_network_ = true; |
412 network_wait_timer_.Start( | 412 network_wait_timer_.Start( |
413 FROM_HERE, | 413 FROM_HERE, |
414 base::TimeDelta::FromSeconds(network_wait_time_), | 414 base::TimeDelta::FromSeconds(network_wait_time_), |
415 this, &AppLaunchController::OnNetworkWaitTimedout); | 415 this, &AppLaunchController::OnNetworkWaitTimedout); |
416 | 416 |
417 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 417 app_launch_splash_screen_view_->UpdateAppLaunchState( |
418 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_PREPARING_NETWORK); | 418 AppLaunchSplashScreenView::APP_LAUNCH_STATE_PREPARING_NETWORK); |
419 } | 419 } |
420 | 420 |
421 bool AppLaunchController::IsNetworkReady() { | 421 bool AppLaunchController::IsNetworkReady() { |
422 return app_launch_splash_screen_actor_->IsNetworkReady(); | 422 return app_launch_splash_screen_view_->IsNetworkReady(); |
423 } | 423 } |
424 | 424 |
425 bool AppLaunchController::ShouldSkipAppInstallation() { | 425 bool AppLaunchController::ShouldSkipAppInstallation() { |
426 return false; | 426 return false; |
427 } | 427 } |
428 | 428 |
429 void AppLaunchController::OnLoadingOAuthFile() { | 429 void AppLaunchController::OnLoadingOAuthFile() { |
430 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 430 app_launch_splash_screen_view_->UpdateAppLaunchState( |
431 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_LOADING_AUTH_FILE); | 431 AppLaunchSplashScreenView::APP_LAUNCH_STATE_LOADING_AUTH_FILE); |
432 } | 432 } |
433 | 433 |
434 void AppLaunchController::OnInitializingTokenService() { | 434 void AppLaunchController::OnInitializingTokenService() { |
435 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 435 app_launch_splash_screen_view_->UpdateAppLaunchState( |
436 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_LOADING_TOKEN_SERVICE); | 436 AppLaunchSplashScreenView::APP_LAUNCH_STATE_LOADING_TOKEN_SERVICE); |
437 } | 437 } |
438 | 438 |
439 void AppLaunchController::OnInstallingApp() { | 439 void AppLaunchController::OnInstallingApp() { |
440 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 440 app_launch_splash_screen_view_->UpdateAppLaunchState( |
441 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_INSTALLING_APPLICATION); | 441 AppLaunchSplashScreenView::APP_LAUNCH_STATE_INSTALLING_APPLICATION); |
442 | 442 |
443 ClearNetworkWaitTimer(); | 443 ClearNetworkWaitTimer(); |
444 app_launch_splash_screen_actor_->ToggleNetworkConfig(false); | 444 app_launch_splash_screen_view_->ToggleNetworkConfig(false); |
445 | 445 |
446 // We have connectivity at this point, so we can skip the network | 446 // We have connectivity at this point, so we can skip the network |
447 // configuration dialog if it is being shown. | 447 // configuration dialog if it is being shown. |
448 if (showing_network_dialog_) { | 448 if (showing_network_dialog_) { |
449 app_launch_splash_screen_actor_->Show(app_id_); | 449 app_launch_splash_screen_view_->Show(app_id_); |
450 showing_network_dialog_ = false; | 450 showing_network_dialog_ = false; |
451 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue(); | 451 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue(); |
452 } | 452 } |
453 } | 453 } |
454 | 454 |
455 void AppLaunchController::OnReadyToLaunch() { | 455 void AppLaunchController::OnReadyToLaunch() { |
456 launcher_ready_ = true; | 456 launcher_ready_ = true; |
457 | 457 |
458 if (network_config_requested_) | 458 if (network_config_requested_) |
459 return; | 459 return; |
(...skipping 21 matching lines...) Expand all Loading... |
481 this, | 481 this, |
482 &AppLaunchController::OnReadyToLaunch); | 482 &AppLaunchController::OnReadyToLaunch); |
483 return; | 483 return; |
484 } | 484 } |
485 | 485 |
486 startup_app_launcher_->LaunchApp(); | 486 startup_app_launcher_->LaunchApp(); |
487 } | 487 } |
488 | 488 |
489 void AppLaunchController::OnLaunchSucceeded() { | 489 void AppLaunchController::OnLaunchSucceeded() { |
490 DVLOG(1) << "Kiosk launch succeeded, wait for app window."; | 490 DVLOG(1) << "Kiosk launch succeeded, wait for app window."; |
491 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 491 app_launch_splash_screen_view_->UpdateAppLaunchState( |
492 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_WAITING_APP_WINDOW); | 492 AppLaunchSplashScreenView::APP_LAUNCH_STATE_WAITING_APP_WINDOW); |
493 | 493 |
494 DCHECK(!app_window_watcher_); | 494 DCHECK(!app_window_watcher_); |
495 app_window_watcher_.reset(new AppWindowWatcher(this, app_id_)); | 495 app_window_watcher_.reset(new AppWindowWatcher(this, app_id_)); |
496 } | 496 } |
497 | 497 |
498 void AppLaunchController::OnLaunchFailed(KioskAppLaunchError::Error error) { | 498 void AppLaunchController::OnLaunchFailed(KioskAppLaunchError::Error error) { |
499 DCHECK_NE(KioskAppLaunchError::NONE, error); | 499 DCHECK_NE(KioskAppLaunchError::NONE, error); |
500 LOG(ERROR) << "Kiosk launch failed, error=" << error; | 500 LOG(ERROR) << "Kiosk launch failed, error=" << error; |
501 | 501 |
502 // Reboot on the recoverable cryptohome errors. | 502 // Reboot on the recoverable cryptohome errors. |
503 if (error == KioskAppLaunchError::CRYPTOHOMED_NOT_RUNNING || | 503 if (error == KioskAppLaunchError::CRYPTOHOMED_NOT_RUNNING || |
504 error == KioskAppLaunchError::ALREADY_MOUNTED) { | 504 error == KioskAppLaunchError::ALREADY_MOUNTED) { |
505 // Do not save the error because saved errors would stop app from launching | 505 // Do not save the error because saved errors would stop app from launching |
506 // on the next run. | 506 // on the next run. |
507 chrome::AttemptRelaunch(); | 507 chrome::AttemptRelaunch(); |
508 return; | 508 return; |
509 } | 509 } |
510 | 510 |
511 // Saves the error and ends the session to go back to login screen. | 511 // Saves the error and ends the session to go back to login screen. |
512 KioskAppLaunchError::Save(error); | 512 KioskAppLaunchError::Save(error); |
513 chrome::AttemptUserExit(); | 513 chrome::AttemptUserExit(); |
514 CleanUp(); | 514 CleanUp(); |
515 } | 515 } |
516 | 516 |
517 bool AppLaunchController::IsShowingNetworkConfigScreen() { | 517 bool AppLaunchController::IsShowingNetworkConfigScreen() { |
518 return network_config_requested_; | 518 return network_config_requested_; |
519 } | 519 } |
520 | 520 |
521 } // namespace chromeos | 521 } // namespace chromeos |
OLD | NEW |