ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / chromeos / login / app_launch_controller.h
blobfd320bdd23664bdb5ea4aedfbdc8397e4706b815
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_APP_LAUNCH_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_APP_LAUNCH_CONTROLLER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/timer/timer.h"
13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
14 #include "chrome/browser/chromeos/app_mode/kiosk_profile_loader.h"
15 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h"
16 #include "chrome/browser/chromeos/login/app_launch_signin_screen.h"
17 #include "chrome/browser/chromeos/login/screens/app_launch_splash_screen_actor.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
21 class Profile;
23 namespace chromeos {
25 class LoginDisplayHost;
26 class OobeDisplay;
27 class UserManager;
29 // Controller for the kiosk app launch process, responsible for
30 // coordinating loading the kiosk profile, launching the app, and
31 // updating the splash screen UI.
32 class AppLaunchController
33 : public AppLaunchSplashScreenActor::Delegate,
34 public KioskProfileLoader::Delegate,
35 public StartupAppLauncher::Delegate,
36 public AppLaunchSigninScreen::Delegate,
37 public content::NotificationObserver {
38 public:
39 typedef base::Callback<bool()> ReturnBoolCallback;
41 AppLaunchController(const std::string& app_id,
42 bool diagnostic_mode,
43 LoginDisplayHost* host,
44 OobeDisplay* oobe_display);
46 ~AppLaunchController() override;
48 // Starts launching an app - set |auto_launch| to true if the app is being
49 // auto-launched with zero delay.
50 void StartAppLaunch(bool auto_launch);
52 bool waiting_for_network() { return waiting_for_network_; }
53 bool network_wait_timedout() { return network_wait_timedout_; }
54 bool showing_network_dialog() { return showing_network_dialog_; }
56 // Customize controller for testing purposes.
57 static void SkipSplashWaitForTesting();
58 static void SetNetworkTimeoutCallbackForTesting(base::Closure* callback);
59 static void SetNetworkWaitForTesting(int wait_time_secs);
60 static void SetCanConfigureNetworkCallbackForTesting(
61 ReturnBoolCallback* can_configure_network_callback);
62 static void SetNeedOwnerAuthToConfigureNetworkCallbackForTesting(
63 ReturnBoolCallback* need_owner_auth_callback);
65 private:
66 // A class to watch app window creation.
67 class AppWindowWatcher;
69 void CleanUp();
70 void OnNetworkWaitTimedout();
72 // Callback of AppWindowWatcher to notify an app window is created.
73 void OnAppWindowCreated();
75 // Whether the network could be configured during launching.
76 bool CanConfigureNetwork();
78 // Whether the owner password is needed to configure network.
79 bool NeedOwnerAuthToConfigureNetwork();
81 // Show network configuration UI if it is allowed. For consumer mode,
82 // owner password might be checked before showing the network configure UI.
83 void MaybeShowNetworkConfigureUI();
85 // KioskProfileLoader::Delegate overrides:
86 void OnProfileLoaded(Profile* profile) override;
87 void OnProfileLoadFailed(KioskAppLaunchError::Error error) override;
89 // AppLaunchSplashScreenActor::Delegate overrides:
90 void OnConfigureNetwork() override;
91 void OnCancelAppLaunch() override;
92 void OnNetworkConfigRequested(bool requested) override;
93 void OnNetworkStateChanged(bool online) override;
95 // StartupAppLauncher::Delegate overrides:
96 void InitializeNetwork() override;
97 bool IsNetworkReady() override;
98 void OnLoadingOAuthFile() override;
99 void OnInitializingTokenService() override;
100 void OnInstallingApp() override;
101 void OnReadyToLaunch() override;
102 void OnLaunchSucceeded() override;
103 void OnLaunchFailed(KioskAppLaunchError::Error error) override;
104 bool IsShowingNetworkConfigScreen() override;
106 // AppLaunchSigninScreen::Delegate overrides:
107 void OnOwnerSigninSuccess() override;
109 // content::NotificationObserver overrides:
110 void Observe(int type,
111 const content::NotificationSource& source,
112 const content::NotificationDetails& details) override;
114 Profile* profile_;
115 const std::string app_id_;
116 const bool diagnostic_mode_;
117 LoginDisplayHost* host_;
118 OobeDisplay* oobe_display_;
119 AppLaunchSplashScreenActor* app_launch_splash_screen_actor_;
120 scoped_ptr<KioskProfileLoader> kiosk_profile_loader_;
121 scoped_ptr<StartupAppLauncher> startup_app_launcher_;
122 scoped_ptr<AppLaunchSigninScreen> signin_screen_;
123 scoped_ptr<AppWindowWatcher> app_window_watcher_;
125 content::NotificationRegistrar registrar_;
126 bool webui_visible_;
127 bool launcher_ready_;
129 // A timer to ensure the app splash is shown for a minimum amount of time.
130 base::OneShotTimer<AppLaunchController> splash_wait_timer_;
132 base::OneShotTimer<AppLaunchController> network_wait_timer_;
133 bool waiting_for_network_;
134 bool network_wait_timedout_;
135 bool showing_network_dialog_;
136 bool network_config_requested_;
137 int64 launch_splash_start_time_;
139 static bool skip_splash_wait_;
140 static int network_wait_time_;
141 static base::Closure* network_timeout_callback_;
142 static ReturnBoolCallback* can_configure_network_callback_;
143 static ReturnBoolCallback* need_owner_auth_to_configure_network_callback_;
145 DISALLOW_COPY_AND_ASSIGN(AppLaunchController);
148 } // namespace chromeos
150 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_APP_LAUNCH_CONTROLLER_H_