Chromium Code Reviews| 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; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 KioskAppData* GetAppDataMutable(const std::string& app_id); | 174 KioskAppData* GetAppDataMutable(const std::string& app_id); |
| 173 | 175 |
| 174 // Update app data |apps_| based on CrosSettings. | 176 // Update app data |apps_| based on CrosSettings. |
| 175 void UpdateAppData(); | 177 void UpdateAppData(); |
| 176 | 178 |
| 177 // KioskAppDataDelegate overrides: | 179 // KioskAppDataDelegate overrides: |
| 178 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; | 180 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; |
| 179 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; | 181 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; |
| 180 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; | 182 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; |
| 181 | 183 |
| 184 // ExternalCache::Delegate: | |
| 185 virtual void OnExtensionListsUpdated( | |
| 186 const base::DictionaryValue* prefs) OVERRIDE; | |
| 187 virtual void OnExtensionLoadedInCache(const std::string& id) OVERRIDE; | |
| 188 virtual void OnExtensionDownloadFailed( | |
| 189 const std::string& id, | |
| 190 extensions::ExtensionDownloaderDelegate::Error error) OVERRIDE; | |
| 191 | |
| 182 // Callback for EnterpriseInstallAttributes::LockDevice() during | 192 // Callback for EnterpriseInstallAttributes::LockDevice() during |
| 183 // EnableConsumerModeKiosk() call. | 193 // EnableConsumerModeKiosk() call. |
| 184 void OnLockDevice( | 194 void OnLockDevice( |
| 185 const EnableKioskAutoLaunchCallback& callback, | 195 const EnableKioskAutoLaunchCallback& callback, |
| 186 policy::EnterpriseInstallAttributes::LockResult result); | 196 policy::EnterpriseInstallAttributes::LockResult result); |
| 187 | 197 |
| 188 // Callback for EnterpriseInstallAttributes::ReadImmutableAttributes() during | 198 // Callback for EnterpriseInstallAttributes::ReadImmutableAttributes() during |
| 189 // GetConsumerKioskModeStatus() call. | 199 // GetConsumerKioskModeStatus() call. |
| 190 void OnReadImmutableAttributes( | 200 void OnReadImmutableAttributes( |
| 191 const GetConsumerKioskAutoLaunchStatusCallback& callback); | 201 const GetConsumerKioskAutoLaunchStatusCallback& callback); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 203 bool ownership_established_; | 213 bool ownership_established_; |
| 204 ScopedVector<KioskAppData> apps_; | 214 ScopedVector<KioskAppData> apps_; |
| 205 std::string auto_launch_app_id_; | 215 std::string auto_launch_app_id_; |
| 206 ObserverList<KioskAppManagerObserver, true> observers_; | 216 ObserverList<KioskAppManagerObserver, true> observers_; |
| 207 | 217 |
| 208 scoped_ptr<CrosSettings::ObserverSubscription> | 218 scoped_ptr<CrosSettings::ObserverSubscription> |
| 209 local_accounts_subscription_; | 219 local_accounts_subscription_; |
| 210 scoped_ptr<CrosSettings::ObserverSubscription> | 220 scoped_ptr<CrosSettings::ObserverSubscription> |
| 211 local_account_auto_login_id_subscription_; | 221 local_account_auto_login_id_subscription_; |
| 212 | 222 |
| 223 base::FilePath cache_dir_; | |
|
xiyuan
2014/05/02 18:33:51
nit: no need to keep as a member if it is only use
jennyz
2014/05/02 21:05:04
Done.
| |
| 224 scoped_ptr<ExternalCache> external_cache_; | |
| 225 | |
| 213 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); | 226 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); |
| 214 }; | 227 }; |
| 215 | 228 |
| 216 } // namespace chromeos | 229 } // namespace chromeos |
| 217 | 230 |
| 218 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ | 231 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ |
| OLD | NEW |