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_UI_WEBUI_CHROMEOS_LOGIN_KIOSK_APP_MENU_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_KIOSK_APP_MENU_HANDLER_H_
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h"
15 #include "chrome/browser/chromeos/login/screens/network_error.h"
16 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
17 #include "content/public/browser/web_ui_message_handler.h"
21 // KioskAppMenuHandler supplies kiosk apps data to apps menu on sign-in
22 // screen when app mode is enabled and handles "launchKioskApp" request
23 // from the apps menu.
24 class KioskAppMenuHandler
25 : public content::WebUIMessageHandler
,
26 public KioskAppManagerObserver
,
27 public NetworkStateInformer::NetworkStateInformerObserver
{
29 explicit KioskAppMenuHandler(
30 const scoped_refptr
<NetworkStateInformer
>& network_state_informer
);
31 ~KioskAppMenuHandler() override
;
33 void GetLocalizedStrings(base::DictionaryValue
* localized_strings
);
35 // content::WebUIMessageHandler overrides:
36 void RegisterMessages() override
;
38 // Returns true if new kiosk UI is enabled.
39 static bool EnableNewKioskUI();
42 // Sends all kiosk apps to webui.
46 void HandleInitializeKioskApps(const base::ListValue
* args
);
47 void HandleKioskAppsLoaded(const base::ListValue
* args
);
48 void HandleCheckKioskAppLaunchError(const base::ListValue
* args
);
50 // KioskAppManagerObserver overrides:
51 void OnKioskAppsSettingsChanged() override
;
52 void OnKioskAppDataChanged(const std::string
& app_id
) override
;
54 // NetworkStateInformer::NetworkStateInformerObserver overrides:
55 void UpdateState(NetworkError::ErrorReason reason
) override
;
57 // True when WebUI is initialized. Otherwise don't allow calling JS functions.
58 bool is_webui_initialized_
;
60 scoped_refptr
<NetworkStateInformer
> network_state_informer_
;
62 base::WeakPtrFactory
<KioskAppMenuHandler
> weak_ptr_factory_
;
64 DISALLOW_COPY_AND_ASSIGN(KioskAppMenuHandler
);
67 } // namespace chromeos
69 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_KIOSK_APP_MENU_HANDLER_H_