Chromium Code Reviews| Index: chrome/browser/chromeos/app_mode/kiosk_app_manager.cc |
| diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_manager.cc b/chrome/browser/chromeos/app_mode/kiosk_app_manager.cc |
| index bd9f0e5ac811fe13cc9cb67b2f431da29d035346..cd1f6dbb5b7463d9165b4aefa34ded5fe32d6213 100644 |
| --- a/chrome/browser/chromeos/app_mode/kiosk_app_manager.cc |
| +++ b/chrome/browser/chromeos/app_mode/kiosk_app_manager.cc |
| @@ -13,6 +13,7 @@ |
| #include "base/values.h" |
| #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" |
| #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" |
| +#include "chrome/browser/chromeos/login/user_manager.h" |
| #include "chrome/browser/chromeos/settings/cros_settings.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/chrome_paths.h" |
| @@ -70,24 +71,31 @@ KioskAppManager::App::~App() {} |
| std::string KioskAppManager::GetAutoLaunchApp() const { |
| std::string app_id; |
| - if (CrosSettings::Get()->GetString(kKioskAutoLaunch, &app_id)) |
| + std::string auto_login_id; |
| + if (CrosSettings::Get()->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
| + &auto_login_id) && |
| + UserManager::ParseKioskAppUserId(auto_login_id, &app_id)) { |
| return app_id; |
| + } |
| return std::string(); |
| } |
| void KioskAppManager::SetAutoLaunchApp(const std::string& app_id) { |
| - CrosSettings::Get()->SetString(kKioskAutoLaunch, app_id); |
| + CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
| + UserManager::FormatKioskAppUserId(app_id)); |
| + CrosSettings::Get()->SetInteger(kAccountsPrefDeviceLocalAccountAutoLoginId, |
|
xiyuan
2013/04/23 06:36:56
Is this kAccountsPrefDeviceLocalAccountAutoLoginDe
Mattias Nissler (ping if slow)
2013/04/23 14:01:01
Yes :)
|
| + 0); |
| } |
| void KioskAppManager::AddApp(const std::string& app_id) { |
| - base::StringValue value(app_id); |
| - CrosSettings::Get()->AppendToList(kKioskApps, &value); |
| + base::StringValue value(UserManager::FormatKioskAppUserId(app_id)); |
| + CrosSettings::Get()->AppendToList(kAccountsPrefDeviceLocalAccounts, &value); |
| } |
| void KioskAppManager::RemoveApp(const std::string& app_id) { |
| - base::StringValue value(app_id); |
| - CrosSettings::Get()->RemoveFromList(kKioskApps, &value); |
| + base::StringValue value(UserManager::FormatKioskAppUserId(app_id)); |
| + CrosSettings::Get()->RemoveFromList(kAccountsPrefDeviceLocalAccounts, &value); |
| } |
| void KioskAppManager::GetApps(Apps* apps) const { |
| @@ -115,9 +123,11 @@ const base::RefCountedString* KioskAppManager::GetAppRawIcon( |
| } |
| bool KioskAppManager::GetDisableBailoutShortcut() const { |
| - bool disable; |
| - if (CrosSettings::Get()->GetBoolean(kKioskDisableBailoutShortcut, &disable)) |
| - return disable; |
| + bool enable; |
| + if (CrosSettings::Get()->GetBoolean( |
| + kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) { |
| + return !enable; |
| + } |
| return false; |
| } |
| @@ -132,13 +142,23 @@ void KioskAppManager::RemoveObserver(KioskAppManagerObserver* observer) { |
| KioskAppManager::KioskAppManager() { |
| UpdateAppData(); |
| - CrosSettings::Get()->AddSettingsObserver(kKioskApps, this); |
| + CrosSettings::Get()->AddSettingsObserver( |
| + kAccountsPrefDeviceLocalAccounts, this); |
| + CrosSettings::Get()->AddSettingsObserver( |
| + kAccountsPrefDeviceLocalAccountAutoLoginId, this); |
| + CrosSettings::Get()->AddSettingsObserver( |
| + kAccountsPrefDeviceLocalAccountAutoLoginDelay, this); |
| } |
| KioskAppManager::~KioskAppManager() {} |
| void KioskAppManager::CleanUp() { |
| - CrosSettings::Get()->RemoveSettingsObserver(kKioskApps, this); |
| + CrosSettings::Get()->RemoveSettingsObserver( |
| + kAccountsPrefDeviceLocalAccounts, this); |
| + CrosSettings::Get()->RemoveSettingsObserver( |
| + kAccountsPrefDeviceLocalAccountAutoLoginId, this); |
| + CrosSettings::Get()->RemoveSettingsObserver( |
| + kAccountsPrefDeviceLocalAccountAutoLoginDelay, this); |
| apps_.clear(); |
| } |
| @@ -160,24 +180,36 @@ void KioskAppManager::UpdateAppData() { |
| old_apps[apps_[i]->id()] = apps_[i]; |
| apps_.weak_clear(); // |old_apps| takes ownership |
| - const base::ListValue* new_apps; |
| - CHECK(CrosSettings::Get()->GetList(kKioskApps, &new_apps)); |
| - |
| - // Re-populates |apps_| and reuses existing KioskAppData when possible. |
| - for (base::ListValue::const_iterator new_it = new_apps->begin(); |
| - new_it != new_apps->end(); |
| - ++new_it) { |
| - std::string id; |
| - CHECK((*new_it)->GetAsString(&id)); |
| - |
| - std::map<std::string, KioskAppData*>::iterator old_it = old_apps.find(id); |
| - if (old_it != old_apps.end()) { |
| - apps_.push_back(old_it->second); |
| - old_apps.erase(old_it); |
| - } else { |
| - KioskAppData* new_app = new KioskAppData(this, id); |
| - apps_.push_back(new_app); // Takes ownership of |new_app|. |
| - new_app->Load(); |
| + const base::ListValue* local_accounts; |
| + if (CrosSettings::Get()->GetList(kAccountsPrefDeviceLocalAccounts, |
| + &local_accounts)) { |
| + // Re-populates |apps_| and reuses existing KioskAppData when possible. |
| + for (base::ListValue::const_iterator account = local_accounts->begin(); |
| + account != local_accounts->end(); |
| + ++account) { |
| + std::string user_id; |
| + if (!(*account)->GetAsString(&user_id)) { |
| + NOTREACHED(); |
| + continue; |
| + } |
| + |
| + std::string kiosk_app_id; |
| + if (!UserManager::ParseKioskAppUserId(user_id, &kiosk_app_id)) { |
| + // Not a kiosk app. |
| + continue; |
| + } |
| + |
| + |
| + std::map<std::string, KioskAppData*>::iterator old_it = |
| + old_apps.find(kiosk_app_id); |
| + if (old_it != old_apps.end()) { |
| + apps_.push_back(old_it->second); |
| + old_apps.erase(old_it); |
| + } else { |
| + KioskAppData* new_app = new KioskAppData(this, kiosk_app_id); |
| + apps_.push_back(new_app); // Takes ownership of |new_app|. |
| + new_app->Load(); |
| + } |
| } |
| } |
| @@ -189,15 +221,15 @@ void KioskAppManager::UpdateAppData() { |
| it->first, base::Bind(&OnRemoveAppCryptohomeComplete, it->first)); |
| } |
| STLDeleteValues(&old_apps); |
| + |
| + FOR_EACH_OBSERVER(KioskAppManagerObserver, observers_, |
| + OnKioskAppsListChanged()); |
| } |
| void KioskAppManager::Observe(int type, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) { |
| DCHECK_EQ(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED, type); |
| - DCHECK_EQ(kKioskApps, |
| - *content::Details<const std::string>(details).ptr()); |
| - |
| UpdateAppData(); |
| } |