| 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/policy/enterprise_install_attributes.h" | 18 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 19 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 20 #include "ui/gfx/image/image_skia.h" | 20 #include "ui/gfx/image/image_skia.h" |
| 21 | 21 |
| 22 class PrefRegistrySimple; | 22 class PrefRegistrySimple; |
| 23 class Profile; |
| 23 | 24 |
| 24 namespace base { | 25 namespace base { |
| 25 class RefCountedString; | 26 class RefCountedString; |
| 26 } | 27 } |
| 27 | 28 |
| 29 namespace extensions { |
| 30 class Extension; |
| 31 } |
| 32 |
| 28 namespace chromeos { | 33 namespace chromeos { |
| 29 | 34 |
| 30 class KioskAppData; | 35 class KioskAppData; |
| 31 class KioskAppManagerObserver; | 36 class KioskAppManagerObserver; |
| 32 | 37 |
| 33 // KioskAppManager manages cached app data. | 38 // KioskAppManager manages cached app data. |
| 34 class KioskAppManager : public KioskAppDataDelegate { | 39 class KioskAppManager : public KioskAppDataDelegate { |
| 35 public: | 40 public: |
| 36 enum ConsumerKioskModeStatus { | 41 enum ConsumerKioskModeStatus { |
| 37 // Consumer kiosk mode can be enabled on this machine. | 42 // Consumer kiosk mode can be enabled on this machine. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // |app| is populated. Otherwise, return false. | 122 // |app| is populated. Otherwise, return false. |
| 118 bool GetApp(const std::string& app_id, App* app) const; | 123 bool GetApp(const std::string& app_id, App* app) const; |
| 119 | 124 |
| 120 // Gets the raw icon data for the given app id. Returns NULL if |app_id| | 125 // Gets the raw icon data for the given app id. Returns NULL if |app_id| |
| 121 // is unknown. | 126 // is unknown. |
| 122 const base::RefCountedString* GetAppRawIcon(const std::string& app_id) const; | 127 const base::RefCountedString* GetAppRawIcon(const std::string& app_id) const; |
| 123 | 128 |
| 124 // Gets whether the bailout shortcut is disabled. | 129 // Gets whether the bailout shortcut is disabled. |
| 125 bool GetDisableBailoutShortcut() const; | 130 bool GetDisableBailoutShortcut() const; |
| 126 | 131 |
| 132 // Clears locally cached app data. |
| 133 void ClearAppData(const std::string& app_id); |
| 134 |
| 135 // Updates app data from the |app| in |profile|. |app| is provided to cover |
| 136 // the case of app update case where |app| is the new version and is not |
| 137 // finished installing (e.g. because old version is still running). Otherwise, |
| 138 // |app| could be NULL and the current installed app in |profile| will be |
| 139 // used. |
| 140 void UpdateAppDataFromProfile(const std::string& app_id, |
| 141 Profile* profile, |
| 142 const extensions::Extension* app); |
| 143 |
| 127 void AddObserver(KioskAppManagerObserver* observer); | 144 void AddObserver(KioskAppManagerObserver* observer); |
| 128 void RemoveObserver(KioskAppManagerObserver* observer); | 145 void RemoveObserver(KioskAppManagerObserver* observer); |
| 129 | 146 |
| 130 private: | 147 private: |
| 131 friend struct base::DefaultLazyInstanceTraits<KioskAppManager>; | 148 friend struct base::DefaultLazyInstanceTraits<KioskAppManager>; |
| 132 friend struct base::DefaultDeleter<KioskAppManager>; | 149 friend struct base::DefaultDeleter<KioskAppManager>; |
| 133 friend class KioskAppManagerTest; | 150 friend class KioskAppManagerTest; |
| 134 friend class KioskTest; | 151 friend class KioskTest; |
| 135 | 152 |
| 136 enum AutoLoginState { | 153 enum AutoLoginState { |
| 137 AUTOLOGIN_NONE = 0, | 154 AUTOLOGIN_NONE = 0, |
| 138 AUTOLOGIN_REQUESTED = 1, | 155 AUTOLOGIN_REQUESTED = 1, |
| 139 AUTOLOGIN_APPROVED = 2, | 156 AUTOLOGIN_APPROVED = 2, |
| 140 AUTOLOGIN_REJECTED = 3, | 157 AUTOLOGIN_REJECTED = 3, |
| 141 }; | 158 }; |
| 142 | 159 |
| 143 KioskAppManager(); | 160 KioskAppManager(); |
| 144 virtual ~KioskAppManager(); | 161 virtual ~KioskAppManager(); |
| 145 | 162 |
| 146 // Stop all data loading and remove its dependency on CrosSettings. | 163 // Stop all data loading and remove its dependency on CrosSettings. |
| 147 void CleanUp(); | 164 void CleanUp(); |
| 148 | 165 |
| 149 // Gets KioskAppData for the given app id. | 166 // Gets KioskAppData for the given app id. |
| 150 const KioskAppData* GetAppData(const std::string& app_id) const; | 167 const KioskAppData* GetAppData(const std::string& app_id) const; |
| 168 KioskAppData* GetAppDataMutable(const std::string& app_id); |
| 151 | 169 |
| 152 // Update app data |apps_| based on CrosSettings. | 170 // Update app data |apps_| based on CrosSettings. |
| 153 void UpdateAppData(); | 171 void UpdateAppData(); |
| 154 | 172 |
| 155 // KioskAppDataDelegate overrides: | 173 // KioskAppDataDelegate overrides: |
| 156 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; | 174 virtual void GetKioskAppIconCacheDir(base::FilePath* cache_dir) OVERRIDE; |
| 157 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; | 175 virtual void OnKioskAppDataChanged(const std::string& app_id) OVERRIDE; |
| 158 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; | 176 virtual void OnKioskAppDataLoadFailure(const std::string& app_id) OVERRIDE; |
| 159 | 177 |
| 160 // Callback for EnterpriseInstallAttributes::LockDevice() during | 178 // Callback for EnterpriseInstallAttributes::LockDevice() during |
| 161 // EnableConsumerModeKiosk() call. | 179 // EnableConsumerModeKiosk() call. |
| 162 void OnLockDevice( | 180 void OnLockDevice( |
| 163 const EnableKioskModeCallback& callback, | 181 const EnableKioskModeCallback& callback, |
| 164 policy::EnterpriseInstallAttributes::LockResult result); | 182 policy::EnterpriseInstallAttributes::LockResult result); |
| 165 | 183 |
| 166 // Callback for EnterpriseInstallAttributes::ReadImmutableAttributes() during | 184 // Callback for EnterpriseInstallAttributes::ReadImmutableAttributes() during |
| 167 // GetConsumerKioskModeStatus() call. | 185 // GetConsumerKioskModeStatus() call. |
| 168 void OnReadImmutableAttributes( | 186 void OnReadImmutableAttributes( |
| 169 const GetConsumerKioskModeStatusCallback& callback); | 187 const GetConsumerKioskModeStatusCallback& callback); |
| 170 | 188 |
| 171 // Callback for reading handling checks of the owner public. | 189 // Callback for reading handling checks of the owner public. |
| 172 void OnOwnerFileChecked( | 190 void OnOwnerFileChecked( |
| 173 const GetConsumerKioskModeStatusCallback& callback, | 191 const GetConsumerKioskModeStatusCallback& callback, |
| 174 bool *owner_present); | 192 bool* owner_present); |
| 175 | 193 |
| 176 // Reads/writes auto login state from/to local state. | 194 // Reads/writes auto login state from/to local state. |
| 177 AutoLoginState GetAutoLoginState() const; | 195 AutoLoginState GetAutoLoginState() const; |
| 178 void SetAutoLoginState(AutoLoginState state); | 196 void SetAutoLoginState(AutoLoginState state); |
| 179 | 197 |
| 180 // True if machine ownership is already established. | 198 // True if machine ownership is already established. |
| 181 bool ownership_established_; | 199 bool ownership_established_; |
| 182 ScopedVector<KioskAppData> apps_; | 200 ScopedVector<KioskAppData> apps_; |
| 183 std::string auto_launch_app_id_; | 201 std::string auto_launch_app_id_; |
| 184 ObserverList<KioskAppManagerObserver, true> observers_; | 202 ObserverList<KioskAppManagerObserver, true> observers_; |
| 185 | 203 |
| 186 scoped_ptr<CrosSettings::ObserverSubscription> | 204 scoped_ptr<CrosSettings::ObserverSubscription> |
| 187 local_accounts_subscription_; | 205 local_accounts_subscription_; |
| 188 scoped_ptr<CrosSettings::ObserverSubscription> | 206 scoped_ptr<CrosSettings::ObserverSubscription> |
| 189 local_account_auto_login_id_subscription_; | 207 local_account_auto_login_id_subscription_; |
| 190 | 208 |
| 191 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); | 209 DISALLOW_COPY_AND_ASSIGN(KioskAppManager); |
| 192 }; | 210 }; |
| 193 | 211 |
| 194 } // namespace chromeos | 212 } // namespace chromeos |
| 195 | 213 |
| 196 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ | 214 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_MANAGER_H_ |
| OLD | NEW |