| 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 "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 diagnostic_mode_(diagnostic_mode), | 112 diagnostic_mode_(diagnostic_mode), |
| 113 host_(host), | 113 host_(host), |
| 114 oobe_display_(oobe_display), | 114 oobe_display_(oobe_display), |
| 115 app_launch_splash_screen_actor_( | 115 app_launch_splash_screen_actor_( |
| 116 oobe_display_->GetAppLaunchSplashScreenActor()), | 116 oobe_display_->GetAppLaunchSplashScreenActor()), |
| 117 webui_visible_(false), | 117 webui_visible_(false), |
| 118 launcher_ready_(false), | 118 launcher_ready_(false), |
| 119 waiting_for_network_(false), | 119 waiting_for_network_(false), |
| 120 network_wait_timedout_(false), | 120 network_wait_timedout_(false), |
| 121 showing_network_dialog_(false), | 121 showing_network_dialog_(false), |
| 122 network_config_requested_(false), | |
| 123 launch_splash_start_time_(0) { | 122 launch_splash_start_time_(0) { |
| 124 } | 123 } |
| 125 | 124 |
| 126 AppLaunchController::~AppLaunchController() { | 125 AppLaunchController::~AppLaunchController() { |
| 127 app_launch_splash_screen_actor_->SetDelegate(NULL); | 126 app_launch_splash_screen_actor_->SetDelegate(NULL); |
| 128 } | 127 } |
| 129 | 128 |
| 130 void AppLaunchController::StartAppLaunch() { | 129 void AppLaunchController::StartAppLaunch() { |
| 131 DVLOG(1) << "Starting kiosk mode..."; | 130 DVLOG(1) << "Starting kiosk mode..."; |
| 132 | 131 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 OnReadyToLaunch(); | 209 OnReadyToLaunch(); |
| 211 } | 210 } |
| 212 | 211 |
| 213 void AppLaunchController::OnCancelAppLaunch() { | 212 void AppLaunchController::OnCancelAppLaunch() { |
| 214 if (KioskAppManager::Get()->GetDisableBailoutShortcut()) | 213 if (KioskAppManager::Get()->GetDisableBailoutShortcut()) |
| 215 return; | 214 return; |
| 216 | 215 |
| 217 OnLaunchFailed(KioskAppLaunchError::USER_CANCEL); | 216 OnLaunchFailed(KioskAppLaunchError::USER_CANCEL); |
| 218 } | 217 } |
| 219 | 218 |
| 220 void AppLaunchController::OnNetworkConfigRequested(bool requested) { | |
| 221 network_config_requested_ = requested; | |
| 222 if (requested) | |
| 223 MaybeShowNetworkConfigureUI(); | |
| 224 else | |
| 225 startup_app_launcher_->RestartLauncher(); | |
| 226 } | |
| 227 | |
| 228 void AppLaunchController::OnNetworkStateChanged(bool online) { | 219 void AppLaunchController::OnNetworkStateChanged(bool online) { |
| 229 if (!waiting_for_network_) | 220 if (!waiting_for_network_) |
| 230 return; | 221 return; |
| 231 | 222 |
| 232 if (online && !network_config_requested_) | 223 if (online) |
| 233 startup_app_launcher_->ContinueWithNetworkReady(); | 224 startup_app_launcher_->ContinueWithNetworkReady(); |
| 234 else if (network_wait_timedout_) | 225 else if (network_wait_timedout_) |
| 235 MaybeShowNetworkConfigureUI(); | 226 MaybeShowNetworkConfigureUI(); |
| 236 } | 227 } |
| 237 | 228 |
| 238 void AppLaunchController::OnProfileLoaded(Profile* profile) { | 229 void AppLaunchController::OnProfileLoaded(Profile* profile) { |
| 239 DVLOG(1) << "Profile loaded... Starting app launch."; | 230 DVLOG(1) << "Profile loaded... Starting app launch."; |
| 240 profile_ = profile; | 231 profile_ = profile; |
| 241 | 232 |
| 242 kiosk_profile_loader_.reset(); | 233 kiosk_profile_loader_.reset(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 return need_owner_auth_to_configure_network_callback_->Run(); | 293 return need_owner_auth_to_configure_network_callback_->Run(); |
| 303 | 294 |
| 304 policy::BrowserPolicyConnectorChromeOS* connector = | 295 policy::BrowserPolicyConnectorChromeOS* connector = |
| 305 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 296 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 306 return !connector->IsEnterpriseManaged(); | 297 return !connector->IsEnterpriseManaged(); |
| 307 } | 298 } |
| 308 | 299 |
| 309 void AppLaunchController::MaybeShowNetworkConfigureUI() { | 300 void AppLaunchController::MaybeShowNetworkConfigureUI() { |
| 310 if (CanConfigureNetwork()) { | 301 if (CanConfigureNetwork()) { |
| 311 if (NeedOwnerAuthToConfigureNetwork()) { | 302 if (NeedOwnerAuthToConfigureNetwork()) { |
| 312 if (network_config_requested_) | 303 app_launch_splash_screen_actor_->ToggleNetworkConfig(true); |
| 313 OnConfigureNetwork(); | |
| 314 else | |
| 315 app_launch_splash_screen_actor_->ToggleNetworkConfig(true); | |
| 316 } else { | 304 } else { |
| 317 showing_network_dialog_ = true; | 305 showing_network_dialog_ = true; |
| 318 app_launch_splash_screen_actor_->ShowNetworkConfigureUI(); | 306 app_launch_splash_screen_actor_->ShowNetworkConfigureUI(); |
| 319 } | 307 } |
| 320 } else { | 308 } else { |
| 321 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 309 app_launch_splash_screen_actor_->UpdateAppLaunchState( |
| 322 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT); | 310 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT); |
| 323 } | 311 } |
| 324 } | 312 } |
| 325 | 313 |
| 326 void AppLaunchController::InitializeNetwork() { | 314 void AppLaunchController::InitializeNetwork() { |
| 327 // Show the network configuration dialog if network is not initialized | 315 // Show the network configration dialog if network is not initialized |
| 328 // after a brief wait time. | 316 // after a brief wait time. |
| 329 waiting_for_network_ = true; | 317 waiting_for_network_ = true; |
| 330 network_wait_timer_.Start( | 318 network_wait_timer_.Start( |
| 331 FROM_HERE, | 319 FROM_HERE, |
| 332 base::TimeDelta::FromSeconds(network_wait_time_), | 320 base::TimeDelta::FromSeconds(network_wait_time_), |
| 333 this, &AppLaunchController::OnNetworkWaitTimedout); | 321 this, &AppLaunchController::OnNetworkWaitTimedout); |
| 334 | 322 |
| 335 app_launch_splash_screen_actor_->UpdateAppLaunchState( | 323 app_launch_splash_screen_actor_->UpdateAppLaunchState( |
| 336 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_PREPARING_NETWORK); | 324 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_PREPARING_NETWORK); |
| 337 } | 325 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 362 // configuration dialog if it is being shown. | 350 // configuration dialog if it is being shown. |
| 363 if (showing_network_dialog_) { | 351 if (showing_network_dialog_) { |
| 364 app_launch_splash_screen_actor_->Show(app_id_); | 352 app_launch_splash_screen_actor_->Show(app_id_); |
| 365 showing_network_dialog_ = false; | 353 showing_network_dialog_ = false; |
| 366 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue(); | 354 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue(); |
| 367 } | 355 } |
| 368 } | 356 } |
| 369 | 357 |
| 370 void AppLaunchController::OnReadyToLaunch() { | 358 void AppLaunchController::OnReadyToLaunch() { |
| 371 launcher_ready_ = true; | 359 launcher_ready_ = true; |
| 372 | |
| 373 if (network_config_requested_) | |
| 374 return; | |
| 375 | |
| 376 if (!webui_visible_) | 360 if (!webui_visible_) |
| 377 return; | 361 return; |
| 378 | 362 |
| 379 if (splash_wait_timer_.IsRunning()) | 363 if (splash_wait_timer_.IsRunning()) |
| 380 return; | 364 return; |
| 381 | 365 |
| 382 const int64 time_taken_ms = (base::TimeTicks::Now() - | 366 const int64 time_taken_ms = (base::TimeTicks::Now() - |
| 383 base::TimeTicks::FromInternalValue(launch_splash_start_time_)). | 367 base::TimeTicks::FromInternalValue(launch_splash_start_time_)). |
| 384 InMilliseconds(); | 368 InMilliseconds(); |
| 385 | 369 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 411 LOG(ERROR) << "Kiosk launch failed. Will now shut down." | 395 LOG(ERROR) << "Kiosk launch failed. Will now shut down." |
| 412 << ", error=" << error; | 396 << ", error=" << error; |
| 413 DCHECK_NE(KioskAppLaunchError::NONE, error); | 397 DCHECK_NE(KioskAppLaunchError::NONE, error); |
| 414 | 398 |
| 415 // Saves the error and ends the session to go back to login screen. | 399 // Saves the error and ends the session to go back to login screen. |
| 416 KioskAppLaunchError::Save(error); | 400 KioskAppLaunchError::Save(error); |
| 417 chrome::AttemptUserExit(); | 401 chrome::AttemptUserExit(); |
| 418 CleanUp(); | 402 CleanUp(); |
| 419 } | 403 } |
| 420 | 404 |
| 421 bool AppLaunchController::IsShowingNetworkConfigScreen() { | |
| 422 return network_config_requested_; | |
| 423 } | |
| 424 | |
| 425 } // namespace chromeos | 405 } // namespace chromeos |
| OLD | NEW |