Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / app_launch_controller.h
index 382cb55..4e52f2c 100644 (file)
@@ -9,15 +9,12 @@
 
 #include "base/basictypes.h"
 #include "base/callback_forward.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
 #include "base/timer/timer.h"
 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
 #include "chrome/browser/chromeos/app_mode/kiosk_profile_loader.h"
 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h"
 #include "chrome/browser/chromeos/login/app_launch_signin_screen.h"
 #include "chrome/browser/chromeos/login/screens/app_launch_splash_screen_actor.h"
-#include "chrome/browser/chromeos/login/screens/error_screen_actor.h"
 #include "content/public/browser/notification_observer.h"
 #include "content/public/browser/notification_registrar.h"
 
@@ -33,16 +30,16 @@ class UserManager;
 // coordinating loading the kiosk profile, launching the app, and
 // updating the splash screen UI.
 class AppLaunchController
-    : public base::SupportsWeakPtr<AppLaunchController>,
-      public AppLaunchSplashScreenActor::Delegate,
+    : public AppLaunchSplashScreenActor::Delegate,
       public KioskProfileLoader::Delegate,
-      public StartupAppLauncher::Observer,
+      public StartupAppLauncher::Delegate,
       public AppLaunchSigninScreen::Delegate,
       public content::NotificationObserver {
  public:
-  typedef base::Callback<bool()> CanConfigureNetworkCallback;
+  typedef base::Callback<bool()> ReturnBoolCallback;
 
   AppLaunchController(const std::string& app_id,
+                      bool diagnostic_mode,
                       LoginDisplayHost* host,
                       OobeDisplay* oobe_display);
 
@@ -59,7 +56,9 @@ class AppLaunchController
   static void SetNetworkTimeoutCallbackForTesting(base::Closure* callback);
   static void SetNetworkWaitForTesting(int wait_time_secs);
   static void SetCanConfigureNetworkCallbackForTesting(
-      CanConfigureNetworkCallback* can_configure_network_callback);
+      ReturnBoolCallback* can_configure_network_callback);
+  static void SetNeedOwnerAuthToConfigureNetworkCallbackForTesting(
+      ReturnBoolCallback* need_owner_auth_callback);
 
  private:
   // A class to watch app window creation.
@@ -74,6 +73,13 @@ class AppLaunchController
   // Whether the network could be configured during launching.
   bool CanConfigureNetwork();
 
+  // Whether the owner password is needed to configure network.
+  bool NeedOwnerAuthToConfigureNetwork();
+
+  // Show network configuration UI if it is allowed. For consumer mode,
+  // owner password might be checked before showing the network configure UI.
+  void MaybeShowNetworkConfigureUI();
+
   // KioskProfileLoader::Delegate overrides:
   virtual void OnProfileLoaded(Profile* profile) OVERRIDE;
   virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) OVERRIDE;
@@ -81,11 +87,13 @@ class AppLaunchController
   // AppLaunchSplashScreenActor::Delegate overrides:
   virtual void OnConfigureNetwork() OVERRIDE;
   virtual void OnCancelAppLaunch() OVERRIDE;
+  virtual void OnNetworkStateChanged(bool online) OVERRIDE;
 
-  // StartupAppLauncher::Observer overrides:
+  // StartupAppLauncher::Delegate overrides:
+  virtual void InitializeNetwork() OVERRIDE;
+  virtual bool IsNetworkReady() OVERRIDE;
   virtual void OnLoadingOAuthFile() OVERRIDE;
   virtual void OnInitializingTokenService() OVERRIDE;
-  virtual void OnInitializingNetwork() OVERRIDE;
   virtual void OnInstallingApp() OVERRIDE;
   virtual void OnReadyToLaunch() OVERRIDE;
   virtual void OnLaunchSucceeded() OVERRIDE;
@@ -101,10 +109,10 @@ class AppLaunchController
 
   Profile* profile_;
   const std::string app_id_;
+  const bool diagnostic_mode_;
   LoginDisplayHost* host_;
   OobeDisplay* oobe_display_;
   AppLaunchSplashScreenActor* app_launch_splash_screen_actor_;
-  ErrorScreenActor* error_screen_actor_;
   scoped_ptr<KioskProfileLoader> kiosk_profile_loader_;
   scoped_ptr<StartupAppLauncher> startup_app_launcher_;
   scoped_ptr<AppLaunchSigninScreen> signin_screen_;
@@ -114,6 +122,9 @@ class AppLaunchController
   bool webui_visible_;
   bool launcher_ready_;
 
+  // A timer to ensure the app splash is shown for a minimum amount of time.
+  base::OneShotTimer<AppLaunchController> splash_wait_timer_;
+
   base::OneShotTimer<AppLaunchController> network_wait_timer_;
   bool waiting_for_network_;
   bool network_wait_timedout_;
@@ -123,7 +134,8 @@ class AppLaunchController
   static bool skip_splash_wait_;
   static int network_wait_time_;
   static base::Closure* network_timeout_callback_;
-  static CanConfigureNetworkCallback* can_configure_network_callback_;
+  static ReturnBoolCallback* can_configure_network_callback_;
+  static ReturnBoolCallback* need_owner_auth_to_configure_network_callback_;
 
   DISALLOW_COPY_AND_ASSIGN(AppLaunchController);
 };