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 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 class PrefRegistrySimple; | 23 class PrefRegistrySimple; |
24 class Profile; | 24 class Profile; |
25 | 25 |
26 namespace base { | 26 namespace base { |
27 class RefCountedString; | 27 class RefCountedString; |
28 } | 28 } |
29 | 29 |
30 namespace extensions { | 30 namespace extensions { |
31 class Extension; | 31 class Extension; |
32 class ExternalLoader; | |
32 } | 33 } |
33 | 34 |
34 namespace chromeos { | 35 namespace chromeos { |
35 | 36 |
36 class KioskAppData; | 37 class KioskAppData; |
38 class KioskAppExternalLoader; | |
37 class KioskAppManagerObserver; | 39 class KioskAppManagerObserver; |
38 | 40 |
39 // KioskAppManager manages cached app data. | 41 // KioskAppManager manages cached app data. |
40 class KioskAppManager : public KioskAppDataDelegate, | 42 class KioskAppManager : public KioskAppDataDelegate, |
41 public ExternalCache::Delegate { | 43 public ExternalCache::Delegate { |
42 public: | 44 public: |
43 enum ConsumerKioskAutoLaunchStatus { | 45 enum ConsumerKioskAutoLaunchStatus { |
44 // Consumer kiosk mode auto-launch feature can be enabled on this machine. | 46 // Consumer kiosk mode auto-launch feature can be enabled on this machine. |
45 CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, | 47 CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE, |
46 // Consumer kiosk auto-launch feature is enabled on this machine. | 48 // Consumer kiosk auto-launch feature is enabled on this machine. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 | 145 |
144 // Updates app data from the |app| in |profile|. |app| is provided to cover | 146 // Updates app data from the |app| in |profile|. |app| is provided to cover |
145 // the case of app update case where |app| is the new version and is not | 147 // the case of app update case where |app| is the new version and is not |
146 // finished installing (e.g. because old version is still running). Otherwise, | 148 // finished installing (e.g. because old version is still running). Otherwise, |
147 // |app| could be NULL and the current installed app in |profile| will be | 149 // |app| could be NULL and the current installed app in |profile| will be |
148 // used. | 150 // used. |
149 void UpdateAppDataFromProfile(const std::string& app_id, | 151 void UpdateAppDataFromProfile(const std::string& app_id, |
150 Profile* profile, | 152 Profile* profile, |
151 const extensions::Extension* app); | 153 const extensions::Extension* app); |
152 | 154 |
155 // Gets the file path and version information of the cached crx with |app_id|. | |
156 // Returns true if the app is found in cache. | |
157 bool GetCachedCrx(const std::string& app_id, | |
xiyuan
2014/07/08 21:50:59
nit: It seems we no longer need to expose crx path
jennyz
2014/07/12 00:03:20
This function is still needed in KioskAppManagerTe
| |
158 base::FilePath* file_path, | |
159 std::string* version); | |
160 | |
161 // Returns true if the extension with |id| is pending for caching crx file | |
162 // for the first time. | |
163 bool IsExtensionPendingForCache(const std::string& id); | |
164 | |
165 // Returns true if the extensions with |id| is pending for update check. | |
166 // The crx file fo the extension has been cached previously. | |
167 bool IsExtensionPendingForUpdateCheck(const std::string& id); | |
xiyuan
2014/07/08 21:50:59
We can probably merge this with IsExtensionPending
jennyz
2014/07/12 00:03:20
We don't need both functions now, removed.
| |
168 | |
153 void AddObserver(KioskAppManagerObserver* observer); | 169 void AddObserver(KioskAppManagerObserver* observer); |
154 void RemoveObserver(KioskAppManagerObserver* observer); | 170 void RemoveObserver(KioskAppManagerObserver* observer); |
155 | 171 |
172 // Creates extensions::ExternalLoader for installing kiosk apps during their | |
173 // first time launch. | |
174 extensions::ExternalLoader* CreateExternalLoader(); | |
175 | |
176 // Installs kiosk app with |id|. | |
177 void InstallKioskApp(const std::string& id); | |
xiyuan
2014/07/08 21:50:59
nit: InstallKioskApp -> InstallFromCache to be mor
jennyz
2014/07/12 00:03:20
Done.
| |
178 | |
179 bool external_loader_created() const { return external_loader_created_; } | |
180 | |
156 private: | 181 private: |
157 friend struct base::DefaultLazyInstanceTraits<KioskAppManager>; | 182 friend struct base::DefaultLazyInstanceTraits<KioskAppManager>; |
158 friend struct base::DefaultDeleter<KioskAppManager>; | 183 friend struct base::DefaultDeleter<KioskAppManager>; |
159 friend class KioskAppManagerTest; | 184 friend class KioskAppManagerTest; |
160 friend class KioskTest; | 185 friend class KioskTest; |
161 | 186 |
162 enum AutoLoginState { | 187 enum AutoLoginState { |
163 AUTOLOGIN_NONE = 0, | 188 AUTOLOGIN_NONE = 0, |
164 AUTOLOGIN_REQUESTED = 1, | 189 AUTOLOGIN_REQUESTED = 1, |
165 AUTOLOGIN_APPROVED = 2, | 190 AUTOLOGIN_APPROVED = 2, |
166 AUTOLOGIN_REJECTED = 3, | 191 AUTOLOGIN_REJECTED = 3, |
167 }; | 192 }; |
168 | 193 |
169 KioskAppManager(); | 194 KioskAppManager(); |
170 virtual ~KioskAppManager(); | 195 virtual ~KioskAppManager(); |
171 | 196 |
172 // Stop all data loading and remove its dependency on CrosSettings. | 197 // Stop all data loading and remove its dependency on CrosSettings. |
173 void CleanUp(); | 198 void CleanUp(); |
174 | 199 |
175 // Gets KioskAppData for the given app id. | 200 // Gets KioskAppData for the given app id. |
176 const KioskAppData* GetAppData(const std::string& app_id) const; | 201 const KioskAppData* GetAppData(const std::string& app_id) const; |
177 KioskAppData* GetAppDataMutable(const std::string& app_id); | 202 KioskAppData* GetAppDataMutable(const std::string& app_id); |
178 | 203 |
179 // Update app data |apps_| based on CrosSettings. | 204 // Updates app data |apps_| based on CrosSettings. |
180 void UpdateAppData(); | 205 void UpdateAppData(); |
181 | 206 |
182 // KioskAppDataDelegate overrides: | 207 // KioskAppDataDelegate overrides: |
183 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; | 208 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; |
184 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; | 209 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; |
185 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; | 210 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; |
186 | 211 |
187 // ExternalCache::Delegate: | 212 // ExternalCache::Delegate: |
188 virtual void OnExtensionListsUpdated( | 213 virtual void OnExtensionListsUpdated( |
189 const base::DictionaryValue* prefs) OVERRIDE; | 214 const base::DictionaryValue* prefs) OVERRIDE; |
(...skipping 17 matching lines...) Expand all Loading... | |
207 void OnOwnerFileChecked( | 232 void OnOwnerFileChecked( |
208 const GetConsumerKioskAutoLaunchStatusCallback& callback, | 233 const GetConsumerKioskAutoLaunchStatusCallback& callback, |
209 bool* owner_present); | 234 bool* owner_present); |
210 | 235 |
211 // Reads/writes auto login state from/to local state. | 236 // Reads/writes auto login state from/to local state. |
212 AutoLoginState GetAutoLoginState() const; | 237 AutoLoginState GetAutoLoginState() const; |
213 void SetAutoLoginState(AutoLoginState state); | 238 void SetAutoLoginState(AutoLoginState state); |
214 | 239 |
215 void GetCrxCacheDir(base::FilePath* cache_dir); | 240 void GetCrxCacheDir(base::FilePath* cache_dir); |
216 | 241 |
217 bool GetCachedCrx(const std::string& app_id, | |
218 base::FilePath* file_path, | |
219 std::string* version); | |
220 | |
221 // True if machine ownership is already established. | 242 // True if machine ownership is already established. |
222 bool ownership_established_; | 243 bool ownership_established_; |
223 ScopedVector<KioskAppData> apps_; | 244 ScopedVector<KioskAppData> apps_; |
224 std::string auto_launch_app_id_; | 245 std::string auto_launch_app_id_; |
225 ObserverList<KioskAppManagerObserver, true> observers_; | 246 ObserverList<KioskAppManagerObserver, true> observers_; |
226 | 247 |
227 scoped_ptr<CrosSettings::ObserverSubscription> | 248 scoped_ptr<CrosSettings::ObserverSubscription> |
228 local_accounts_subscription_; | 249 local_accounts_subscription_; |
229 scoped_ptr<CrosSettings::ObserverSubscription> | 250 scoped_ptr<CrosSettings::ObserverSubscription> |
230 local_account_auto_login_id_subscription_; | 251 local_account_auto_login_id_subscription_; |
231 | 252 |
232 scoped_ptr<ExternalCache> external_cache_; | 253 scoped_ptr<ExternalCache> external_cache_; |
233 | 254 |
255 // The extension external loader for installing kiosk app. | |
256 bool external_loader_created_; | |
257 base::WeakPtr<KioskAppExternalLoader> external_loader_; | |
258 | |
234 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); | 259 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); |
235 }; | 260 }; |
236 | 261 |
237 } // namespace chromeos | 262 } // namespace chromeos |
238 | 263 |
239 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ | 264 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ |
OLD | NEW |