• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_APP_LAUNCH_SPLASH_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_APP_LAUNCH_SPLASH_SCREEN_HANDLER_H_
7 
8 #include <set>
9 #include <string>
10 
11 #include "chrome/browser/chromeos/login/screens/app_launch_splash_screen_actor.h"
12 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
13 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
14 
15 namespace chromeos {
16 
17 class ErrorScreenActor;
18 
19 // A class that handles the WebUI hooks for the app launch splash screen.
20 class AppLaunchSplashScreenHandler
21     : public BaseScreenHandler,
22       public AppLaunchSplashScreenActor,
23       public NetworkStateInformer::NetworkStateInformerObserver {
24  public:
25   AppLaunchSplashScreenHandler(
26       const scoped_refptr<NetworkStateInformer>& network_state_informer,
27       ErrorScreenActor* error_screen_actor);
28   virtual ~AppLaunchSplashScreenHandler();
29 
30   // BaseScreenHandler implementation:
31   virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE;
32   virtual void Initialize() OVERRIDE;
33 
34   // WebUIMessageHandler implementation:
35   virtual void RegisterMessages() OVERRIDE;
36 
37   // AppLaunchSplashScreenActor implementation:
38   virtual void Show(const std::string& app_id) OVERRIDE;
39   virtual void PrepareToShow() OVERRIDE;
40   virtual void Hide() OVERRIDE;
41   virtual void ToggleNetworkConfig(bool visible) OVERRIDE;
42   virtual void UpdateAppLaunchState(AppLaunchState state) OVERRIDE;
43   virtual void SetDelegate(
44       AppLaunchSplashScreenHandler::Delegate* delegate) OVERRIDE;
45   virtual void ShowNetworkConfigureUI() OVERRIDE;
46 
47   // NetworkStateInformer::NetworkStateInformerObserver implementation:
48   virtual void OnNetworkReady() OVERRIDE;
49   virtual void UpdateState(ErrorScreenActor::ErrorReason reason) OVERRIDE;
50 
51  private:
52   void PopulateAppInfo(base::DictionaryValue* out_info);
53   void SetLaunchText(const std::string& text);
54   int GetProgressMessageFromState(AppLaunchState state);
55   void HandleConfigureNetwork();
56   void HandleCancelAppLaunch();
57 
58   AppLaunchSplashScreenHandler::Delegate* delegate_;
59   bool show_on_init_;
60   std::string app_id_;
61   AppLaunchState state_;
62 
63   scoped_refptr<NetworkStateInformer> network_state_informer_;
64   ErrorScreenActor* error_screen_actor_;
65 
66   DISALLOW_COPY_AND_ASSIGN(AppLaunchSplashScreenHandler);
67 };
68 
69 }  // namespace chromeos
70 
71 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_APP_LAUNCH_SPLASH_SCREEN_HANDLER_H_
72