Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Unified Diff: chrome/browser/chromeos/settings/device_settings_provider.cc

Issue 14306004: Put Kiosk App parameters into device settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make kiosk app ID a separate field in policy. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/settings/device_settings_provider.cc
diff --git a/chrome/browser/chromeos/settings/device_settings_provider.cc b/chrome/browser/chromeos/settings/device_settings_provider.cc
index 64b592d06a6491b852d5df71a9bd0689391ee291..22a7c2c98a5c6fe3f1e7980df5f56d2b143b6b2e 100644
--- a/chrome/browser/chromeos/settings/device_settings_provider.cc
+++ b/chrome/browser/chromeos/settings/device_settings_provider.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
-#include "chrome/browser/chromeos/policy/app_pack_updater.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/cros_settings_names.h"
#include "chrome/browser/chromeos/settings/device_settings_cache.h"
@@ -42,6 +41,7 @@ const char* kKnownSettings[] = {
kAccountsPrefAllowGuest,
kAccountsPrefAllowNewUser,
kAccountsPrefDeviceLocalAccounts,
+ kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled,
kAccountsPrefDeviceLocalAccountAutoLoginDelay,
kAccountsPrefDeviceLocalAccountAutoLoginId,
kAccountsPrefEphemeralUsersEnabled,
@@ -226,15 +226,31 @@ void DeviceSettingsProvider::SetInPolicy() {
} else if (prop == kAccountsPrefDeviceLocalAccounts) {
em::DeviceLocalAccountsProto* device_local_accounts =
device_settings_.mutable_device_local_accounts();
- base::ListValue* accounts_list;
- if (value->GetAsList(&accounts_list)) {
- for (base::ListValue::const_iterator entry(accounts_list->begin());
- entry != accounts_list->end(); ++entry) {
- std::string id;
- if ((*entry)->GetAsString(&id))
- device_local_accounts->add_account()->set_id(id);
- else
+ device_local_accounts->clear_account();
+ const base::DictionaryValue* accounts_dict = NULL;
+ if (value->GetAsDictionary(&accounts_dict)) {
+ for (base::DictionaryValue::Iterator entry(*accounts_dict);
+ !entry.IsAtEnd(); entry.Advance()) {
+ const base::DictionaryValue* entry_dict = NULL;
+ if (entry.value().GetAsDictionary(&entry_dict)) {
+ em::DeviceLocalAccountInfoProto* account =
+ device_local_accounts->add_account();
+ account->set_id(entry.key());
+ std::string kiosk_app_id;
+ if (entry_dict->GetStringWithoutPathExpansion(
+ kAccountsPrefDeviceLocalAccountsKeyKioskAppId,
+ &kiosk_app_id)) {
+ account->set_kiosk_app_id(kiosk_app_id);
+ }
+ std::string kiosk_app_update_url;
+ if (entry_dict->GetStringWithoutPathExpansion(
+ kAccountsPrefDeviceLocalAccountsKeyKioskAppUpdateURL,
+ &kiosk_app_update_url)) {
+ account->set_kiosk_app_update_url(kiosk_app_update_url);
+ }
+ } else {
NOTREACHED();
+ }
}
} else {
NOTREACHED();
@@ -255,6 +271,14 @@ void DeviceSettingsProvider::SetInPolicy() {
device_local_accounts->set_auto_login_delay(delay);
else
NOTREACHED();
+ } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled) {
+ em::DeviceLocalAccountsProto* device_local_accounts =
+ device_settings_.mutable_device_local_accounts();
+ bool enabled;
+ if (value->GetAsBoolean(&enabled))
+ device_local_accounts->set_enable_auto_login_bailout(enabled);
+ else
+ NOTREACHED();
} else if (prop == kSignedDataRoamingEnabled) {
em::DataRoamingEnabledProto* roam =
device_settings_.mutable_data_roaming_enabled();
@@ -433,7 +457,7 @@ void DeviceSettingsProvider::DecodeLoginPolicies(
}
new_values_cache->SetValue(kAccountsPrefUsers, list);
- base::ListValue* account_list = new base::ListValue();
+ base::DictionaryValue* account_dict = new base::DictionaryValue();
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kDisableLocalAccounts)) {
const em::DeviceLocalAccountsProto device_local_accounts_proto =
@@ -442,22 +466,24 @@ void DeviceSettingsProvider::DecodeLoginPolicies(
device_local_accounts_proto.account();
RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry;
for (entry = accounts.begin(); entry != accounts.end(); ++entry) {
- if (entry->has_id())
- account_list->AppendString(entry->id());
- }
- }
- new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list);
-
- if (policy.has_start_up_flags()) {
- base::ListValue* list = new base::ListValue();
- const em::StartUpFlagsProto& flags_proto = policy.start_up_flags();
- const RepeatedPtrField<std::string>& flags = flags_proto.flags();
- for (RepeatedPtrField<std::string>::const_iterator it = flags.begin();
- it != flags.end(); ++it) {
- list->Append(new base::StringValue(*it));
+ if (entry->id().empty() || account_dict->HasKey(entry->id()))
bartfab (slow) 2013/04/25 11:17:28 This way, we silently skip duplicates. We should a
Mattias Nissler (ping if slow) 2013/04/26 09:10:05 Obsolete, using a list.
+ continue;
+
+ scoped_ptr<base::DictionaryValue> entry_dict(new base::DictionaryValue());
bartfab (slow) 2013/04/25 11:17:28 As before: Why use a scoped_ptr if you are passing
Mattias Nissler (ping if slow) 2013/04/26 09:10:05 same as before.
+ if (entry->has_kiosk_app_id()) {
+ entry_dict->SetStringWithoutPathExpansion(
+ kAccountsPrefDeviceLocalAccountsKeyKioskAppId,
+ entry->kiosk_app_id());
+ }
+ if (entry->has_kiosk_app_update_url()) {
+ entry_dict->SetStringWithoutPathExpansion(
+ kAccountsPrefDeviceLocalAccountsKeyKioskAppUpdateURL,
+ entry->kiosk_app_update_url());
+ }
+ account_dict->SetWithoutPathExpansion(entry->id(), entry_dict.release());
}
- new_values_cache->SetValue(kStartUpFlags, list);
}
+ new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_dict);
if (policy.has_device_local_accounts()) {
if (policy.device_local_accounts().has_auto_login_id()) {
@@ -471,6 +497,21 @@ void DeviceSettingsProvider::DecodeLoginPolicies(
policy.device_local_accounts().auto_login_delay());
}
}
+
+ new_values_cache->SetBoolean(
+ kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled,
+ policy.device_local_accounts().enable_auto_login_bailout());
+
+ if (policy.has_start_up_flags()) {
+ base::ListValue* list = new base::ListValue();
+ const em::StartUpFlagsProto& flags_proto = policy.start_up_flags();
+ const RepeatedPtrField<std::string>& flags = flags_proto.flags();
+ for (RepeatedPtrField<std::string>::const_iterator it = flags.begin();
+ it != flags.end(); ++it) {
+ list->Append(new base::StringValue(*it));
+ }
+ new_values_cache->SetValue(kStartUpFlags, list);
+ }
}
void DeviceSettingsProvider::DecodeKioskPolicies(
@@ -512,11 +553,13 @@ void DeviceSettingsProvider::DecodeKioskPolicies(
it != app_pack.end(); ++it) {
base::DictionaryValue* entry = new base::DictionaryValue;
if (it->has_extension_id()) {
- entry->SetString(policy::AppPackUpdater::kExtensionId,
- it->extension_id());
+ entry->SetStringWithoutPathExpansion(kAppPackKeyExtensionId,
+ it->extension_id());
+ }
+ if (it->has_update_url()) {
+ entry->SetStringWithoutPathExpansion(kAppPackKeyUpdateUrl,
+ it->update_url());
}
- if (it->has_update_url())
- entry->SetString(policy::AppPackUpdater::kUpdateUrl, it->update_url());
list->Append(entry);
}
new_values_cache->SetValue(kAppPack, list);

Powered by Google App Engine
This is Rietveld 408576698