OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "chrome/browser/chromeos/app_mode/kiosk_app_data_delegate.h" | 17 #include "chrome/browser/chromeos/app_mode/kiosk_app_data_delegate.h" |
| 18 #include "chrome/browser/chromeos/extensions/external_cache.h" |
18 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 19 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
19 #include "chrome/browser/chromeos/settings/cros_settings.h" | 20 #include "chrome/browser/chromeos/settings/cros_settings.h" |
20 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
21 | 22 |
22 class PrefRegistrySimple; | 23 class PrefRegistrySimple; |
23 class Profile; | 24 class Profile; |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 class RefCountedString; | 27 class RefCountedString; |
27 } | 28 } |
28 | 29 |
29 namespace extensions { | 30 namespace extensions { |
30 class Extension; | 31 class Extension; |
31 } | 32 } |
32 | 33 |
33 namespace chromeos { | 34 namespace chromeos { |
34 | 35 |
35 class KioskAppData; | 36 class KioskAppData; |
36 class KioskAppManagerObserver; | 37 class KioskAppManagerObserver; |
37 | 38 |
38 // KioskAppManager manages cached app data. | 39 // KioskAppManager manages cached app data. |
39 class KioskAppManager : public KioskAppDataDelegate { | 40 class KioskAppManager : public KioskAppDataDelegate, |
| 41 public ExternalCache::Delegate { |
40 public: | 42 public: |
41 enum ConsumerKioskAutoLaunchStatus { | 43 enum ConsumerKioskAutoLaunchStatus { |
42 // Consumer kiosk mode auto-launch feature can be enabled on this machine. | 44 // Consumer kiosk mode auto-launch feature can be enabled on this machine. |
43 CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, | 45 CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
44 // Consumer kiosk auto-launch feature is enabled on this machine. | 46 // Consumer kiosk auto-launch feature is enabled on this machine. |
45 CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED, | 47 CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED, |
46 // Consumer kiosk mode auto-launch feature is disabled and cannot any longer | 48 // Consumer kiosk mode auto-launch feature is disabled and cannot any longer |
47 // be enabled on this machine. | 49 // be enabled on this machine. |
48 CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED, | 50 CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED, |
49 }; | 51 }; |
50 | 52 |
51 typedef base::Callback<void(bool success)> EnableKioskAutoLaunchCallback; | 53 typedef base::Callback<void(bool success)> EnableKioskAutoLaunchCallback; |
52 typedef base::Callback<void(ConsumerKioskAutoLaunchStatus status)> | 54 typedef base::Callback<void(ConsumerKioskAutoLaunchStatus status)> |
53 GetConsumerKioskAutoLaunchStatusCallback; | 55 GetConsumerKioskAutoLaunchStatusCallback; |
54 | 56 |
55 // Struct to hold app info returned from GetApps() call. | 57 // Struct to hold app info returned from GetApps() call. |
56 struct App { | 58 struct App { |
57 explicit App(const KioskAppData& data); | 59 App(const KioskAppData& data, bool is_extension_pending); |
58 App(); | 60 App(); |
59 ~App(); | 61 ~App(); |
60 | 62 |
61 std::string app_id; | 63 std::string app_id; |
62 std::string user_id; | 64 std::string user_id; |
63 std::string name; | 65 std::string name; |
64 gfx::ImageSkia icon; | 66 gfx::ImageSkia icon; |
65 bool is_loading; | 67 bool is_loading; |
66 }; | 68 }; |
67 typedef std::vector<App> Apps; | 69 typedef std::vector<App> Apps; |
68 | 70 |
69 // Name of a dictionary that holds kiosk app info in Local State. | 71 // Name of a dictionary that holds kiosk app info in Local State. |
70 // Sample layout: | 72 // Sample layout: |
71 // "kiosk": { | 73 // "kiosk": { |
72 // "auto_login_enabled": true // | 74 // "auto_login_enabled": true // |
73 // } | 75 // } |
74 static const char kKioskDictionaryName[]; | 76 static const char kKioskDictionaryName[]; |
75 static const char kKeyApps[]; | 77 static const char kKeyApps[]; |
76 static const char kKeyAutoLoginState[]; | 78 static const char kKeyAutoLoginState[]; |
77 | 79 |
78 // Sub directory under DIR_USER_DATA to store cached icon files. | 80 // Sub directory under DIR_USER_DATA to store cached icon files. |
79 static const char kIconCacheDir[]; | 81 static const char kIconCacheDir[]; |
80 | 82 |
| 83 // Sub directory under DIR_USER_DATA to store cached crx files. |
| 84 static const char kCrxCacheDir[]; |
| 85 |
81 // Gets the KioskAppManager instance, which is lazily created on first call.. | 86 // Gets the KioskAppManager instance, which is lazily created on first call.. |
82 static KioskAppManager* Get(); | 87 static KioskAppManager* Get(); |
83 | 88 |
84 // Prepares for shutdown and calls CleanUp() if needed. | 89 // Prepares for shutdown and calls CleanUp() if needed. |
85 static void Shutdown(); | 90 static void Shutdown(); |
86 | 91 |
87 // Registers kiosk app entries in local state. | 92 // Registers kiosk app entries in local state. |
88 static void RegisterPrefs(PrefRegistrySimple* registry); | 93 static void RegisterPrefs(PrefRegistrySimple* registry); |
89 | 94 |
90 // Initiates reading of consumer kiosk mode auto-launch status. | 95 // Initiates reading of consumer kiosk mode auto-launch status. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 KioskAppData* GetAppDataMutable(const std::string& app_id); | 177 KioskAppData* GetAppDataMutable(const std::string& app_id); |
173 | 178 |
174 // Update app data |apps_| based on CrosSettings. | 179 // Update app data |apps_| based on CrosSettings. |
175 void UpdateAppData(); | 180 void UpdateAppData(); |
176 | 181 |
177 // KioskAppDataDelegate overrides: | 182 // KioskAppDataDelegate overrides: |
178 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; | 183 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; |
179 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; | 184 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; |
180 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; | 185 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; |
181 | 186 |
| 187 // ExternalCache::Delegate: |
| 188 virtual void OnExtensionListsUpdated( |
| 189 const base::DictionaryValue* prefs) OVERRIDE; |
| 190 virtual void OnExtensionLoadedInCache(const std::string& id) OVERRIDE; |
| 191 virtual void OnExtensionDownloadFailed( |
| 192 const std::string& id, |
| 193 extensions::ExtensionDownloaderDelegate::Error error) OVERRIDE; |
| 194 |
182 // Callback for EnterpriseInstallAttributes::LockDevice() during | 195 // Callback for EnterpriseInstallAttributes::LockDevice() during |
183 // EnableConsumerModeKiosk() call. | 196 // EnableConsumerModeKiosk() call. |
184 void OnLockDevice( | 197 void OnLockDevice( |
185 const EnableKioskAutoLaunchCallback& callback, | 198 const EnableKioskAutoLaunchCallback& callback, |
186 policy::EnterpriseInstallAttributes::LockResult result); | 199 policy::EnterpriseInstallAttributes::LockResult result); |
187 | 200 |
188 // Callback for EnterpriseInstallAttributes::ReadImmutableAttributes() during | 201 // Callback for EnterpriseInstallAttributes::ReadImmutableAttributes() during |
189 // GetConsumerKioskModeStatus() call. | 202 // GetConsumerKioskModeStatus() call. |
190 void OnReadImmutableAttributes( | 203 void OnReadImmutableAttributes( |
191 const GetConsumerKioskAutoLaunchStatusCallback& callback); | 204 const GetConsumerKioskAutoLaunchStatusCallback& callback); |
192 | 205 |
193 // Callback for reading handling checks of the owner public. | 206 // Callback for reading handling checks of the owner public. |
194 void OnOwnerFileChecked( | 207 void OnOwnerFileChecked( |
195 const GetConsumerKioskAutoLaunchStatusCallback& callback, | 208 const GetConsumerKioskAutoLaunchStatusCallback& callback, |
196 bool* owner_present); | 209 bool* owner_present); |
197 | 210 |
198 // Reads/writes auto login state from/to local state. | 211 // Reads/writes auto login state from/to local state. |
199 AutoLoginState GetAutoLoginState() const; | 212 AutoLoginState GetAutoLoginState() const; |
200 void SetAutoLoginState(AutoLoginState state); | 213 void SetAutoLoginState(AutoLoginState state); |
201 | 214 |
| 215 void GetKioskAppCrxCacheDir(base::FilePath* cache_dir); |
| 216 |
202 // True if machine ownership is already established. | 217 // True if machine ownership is already established. |
203 bool ownership_established_; | 218 bool ownership_established_; |
204 ScopedVector<KioskAppData> apps_; | 219 ScopedVector<KioskAppData> apps_; |
205 std::string auto_launch_app_id_; | 220 std::string auto_launch_app_id_; |
206 ObserverList<KioskAppManagerObserver, true> observers_; | 221 ObserverList<KioskAppManagerObserver, true> observers_; |
207 | 222 |
208 scoped_ptr<CrosSettings::ObserverSubscription> | 223 scoped_ptr<CrosSettings::ObserverSubscription> |
209 local_accounts_subscription_; | 224 local_accounts_subscription_; |
210 scoped_ptr<CrosSettings::ObserverSubscription> | 225 scoped_ptr<CrosSettings::ObserverSubscription> |
211 local_account_auto_login_id_subscription_; | 226 local_account_auto_login_id_subscription_; |
212 | 227 |
| 228 scoped_ptr<ExternalCache> external_cache_; |
| 229 |
213 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); | 230 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); |
214 }; | 231 }; |
215 | 232 |
216 } // namespace chromeos | 233 } // namespace chromeos |
217 | 234 |
218 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ | 235 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ |
OLD | NEW |