Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: chrome/browser/chromeos/login/app_launch_controller.cc

Issue 127183002: kiosk: Fix StartupAppLauncher::LaunchApp crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: per discussion Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/login/app_launch_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/shell_window_registry.h" 7 #include "apps/shell_window_registry.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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h" 15 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h"
16 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 16 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
17 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h" 17 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h"
18 #include "chrome/browser/chromeos/login/login_display_host.h" 18 #include "chrome/browser/chromeos/login/login_display_host.h"
19 #include "chrome/browser/chromeos/login/login_display_host_impl.h" 19 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
20 #include "chrome/browser/chromeos/login/oobe_display.h" 20 #include "chrome/browser/chromeos/login/oobe_display.h"
21 #include "chrome/browser/chromeos/login/screens/error_screen_actor.h" 21 #include "chrome/browser/chromeos/login/screens/error_screen_actor.h"
22 #include "chrome/browser/chromeos/login/webui_login_view.h" 22 #include "chrome/browser/chromeos/login/webui_login_view.h"
23 #include "chrome/browser/chromeos/settings/cros_settings.h" 23 #include "chrome/browser/chromeos/settings/cros_settings.h"
24 #include "chrome/browser/lifetime/application_lifetime.h" 24 #include "chrome/browser/lifetime/application_lifetime.h"
25 #include "chrome/browser/policy/browser_policy_connector.h" 25 #include "chrome/browser/policy/browser_policy_connector.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handle r.h" 27 #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handle r.h"
28 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 28 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
31 #include "net/base/network_change_notifier.h" 30 #include "net/base/network_change_notifier.h"
32 31
33 namespace chromeos { 32 namespace chromeos {
34 33
35 namespace { 34 namespace {
36 35
37 // Application install splash screen minimum show time in milliseconds. 36 // Application install splash screen minimum show time in milliseconds.
38 const int kAppInstallSplashScreenMinTimeMS = 3000; 37 const int kAppInstallSplashScreenMinTimeMS = 3000;
39 38
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 211 }
213 212
214 void AppLaunchController::OnProfileLoadFailed( 213 void AppLaunchController::OnProfileLoadFailed(
215 KioskAppLaunchError::Error error) { 214 KioskAppLaunchError::Error error) {
216 OnLaunchFailed(error); 215 OnLaunchFailed(error);
217 } 216 }
218 217
219 void AppLaunchController::CleanUp() { 218 void AppLaunchController::CleanUp() {
220 kiosk_profile_loader_.reset(); 219 kiosk_profile_loader_.reset();
221 startup_app_launcher_.reset(); 220 startup_app_launcher_.reset();
221 splash_wait_timer_.Stop();
222 222
223 if (host_) 223 if (host_)
224 host_->Finalize(); 224 host_->Finalize();
225 } 225 }
226 226
227 void AppLaunchController::OnNetworkWaitTimedout() { 227 void AppLaunchController::OnNetworkWaitTimedout() {
228 DCHECK(waiting_for_network_); 228 DCHECK(waiting_for_network_);
229 LOG(WARNING) << "OnNetworkWaitTimedout... connection = " 229 LOG(WARNING) << "OnNetworkWaitTimedout... connection = "
230 << net::NetworkChangeNotifier::GetConnectionType(); 230 << net::NetworkChangeNotifier::GetConnectionType();
231 network_wait_timedout_ = true; 231 network_wait_timedout_ = true;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 showing_network_dialog_ = false; 319 showing_network_dialog_ = false;
320 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue(); 320 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue();
321 } 321 }
322 } 322 }
323 323
324 void AppLaunchController::OnReadyToLaunch() { 324 void AppLaunchController::OnReadyToLaunch() {
325 launcher_ready_ = true; 325 launcher_ready_ = true;
326 if (!webui_visible_) 326 if (!webui_visible_)
327 return; 327 return;
328 328
329 if (splash_wait_timer_.IsRunning())
330 return;
331
329 const int64 time_taken_ms = (base::TimeTicks::Now() - 332 const int64 time_taken_ms = (base::TimeTicks::Now() -
330 base::TimeTicks::FromInternalValue(launch_splash_start_time_)). 333 base::TimeTicks::FromInternalValue(launch_splash_start_time_)).
331 InMilliseconds(); 334 InMilliseconds();
332 335
333 // Enforce that we show app install splash screen for some minimum amount 336 // Enforce that we show app install splash screen for some minimum amount
334 // of time. 337 // of time.
335 if (!skip_splash_wait_ && time_taken_ms < kAppInstallSplashScreenMinTimeMS) { 338 if (!skip_splash_wait_ && time_taken_ms < kAppInstallSplashScreenMinTimeMS) {
336 content::BrowserThread::PostDelayedTask( 339 splash_wait_timer_.Start(
337 content::BrowserThread::UI,
338 FROM_HERE, 340 FROM_HERE,
339 base::Bind(&AppLaunchController::OnReadyToLaunch, AsWeakPtr()),
340 base::TimeDelta::FromMilliseconds( 341 base::TimeDelta::FromMilliseconds(
341 kAppInstallSplashScreenMinTimeMS - time_taken_ms)); 342 kAppInstallSplashScreenMinTimeMS - time_taken_ms),
343 this,
344 &AppLaunchController::OnReadyToLaunch);
342 return; 345 return;
343 } 346 }
344 347
345 startup_app_launcher_->LaunchApp(); 348 startup_app_launcher_->LaunchApp();
346 } 349 }
347 350
348 void AppLaunchController::OnLaunchSucceeded() { 351 void AppLaunchController::OnLaunchSucceeded() {
349 DVLOG(1) << "Kiosk launch succeeded, wait for app window."; 352 DVLOG(1) << "Kiosk launch succeeded, wait for app window.";
350 app_launch_splash_screen_actor_->UpdateAppLaunchState( 353 app_launch_splash_screen_actor_->UpdateAppLaunchState(
351 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_WAITING_APP_WINDOW); 354 AppLaunchSplashScreenActor::APP_LAUNCH_STATE_WAITING_APP_WINDOW);
352 355
353 DCHECK(!app_window_watcher_); 356 DCHECK(!app_window_watcher_);
354 app_window_watcher_.reset(new AppWindowWatcher(this)); 357 app_window_watcher_.reset(new AppWindowWatcher(this));
355 } 358 }
356 359
357 void AppLaunchController::OnLaunchFailed(KioskAppLaunchError::Error error) { 360 void AppLaunchController::OnLaunchFailed(KioskAppLaunchError::Error error) {
358 LOG(ERROR) << "Kiosk launch failed. Will now shut down."; 361 LOG(ERROR) << "Kiosk launch failed. Will now shut down."
362 << ", error=" << error;
359 DCHECK_NE(KioskAppLaunchError::NONE, error); 363 DCHECK_NE(KioskAppLaunchError::NONE, error);
360 364
361 // Saves the error and ends the session to go back to login screen. 365 // Saves the error and ends the session to go back to login screen.
362 KioskAppLaunchError::Save(error); 366 KioskAppLaunchError::Save(error);
363 chrome::AttemptUserExit(); 367 chrome::AttemptUserExit();
364 CleanUp(); 368 CleanUp();
365 } 369 }
366 370
367 } // namespace chromeos 371 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/app_launch_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698