| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 153 void RetryFailedAppDataFetch(); | 155 void RetryFailedAppDataFetch(); |
| 154 | 156 |
| 157 // Returns true if the app is found in cache. |
| 158 bool HasCachedCrx(const std::string& app_id) const; |
| 159 |
| 155 void AddObserver(KioskAppManagerObserver* observer); | 160 void AddObserver(KioskAppManagerObserver* observer); |
| 156 void RemoveObserver(KioskAppManagerObserver* observer); | 161 void RemoveObserver(KioskAppManagerObserver* observer); |
| 157 | 162 |
| 163 // Creates extensions::ExternalLoader for installing kiosk apps during their |
| 164 // first time launch. |
| 165 extensions::ExternalLoader* CreateExternalLoader(); |
| 166 |
| 167 // Installs kiosk app with |id| from cache. |
| 168 void InstallFromCache(const std::string& id); |
| 169 |
| 170 void UpdateExternalCache(); |
| 171 |
| 172 bool external_loader_created() const { return external_loader_created_; } |
| 173 |
| 158 private: | 174 private: |
| 159 friend struct base::DefaultLazyInstanceTraits<KioskAppManager>; | 175 friend struct base::DefaultLazyInstanceTraits<KioskAppManager>; |
| 160 friend struct base::DefaultDeleter<KioskAppManager>; | 176 friend struct base::DefaultDeleter<KioskAppManager>; |
| 161 friend class KioskAppManagerTest; | 177 friend class KioskAppManagerTest; |
| 162 friend class KioskTest; | 178 friend class KioskTest; |
| 179 friend class KioskUpdateTest; |
| 163 | 180 |
| 164 enum AutoLoginState { | 181 enum AutoLoginState { |
| 165 AUTOLOGIN_NONE = 0, | 182 AUTOLOGIN_NONE = 0, |
| 166 AUTOLOGIN_REQUESTED = 1, | 183 AUTOLOGIN_REQUESTED = 1, |
| 167 AUTOLOGIN_APPROVED = 2, | 184 AUTOLOGIN_APPROVED = 2, |
| 168 AUTOLOGIN_REJECTED = 3, | 185 AUTOLOGIN_REJECTED = 3, |
| 169 }; | 186 }; |
| 170 | 187 |
| 171 KioskAppManager(); | 188 KioskAppManager(); |
| 172 virtual ~KioskAppManager(); | 189 virtual ~KioskAppManager(); |
| 173 | 190 |
| 174 // Stop all data loading and remove its dependency on CrosSettings. | 191 // Stop all data loading and remove its dependency on CrosSettings. |
| 175 void CleanUp(); | 192 void CleanUp(); |
| 176 | 193 |
| 177 // Gets KioskAppData for the given app id. | 194 // Gets KioskAppData for the given app id. |
| 178 const KioskAppData* GetAppData(const std::string& app_id) const; | 195 const KioskAppData* GetAppData(const std::string& app_id) const; |
| 179 KioskAppData* GetAppDataMutable(const std::string& app_id); | 196 KioskAppData* GetAppDataMutable(const std::string& app_id); |
| 180 | 197 |
| 181 // Update app data |apps_| based on CrosSettings. | 198 // Updates app data |apps_| based on CrosSettings. |
| 182 void UpdateAppData(); | 199 void UpdateAppData(); |
| 183 | 200 |
| 184 // KioskAppDataDelegate overrides: | 201 // KioskAppDataDelegate overrides: |
| 185 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; | 202 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; |
| 186 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; | 203 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; |
| 187 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; | 204 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; |
| 188 | 205 |
| 189 // ExternalCache::Delegate: | 206 // ExternalCache::Delegate: |
| 190 virtual void OnExtensionListsUpdated( | 207 virtual void OnExtensionListsUpdated( |
| 191 const base::DictionaryValue* prefs) OVERRIDE; | 208 const base::DictionaryValue* prefs) OVERRIDE; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 209 void OnOwnerFileChecked( | 226 void OnOwnerFileChecked( |
| 210 const GetConsumerKioskAutoLaunchStatusCallback& callback, | 227 const GetConsumerKioskAutoLaunchStatusCallback& callback, |
| 211 bool* owner_present); | 228 bool* owner_present); |
| 212 | 229 |
| 213 // Reads/writes auto login state from/to local state. | 230 // Reads/writes auto login state from/to local state. |
| 214 AutoLoginState GetAutoLoginState() const; | 231 AutoLoginState GetAutoLoginState() const; |
| 215 void SetAutoLoginState(AutoLoginState state); | 232 void SetAutoLoginState(AutoLoginState state); |
| 216 | 233 |
| 217 void GetCrxCacheDir(base::FilePath* cache_dir); | 234 void GetCrxCacheDir(base::FilePath* cache_dir); |
| 218 | 235 |
| 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. |
| 219 bool GetCachedCrx(const std::string& app_id, | 238 bool GetCachedCrx(const std::string& app_id, |
| 220 base::FilePath* file_path, | 239 base::FilePath* file_path, |
| 221 std::string* version); | 240 std::string* version) const; |
| 222 | 241 |
| 223 // True if machine ownership is already established. | 242 // True if machine ownership is already established. |
| 224 bool ownership_established_; | 243 bool ownership_established_; |
| 225 ScopedVector<KioskAppData> apps_; | 244 ScopedVector<KioskAppData> apps_; |
| 226 std::string auto_launch_app_id_; | 245 std::string auto_launch_app_id_; |
| 227 ObserverList<KioskAppManagerObserver, true> observers_; | 246 ObserverList<KioskAppManagerObserver, true> observers_; |
| 228 | 247 |
| 229 scoped_ptr<CrosSettings::ObserverSubscription> | 248 scoped_ptr<CrosSettings::ObserverSubscription> |
| 230 local_accounts_subscription_; | 249 local_accounts_subscription_; |
| 231 scoped_ptr<CrosSettings::ObserverSubscription> | 250 scoped_ptr<CrosSettings::ObserverSubscription> |
| 232 local_account_auto_login_id_subscription_; | 251 local_account_auto_login_id_subscription_; |
| 233 | 252 |
| 234 scoped_ptr<ExternalCache> external_cache_; | 253 scoped_ptr<ExternalCache> external_cache_; |
| 235 | 254 |
| 255 // The extension external loader for installing kiosk app. |
| 256 bool external_loader_created_; |
| 257 base::WeakPtr<KioskAppExternalLoader> external_loader_; |
| 258 |
| 236 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); | 259 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); |
| 237 }; | 260 }; |
| 238 | 261 |
| 239 } // namespace chromeos | 262 } // namespace chromeos |
| 240 | 263 |
| 241 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ | 264 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ |
| OLD | NEW |