• 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_EXTENSIONS_CHROMEOS_KIOSK_APPS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_CHROMEOS_KIOSK_APPS_HANDLER_H_
7 
8 #include <string>
9 
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
13 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h"
14 #include "content/public/browser/web_ui_message_handler.h"
15 
16 namespace base {
17 class DictionaryValue;
18 class ListValue;
19 }
20 
21 namespace content {
22 class WebUIDataSource;
23 }
24 
25 namespace chromeos {
26 
27 class KioskAppManager;
28 
29 class KioskAppsHandler : public content::WebUIMessageHandler,
30                          public KioskAppManagerObserver {
31  public:
32   KioskAppsHandler();
33   virtual ~KioskAppsHandler();
34 
35   void GetLocalizedValues(content::WebUIDataSource* source);
36 
37   // content::WebUIMessageHandler overrides:
38   virtual void RegisterMessages() OVERRIDE;
39 
40   // KioskAppManagerObserver overrides:
41   virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE;
42   virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE;
43   virtual void OnKioskExtensionLoadedInCache(
44       const std::string& app_id) OVERRIDE;
45   virtual void OnKioskExtensionDownloadFailed(
46       const std::string& app_id) OVERRIDE;
47 
48   virtual void OnKioskAppsSettingsChanged() OVERRIDE;
49 
50  private:
51   // Sends all kiosk apps and settings to webui.
52   void SendKioskAppSettings();
53 
54   // JS callbacks.
55   void HandleInitializeKioskAppSettings(const base::ListValue* args);
56   void HandleGetKioskAppSettings(const base::ListValue* args);
57   void HandleAddKioskApp(const base::ListValue* args);
58   void HandleRemoveKioskApp(const base::ListValue* args);
59   void HandleEnableKioskAutoLaunch(const base::ListValue* args);
60   void HandleDisableKioskAutoLaunch(const base::ListValue* args);
61   void HandleSetDisableBailoutShortcut(const base::ListValue* args);
62 
63   void UpdateApp(const std::string& app_id);
64   void ShowError(const std::string& app_id);
65 
66   // Callback for KioskAppManager::GetConsumerKioskModeStatus().
67   void OnGetConsumerKioskAutoLaunchStatus(
68       chromeos::KioskAppManager::ConsumerKioskAutoLaunchStatus status);
69 
70   KioskAppManager* kiosk_app_manager_;  // not owned.
71   bool initialized_;
72   bool is_kiosk_enabled_;
73   bool is_auto_launch_enabled_;
74   base::WeakPtrFactory<KioskAppsHandler> weak_ptr_factory_;
75 
76   DISALLOW_COPY_AND_ASSIGN(KioskAppsHandler);
77 };
78 
79 }  // namespace chromeos
80 
81 #endif  // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_CHROMEOS_KIOSK_APPS_HANDLER_H_
82