ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / chromeos / app_mode / kiosk_app_manager.cc
blobe84dff2ec3e220fdc1f6456e1a7ee03b62f05d1e
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
7 #include <map>
8 #include <set>
10 #include "base/bind.h"
11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h"
13 #include "base/logging.h"
14 #include "base/path_service.h"
15 #include "base/prefs/pref_registry_simple.h"
16 #include "base/prefs/pref_service.h"
17 #include "base/prefs/scoped_user_pref_update.h"
18 #include "base/stl_util.h"
19 #include "base/sys_info.h"
20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h"
22 #include "chrome/browser/chromeos/app_mode/kiosk_app_external_loader.h"
23 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h"
24 #include "chrome/browser/chromeos/app_mode/kiosk_external_updater.h"
25 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
26 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
27 #include "chrome/browser/chromeos/policy/device_local_account.h"
28 #include "chrome/browser/chromeos/settings/cros_settings.h"
29 #include "chrome/browser/extensions/external_loader.h"
30 #include "chrome/browser/extensions/external_provider_impl.h"
31 #include "chrome/common/chrome_paths.h"
32 #include "chrome/common/extensions/extension_constants.h"
33 #include "chromeos/chromeos_paths.h"
34 #include "chromeos/cryptohome/async_method_caller.h"
35 #include "chromeos/settings/cros_settings_names.h"
36 #include "components/ownership/owner_key_util.h"
37 #include "content/public/browser/browser_thread.h"
38 #include "extensions/common/extension_urls.h"
40 namespace chromeos {
42 namespace {
44 // Domain that is used for kiosk-app account IDs.
45 const char kKioskAppAccountDomain[] = "kiosk-apps";
47 std::string GenerateKioskAppAccountId(const std::string& app_id) {
48 return app_id + '@' + kKioskAppAccountDomain;
51 void OnRemoveAppCryptohomeComplete(const std::string& app,
52 bool success,
53 cryptohome::MountError return_code) {
54 if (!success) {
55 LOG(ERROR) << "Remove cryptohome for " << app
56 << " failed, return code: " << return_code;
60 // Check for presence of machine owner public key file.
61 void CheckOwnerFilePresence(bool *present) {
62 scoped_refptr<ownership::OwnerKeyUtil> util =
63 OwnerSettingsServiceChromeOSFactory::GetInstance()->GetOwnerKeyUtil();
64 *present = util.get() && util->IsPublicKeyPresent();
67 scoped_refptr<base::SequencedTaskRunner> GetBackgroundTaskRunner() {
68 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
69 CHECK(pool);
70 return pool->GetSequencedTaskRunnerWithShutdownBehavior(
71 pool->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
74 } // namespace
76 // static
77 const char KioskAppManager::kKioskDictionaryName[] = "kiosk";
78 const char KioskAppManager::kKeyApps[] = "apps";
79 const char KioskAppManager::kKeyAutoLoginState[] = "auto_login_state";
80 const char KioskAppManager::kIconCacheDir[] = "kiosk/icon";
81 const char KioskAppManager::kCrxCacheDir[] = "kiosk/crx";
82 const char KioskAppManager::kCrxUnpackDir[] = "kiosk_unpack";
84 // static
85 static base::LazyInstance<KioskAppManager> instance = LAZY_INSTANCE_INITIALIZER;
86 KioskAppManager* KioskAppManager::Get() {
87 return instance.Pointer();
90 // static
91 void KioskAppManager::Shutdown() {
92 if (instance == NULL)
93 return;
95 instance.Pointer()->CleanUp();
98 // static
99 void KioskAppManager::RegisterPrefs(PrefRegistrySimple* registry) {
100 registry->RegisterDictionaryPref(kKioskDictionaryName);
103 KioskAppManager::App::App(
104 const KioskAppData& data,
105 bool is_extension_pending,
106 bool auto_launched_with_zero_delay)
107 : app_id(data.app_id()),
108 user_id(data.user_id()),
109 name(data.name()),
110 icon(data.icon()),
111 is_loading(data.IsLoading() || is_extension_pending),
112 was_auto_launched_with_zero_delay(auto_launched_with_zero_delay) {
115 KioskAppManager::App::App() : is_loading(false),
116 was_auto_launched_with_zero_delay(false) {}
118 KioskAppManager::App::~App() {}
120 std::string KioskAppManager::GetAutoLaunchApp() const {
121 return auto_launch_app_id_;
124 void KioskAppManager::SetAutoLaunchApp(const std::string& app_id) {
125 SetAutoLoginState(AUTOLOGIN_REQUESTED);
126 // Clean first, so the proper change callbacks are triggered even
127 // if we are only changing AutoLoginState here.
128 if (!auto_launch_app_id_.empty()) {
129 CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId,
130 std::string());
133 CrosSettings::Get()->SetString(
134 kAccountsPrefDeviceLocalAccountAutoLoginId,
135 app_id.empty() ? std::string() : GenerateKioskAppAccountId(app_id));
136 CrosSettings::Get()->SetInteger(
137 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 0);
140 void KioskAppManager::SetAppWasAutoLaunchedWithZeroDelay(
141 const std::string& app_id) {
142 DCHECK_EQ(auto_launch_app_id_, app_id);
143 currently_auto_launched_with_zero_delay_app_ = app_id;
146 void KioskAppManager::EnableConsumerKioskAutoLaunch(
147 const KioskAppManager::EnableKioskAutoLaunchCallback& callback) {
148 policy::BrowserPolicyConnectorChromeOS* connector =
149 g_browser_process->platform_part()->browser_policy_connector_chromeos();
150 connector->GetInstallAttributes()->LockDevice(
151 std::string(), // user
152 policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH,
153 std::string(), // device_id
154 base::Bind(
155 &KioskAppManager::OnLockDevice, base::Unretained(this), callback));
158 void KioskAppManager::GetConsumerKioskAutoLaunchStatus(
159 const KioskAppManager::GetConsumerKioskAutoLaunchStatusCallback& callback) {
160 policy::BrowserPolicyConnectorChromeOS* connector =
161 g_browser_process->platform_part()->browser_policy_connector_chromeos();
162 connector->GetInstallAttributes()->ReadImmutableAttributes(
163 base::Bind(&KioskAppManager::OnReadImmutableAttributes,
164 base::Unretained(this),
165 callback));
168 bool KioskAppManager::IsConsumerKioskDeviceWithAutoLaunch() {
169 policy::BrowserPolicyConnectorChromeOS* connector =
170 g_browser_process->platform_part()->browser_policy_connector_chromeos();
171 return connector->GetInstallAttributes() &&
172 connector->GetInstallAttributes()
173 ->IsConsumerKioskDeviceWithAutoLaunch();
176 void KioskAppManager::OnLockDevice(
177 const KioskAppManager::EnableKioskAutoLaunchCallback& callback,
178 policy::EnterpriseInstallAttributes::LockResult result) {
179 if (callback.is_null())
180 return;
182 callback.Run(result == policy::EnterpriseInstallAttributes::LOCK_SUCCESS);
185 void KioskAppManager::OnOwnerFileChecked(
186 const KioskAppManager::GetConsumerKioskAutoLaunchStatusCallback& callback,
187 bool* owner_present) {
188 ownership_established_ = *owner_present;
190 if (callback.is_null())
191 return;
193 // If we have owner already established on the machine, don't let
194 // consumer kiosk to be enabled.
195 if (ownership_established_)
196 callback.Run(CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED);
197 else
198 callback.Run(CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE);
201 void KioskAppManager::OnReadImmutableAttributes(
202 const KioskAppManager::GetConsumerKioskAutoLaunchStatusCallback&
203 callback) {
204 if (callback.is_null())
205 return;
207 ConsumerKioskAutoLaunchStatus status =
208 CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED;
209 policy::BrowserPolicyConnectorChromeOS* connector =
210 g_browser_process->platform_part()->browser_policy_connector_chromeos();
211 policy::EnterpriseInstallAttributes* attributes =
212 connector->GetInstallAttributes();
213 switch (attributes->GetMode()) {
214 case policy::DEVICE_MODE_NOT_SET: {
215 if (!base::SysInfo::IsRunningOnChromeOS()) {
216 status = CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE;
217 } else if (!ownership_established_) {
218 bool* owner_present = new bool(false);
219 content::BrowserThread::PostBlockingPoolTaskAndReply(
220 FROM_HERE,
221 base::Bind(&CheckOwnerFilePresence,
222 owner_present),
223 base::Bind(&KioskAppManager::OnOwnerFileChecked,
224 base::Unretained(this),
225 callback,
226 base::Owned(owner_present)));
227 return;
229 break;
231 case policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH:
232 status = CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED;
233 break;
234 default:
235 break;
238 callback.Run(status);
241 void KioskAppManager::SetEnableAutoLaunch(bool value) {
242 SetAutoLoginState(value ? AUTOLOGIN_APPROVED : AUTOLOGIN_REJECTED);
245 bool KioskAppManager::IsAutoLaunchRequested() const {
246 if (GetAutoLaunchApp().empty())
247 return false;
249 // Apps that were installed by the policy don't require machine owner
250 // consent through UI.
251 policy::BrowserPolicyConnectorChromeOS* connector =
252 g_browser_process->platform_part()->browser_policy_connector_chromeos();
253 if (connector->IsEnterpriseManaged())
254 return false;
256 return GetAutoLoginState() == AUTOLOGIN_REQUESTED;
259 bool KioskAppManager::IsAutoLaunchEnabled() const {
260 if (GetAutoLaunchApp().empty())
261 return false;
263 // Apps that were installed by the policy don't require machine owner
264 // consent through UI.
265 policy::BrowserPolicyConnectorChromeOS* connector =
266 g_browser_process->platform_part()->browser_policy_connector_chromeos();
267 if (connector->IsEnterpriseManaged())
268 return true;
270 return GetAutoLoginState() == AUTOLOGIN_APPROVED;
273 void KioskAppManager::AddApp(const std::string& app_id) {
274 std::vector<policy::DeviceLocalAccount> device_local_accounts =
275 policy::GetDeviceLocalAccounts(CrosSettings::Get());
277 // Don't insert the app if it's already in the list.
278 for (std::vector<policy::DeviceLocalAccount>::const_iterator
279 it = device_local_accounts.begin();
280 it != device_local_accounts.end(); ++it) {
281 if (it->type == policy::DeviceLocalAccount::TYPE_KIOSK_APP &&
282 it->kiosk_app_id == app_id) {
283 return;
287 // Add the new account.
288 device_local_accounts.push_back(policy::DeviceLocalAccount(
289 policy::DeviceLocalAccount::TYPE_KIOSK_APP,
290 GenerateKioskAppAccountId(app_id),
291 app_id,
292 std::string()));
294 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts);
297 void KioskAppManager::RemoveApp(const std::string& app_id) {
298 // Resets auto launch app if it is the removed app.
299 if (auto_launch_app_id_ == app_id)
300 SetAutoLaunchApp(std::string());
302 std::vector<policy::DeviceLocalAccount> device_local_accounts =
303 policy::GetDeviceLocalAccounts(CrosSettings::Get());
304 if (device_local_accounts.empty())
305 return;
307 // Remove entries that match |app_id|.
308 for (std::vector<policy::DeviceLocalAccount>::iterator
309 it = device_local_accounts.begin();
310 it != device_local_accounts.end(); ++it) {
311 if (it->type == policy::DeviceLocalAccount::TYPE_KIOSK_APP &&
312 it->kiosk_app_id == app_id) {
313 device_local_accounts.erase(it);
314 break;
318 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts);
321 void KioskAppManager::GetApps(Apps* apps) const {
322 apps->clear();
323 apps->reserve(apps_.size());
324 for (size_t i = 0; i < apps_.size(); ++i) {
325 const KioskAppData& app_data = *apps_[i];
326 if (app_data.status() != KioskAppData::STATUS_ERROR) {
327 apps->push_back(App(
328 app_data, external_cache_->IsExtensionPending(app_data.app_id()),
329 app_data.app_id() == currently_auto_launched_with_zero_delay_app_));
334 bool KioskAppManager::GetApp(const std::string& app_id, App* app) const {
335 const KioskAppData* data = GetAppData(app_id);
336 if (!data)
337 return false;
339 *app = App(*data, external_cache_->IsExtensionPending(app_id),
340 app_id == currently_auto_launched_with_zero_delay_app_);
341 return true;
344 bool KioskAppManager::GetDisableBailoutShortcut() const {
345 bool enable;
346 if (CrosSettings::Get()->GetBoolean(
347 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) {
348 return !enable;
351 return false;
354 void KioskAppManager::ClearAppData(const std::string& app_id) {
355 KioskAppData* app_data = GetAppDataMutable(app_id);
356 if (!app_data)
357 return;
359 app_data->ClearCache();
362 void KioskAppManager::UpdateAppDataFromProfile(
363 const std::string& app_id,
364 Profile* profile,
365 const extensions::Extension* app) {
366 KioskAppData* app_data = GetAppDataMutable(app_id);
367 if (!app_data)
368 return;
370 app_data->LoadFromInstalledApp(profile, app);
373 void KioskAppManager::RetryFailedAppDataFetch() {
374 for (size_t i = 0; i < apps_.size(); ++i) {
375 if (apps_[i]->status() == KioskAppData::STATUS_ERROR)
376 apps_[i]->Load();
380 bool KioskAppManager::HasCachedCrx(const std::string& app_id) const {
381 base::FilePath crx_path;
382 std::string version;
383 return GetCachedCrx(app_id, &crx_path, &version);
386 bool KioskAppManager::GetCachedCrx(const std::string& app_id,
387 base::FilePath* file_path,
388 std::string* version) const {
389 return external_cache_->GetExtension(app_id, file_path, version);
392 void KioskAppManager::AddObserver(KioskAppManagerObserver* observer) {
393 observers_.AddObserver(observer);
396 void KioskAppManager::RemoveObserver(KioskAppManagerObserver* observer) {
397 observers_.RemoveObserver(observer);
400 extensions::ExternalLoader* KioskAppManager::CreateExternalLoader() {
401 if (external_loader_created_) {
402 NOTREACHED();
403 return NULL;
405 external_loader_created_ = true;
406 KioskAppExternalLoader* loader = new KioskAppExternalLoader();
407 external_loader_ = loader->AsWeakPtr();
409 return loader;
412 void KioskAppManager::InstallFromCache(const std::string& id) {
413 const base::DictionaryValue* extension = NULL;
414 if (external_cache_->cached_extensions()->GetDictionary(id, &extension)) {
415 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue);
416 base::DictionaryValue* extension_copy = extension->DeepCopy();
417 prefs->Set(id, extension_copy);
418 external_loader_->SetCurrentAppExtensions(prefs.Pass());
419 } else {
420 LOG(ERROR) << "Can't find app in the cached externsions"
421 << " id = " << id;
425 void KioskAppManager::UpdateExternalCache() {
426 UpdateAppData();
429 void KioskAppManager::OnKioskAppCacheUpdated(const std::string& app_id) {
430 FOR_EACH_OBSERVER(
431 KioskAppManagerObserver, observers_, OnKioskAppCacheUpdated(app_id));
434 void KioskAppManager::OnKioskAppExternalUpdateComplete(bool success) {
435 FOR_EACH_OBSERVER(KioskAppManagerObserver,
436 observers_,
437 OnKioskAppExternalUpdateComplete(success));
440 void KioskAppManager::PutValidatedExternalExtension(
441 const std::string& app_id,
442 const base::FilePath& crx_path,
443 const std::string& version,
444 const ExternalCache::PutExternalExtensionCallback& callback) {
445 external_cache_->PutExternalExtension(app_id, crx_path, version, callback);
448 KioskAppManager::KioskAppManager()
449 : ownership_established_(false), external_loader_created_(false) {
450 base::FilePath cache_dir;
451 GetCrxCacheDir(&cache_dir);
452 external_cache_.reset(
453 new ExternalCache(cache_dir,
454 g_browser_process->system_request_context(),
455 GetBackgroundTaskRunner(),
456 this,
457 true /* always_check_updates */,
458 false /* wait_for_cache_initialization */));
459 UpdateAppData();
460 local_accounts_subscription_ =
461 CrosSettings::Get()->AddSettingsObserver(
462 kAccountsPrefDeviceLocalAccounts,
463 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this)));
464 local_account_auto_login_id_subscription_ =
465 CrosSettings::Get()->AddSettingsObserver(
466 kAccountsPrefDeviceLocalAccountAutoLoginId,
467 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this)));
470 KioskAppManager::~KioskAppManager() {}
472 void KioskAppManager::MonitorKioskExternalUpdate() {
473 base::FilePath cache_dir;
474 GetCrxCacheDir(&cache_dir);
475 base::FilePath unpack_dir;
476 GetCrxUnpackDir(&unpack_dir);
477 usb_stick_updater_.reset(new KioskExternalUpdater(
478 GetBackgroundTaskRunner(), cache_dir, unpack_dir));
481 void KioskAppManager::CleanUp() {
482 local_accounts_subscription_.reset();
483 local_account_auto_login_id_subscription_.reset();
484 apps_.clear();
485 usb_stick_updater_.reset();
486 external_cache_.reset();
489 const KioskAppData* KioskAppManager::GetAppData(
490 const std::string& app_id) const {
491 for (size_t i = 0; i < apps_.size(); ++i) {
492 const KioskAppData* data = apps_[i];
493 if (data->app_id() == app_id)
494 return data;
497 return NULL;
500 KioskAppData* KioskAppManager::GetAppDataMutable(const std::string& app_id) {
501 return const_cast<KioskAppData*>(GetAppData(app_id));
504 void KioskAppManager::UpdateAppData() {
505 // Gets app id to data mapping for existing apps.
506 std::map<std::string, KioskAppData*> old_apps;
507 for (size_t i = 0; i < apps_.size(); ++i)
508 old_apps[apps_[i]->app_id()] = apps_[i];
509 apps_.weak_clear(); // |old_apps| takes ownership
511 auto_launch_app_id_.clear();
512 std::string auto_login_account_id;
513 CrosSettings::Get()->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId,
514 &auto_login_account_id);
516 // Re-populates |apps_| and reuses existing KioskAppData when possible.
517 const std::vector<policy::DeviceLocalAccount> device_local_accounts =
518 policy::GetDeviceLocalAccounts(CrosSettings::Get());
519 for (std::vector<policy::DeviceLocalAccount>::const_iterator
520 it = device_local_accounts.begin();
521 it != device_local_accounts.end(); ++it) {
522 if (it->type != policy::DeviceLocalAccount::TYPE_KIOSK_APP)
523 continue;
525 if (it->account_id == auto_login_account_id)
526 auto_launch_app_id_ = it->kiosk_app_id;
528 std::map<std::string, KioskAppData*>::iterator old_it =
529 old_apps.find(it->kiosk_app_id);
530 if (old_it != old_apps.end()) {
531 apps_.push_back(old_it->second);
532 old_apps.erase(old_it);
533 } else {
534 KioskAppData* new_app = new KioskAppData(
535 this, it->kiosk_app_id, it->user_id, GURL(it->kiosk_app_update_url));
536 apps_.push_back(new_app); // Takes ownership of |new_app|.
537 new_app->Load();
541 // Clears cache and deletes the remaining old data.
542 std::vector<std::string> apps_to_remove;
543 for (std::map<std::string, KioskAppData*>::iterator it = old_apps.begin();
544 it != old_apps.end(); ++it) {
545 it->second->ClearCache();
546 cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove(
547 it->second->user_id(),
548 base::Bind(&OnRemoveAppCryptohomeComplete, it->first));
549 apps_to_remove.push_back(it->second->app_id());
551 STLDeleteValues(&old_apps);
552 external_cache_->RemoveExtensions(apps_to_remove);
554 // Request external_cache_ to download new apps and update the existing
555 // apps.
556 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue);
557 for (size_t i = 0; i < apps_.size(); ++i) {
558 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
560 if (apps_[i]->update_url().is_valid()) {
561 entry->SetString(extensions::ExternalProviderImpl::kExternalUpdateUrl,
562 apps_[i]->update_url().spec());
563 } else {
564 entry->SetString(extensions::ExternalProviderImpl::kExternalUpdateUrl,
565 extension_urls::GetWebstoreUpdateUrl().spec());
568 prefs->Set(apps_[i]->app_id(), entry.release());
570 external_cache_->UpdateExtensionsList(prefs.Pass());
572 RetryFailedAppDataFetch();
574 FOR_EACH_OBSERVER(KioskAppManagerObserver, observers_,
575 OnKioskAppsSettingsChanged());
578 void KioskAppManager::GetKioskAppIconCacheDir(base::FilePath* cache_dir) {
579 base::FilePath user_data_dir;
580 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
581 *cache_dir = user_data_dir.AppendASCII(kIconCacheDir);
584 void KioskAppManager::OnKioskAppDataChanged(const std::string& app_id) {
585 FOR_EACH_OBSERVER(KioskAppManagerObserver,
586 observers_,
587 OnKioskAppDataChanged(app_id));
590 void KioskAppManager::OnKioskAppDataLoadFailure(const std::string& app_id) {
591 FOR_EACH_OBSERVER(KioskAppManagerObserver,
592 observers_,
593 OnKioskAppDataLoadFailure(app_id));
596 void KioskAppManager::OnExtensionListsUpdated(
597 const base::DictionaryValue* prefs) {
600 void KioskAppManager::OnExtensionLoadedInCache(const std::string& id) {
601 KioskAppData* app_data = GetAppDataMutable(id);
602 if (!app_data)
603 return;
605 base::FilePath crx_path;
606 std::string version;
607 if (GetCachedCrx(id, &crx_path, &version))
608 app_data->SetCachedCrx(crx_path);
610 FOR_EACH_OBSERVER(KioskAppManagerObserver,
611 observers_,
612 OnKioskExtensionLoadedInCache(id));
616 void KioskAppManager::OnExtensionDownloadFailed(
617 const std::string& id,
618 extensions::ExtensionDownloaderDelegate::Error error) {
619 KioskAppData* app_data = GetAppDataMutable(id);
620 if (!app_data)
621 return;
622 FOR_EACH_OBSERVER(KioskAppManagerObserver,
623 observers_,
624 OnKioskExtensionDownloadFailed(id));
627 KioskAppManager::AutoLoginState KioskAppManager::GetAutoLoginState() const {
628 PrefService* prefs = g_browser_process->local_state();
629 const base::DictionaryValue* dict =
630 prefs->GetDictionary(KioskAppManager::kKioskDictionaryName);
631 int value;
632 if (!dict->GetInteger(kKeyAutoLoginState, &value))
633 return AUTOLOGIN_NONE;
635 return static_cast<AutoLoginState>(value);
638 void KioskAppManager::SetAutoLoginState(AutoLoginState state) {
639 PrefService* prefs = g_browser_process->local_state();
640 DictionaryPrefUpdate dict_update(prefs,
641 KioskAppManager::kKioskDictionaryName);
642 dict_update->SetInteger(kKeyAutoLoginState, state);
643 prefs->CommitPendingWrite();
646 void KioskAppManager::GetCrxCacheDir(base::FilePath* cache_dir) {
647 base::FilePath user_data_dir;
648 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
649 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir);
652 void KioskAppManager::GetCrxUnpackDir(base::FilePath* unpack_dir) {
653 base::FilePath temp_dir;
654 base::GetTempDir(&temp_dir);
655 *unpack_dir = temp_dir.AppendASCII(kCrxUnpackDir);
658 } // namespace chromeos