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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace extensions { | 30 namespace extensions { |
31 class Extension; | 31 class Extension; |
32 class ExternalLoader; | 32 class ExternalLoader; |
33 } | 33 } |
34 | 34 |
35 namespace chromeos { | 35 namespace chromeos { |
36 | 36 |
37 class KioskAppData; | 37 class KioskAppData; |
38 class KioskAppExternalLoader; | 38 class KioskAppExternalLoader; |
39 class KioskAppManagerObserver; | 39 class KioskAppManagerObserver; |
| 40 class KioskExternalUpdater; |
40 | 41 |
41 // KioskAppManager manages cached app data. | 42 // KioskAppManager manages cached app data. |
42 class KioskAppManager : public KioskAppDataDelegate, | 43 class KioskAppManager : public KioskAppDataDelegate, |
43 public ExternalCache::Delegate { | 44 public ExternalCache::Delegate { |
44 public: | 45 public: |
45 enum ConsumerKioskAutoLaunchStatus { | 46 enum ConsumerKioskAutoLaunchStatus { |
46 // Consumer kiosk mode auto-launch feature can be enabled on this machine. | 47 // Consumer kiosk mode auto-launch feature can be enabled on this machine. |
47 CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, | 48 CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
48 // Consumer kiosk auto-launch feature is enabled on this machine. | 49 // Consumer kiosk auto-launch feature is enabled on this machine. |
49 CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED, | 50 CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED, |
(...skipping 28 matching lines...) Expand all Loading... |
78 static const char kKioskDictionaryName[]; | 79 static const char kKioskDictionaryName[]; |
79 static const char kKeyApps[]; | 80 static const char kKeyApps[]; |
80 static const char kKeyAutoLoginState[]; | 81 static const char kKeyAutoLoginState[]; |
81 | 82 |
82 // Sub directory under DIR_USER_DATA to store cached icon files. | 83 // Sub directory under DIR_USER_DATA to store cached icon files. |
83 static const char kIconCacheDir[]; | 84 static const char kIconCacheDir[]; |
84 | 85 |
85 // Sub directory under DIR_USER_DATA to store cached crx files. | 86 // Sub directory under DIR_USER_DATA to store cached crx files. |
86 static const char kCrxCacheDir[]; | 87 static const char kCrxCacheDir[]; |
87 | 88 |
| 89 // Sub directory under DIR_USER_DATA to store unpacked crx file for validating |
| 90 // its signature. |
| 91 static const char kCrxUnpackDir[]; |
| 92 |
88 // Gets the KioskAppManager instance, which is lazily created on first call.. | 93 // Gets the KioskAppManager instance, which is lazily created on first call.. |
89 static KioskAppManager* Get(); | 94 static KioskAppManager* Get(); |
90 | 95 |
91 // Prepares for shutdown and calls CleanUp() if needed. | 96 // Prepares for shutdown and calls CleanUp() if needed. |
92 static void Shutdown(); | 97 static void Shutdown(); |
93 | 98 |
94 // Registers kiosk app entries in local state. | 99 // Registers kiosk app entries in local state. |
95 static void RegisterPrefs(PrefRegistrySimple* registry); | 100 static void RegisterPrefs(PrefRegistrySimple* registry); |
96 | 101 |
97 // Initiates reading of consumer kiosk mode auto-launch status. | 102 // Initiates reading of consumer kiosk mode auto-launch status. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // used. | 155 // used. |
151 void UpdateAppDataFromProfile(const std::string& app_id, | 156 void UpdateAppDataFromProfile(const std::string& app_id, |
152 Profile* profile, | 157 Profile* profile, |
153 const extensions::Extension* app); | 158 const extensions::Extension* app); |
154 | 159 |
155 void RetryFailedAppDataFetch(); | 160 void RetryFailedAppDataFetch(); |
156 | 161 |
157 // Returns true if the app is found in cache. | 162 // Returns true if the app is found in cache. |
158 bool HasCachedCrx(const std::string& app_id) const; | 163 bool HasCachedCrx(const std::string& app_id) const; |
159 | 164 |
| 165 // Gets the path and version of the cached crx with |app_id|. |
| 166 // Returns true if the app is found in cache. |
| 167 bool GetCachedCrx(const std::string& app_id, |
| 168 base::FilePath* file_path, |
| 169 std::string* version) const; |
| 170 |
160 void AddObserver(KioskAppManagerObserver* observer); | 171 void AddObserver(KioskAppManagerObserver* observer); |
161 void RemoveObserver(KioskAppManagerObserver* observer); | 172 void RemoveObserver(KioskAppManagerObserver* observer); |
162 | 173 |
163 // Creates extensions::ExternalLoader for installing kiosk apps during their | 174 // Creates extensions::ExternalLoader for installing kiosk apps during their |
164 // first time launch. | 175 // first time launch. |
165 extensions::ExternalLoader* CreateExternalLoader(); | 176 extensions::ExternalLoader* CreateExternalLoader(); |
166 | 177 |
167 // Installs kiosk app with |id| from cache. | 178 // Installs kiosk app with |id| from cache. |
168 void InstallFromCache(const std::string& id); | 179 void InstallFromCache(const std::string& id); |
169 | 180 |
170 void UpdateExternalCache(); | 181 void UpdateExternalCache(); |
171 | 182 |
| 183 // Monitors kiosk external update from usb stick. |
| 184 void MonitorKioskExternalUpdate(); |
| 185 |
| 186 // Invoked when kiosk app cache has been updated. |
| 187 void OnKioskAppCacheUpdated(const std::string& app_id); |
| 188 |
172 bool external_loader_created() const { return external_loader_created_; } | 189 bool external_loader_created() const { return external_loader_created_; } |
173 | 190 |
174 private: | 191 private: |
175 friend struct base::DefaultLazyInstanceTraits<KioskAppManager>; | 192 friend struct base::DefaultLazyInstanceTraits<KioskAppManager>; |
176 friend struct base::DefaultDeleter<KioskAppManager>; | 193 friend struct base::DefaultDeleter<KioskAppManager>; |
177 friend class KioskAppManagerTest; | 194 friend class KioskAppManagerTest; |
178 friend class KioskTest; | 195 friend class KioskTest; |
179 friend class KioskUpdateTest; | 196 friend class KioskUpdateTest; |
180 | 197 |
181 enum AutoLoginState { | 198 enum AutoLoginState { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // Callback for reading handling checks of the owner public. | 242 // Callback for reading handling checks of the owner public. |
226 void OnOwnerFileChecked( | 243 void OnOwnerFileChecked( |
227 const GetConsumerKioskAutoLaunchStatusCallback& callback, | 244 const GetConsumerKioskAutoLaunchStatusCallback& callback, |
228 bool* owner_present); | 245 bool* owner_present); |
229 | 246 |
230 // Reads/writes auto login state from/to local state. | 247 // Reads/writes auto login state from/to local state. |
231 AutoLoginState GetAutoLoginState() const; | 248 AutoLoginState GetAutoLoginState() const; |
232 void SetAutoLoginState(AutoLoginState state); | 249 void SetAutoLoginState(AutoLoginState state); |
233 | 250 |
234 void GetCrxCacheDir(base::FilePath* cache_dir); | 251 void GetCrxCacheDir(base::FilePath* cache_dir); |
235 | 252 void GetCrxUnpackDir(base::FilePath* unpack_dir); |
236 // Gets the file path and version information of the cached crx with |app_id|. | |
237 // Returns true if the app is found in cache. | |
238 bool GetCachedCrx(const std::string& app_id, | |
239 base::FilePath* file_path, | |
240 std::string* version) const; | |
241 | 253 |
242 // True if machine ownership is already established. | 254 // True if machine ownership is already established. |
243 bool ownership_established_; | 255 bool ownership_established_; |
244 ScopedVector<KioskAppData> apps_; | 256 ScopedVector<KioskAppData> apps_; |
245 std::string auto_launch_app_id_; | 257 std::string auto_launch_app_id_; |
246 ObserverList<KioskAppManagerObserver, true> observers_; | 258 ObserverList<KioskAppManagerObserver, true> observers_; |
247 | 259 |
248 scoped_ptr<CrosSettings::ObserverSubscription> | 260 scoped_ptr<CrosSettings::ObserverSubscription> |
249 local_accounts_subscription_; | 261 local_accounts_subscription_; |
250 scoped_ptr<CrosSettings::ObserverSubscription> | 262 scoped_ptr<CrosSettings::ObserverSubscription> |
251 local_account_auto_login_id_subscription_; | 263 local_account_auto_login_id_subscription_; |
252 | 264 |
253 scoped_ptr<ExternalCache> external_cache_; | 265 scoped_ptr<ExternalCache> external_cache_; |
| 266 scoped_refptr<KioskExternalUpdater> usb_stick_updater_; |
254 | 267 |
255 // The extension external loader for installing kiosk app. | 268 // The extension external loader for installing kiosk app. |
256 bool external_loader_created_; | 269 bool external_loader_created_; |
257 base::WeakPtr<KioskAppExternalLoader> external_loader_; | 270 base::WeakPtr<KioskAppExternalLoader> external_loader_; |
258 | 271 |
259 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); | 272 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); |
260 }; | 273 }; |
261 | 274 |
262 } // namespace chromeos | 275 } // namespace chromeos |
263 | 276 |
264 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ | 277 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ |
OLD | NEW |