OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/settings/device_settings_provider.h" | 5 #include "chrome/browser/chromeos/settings/device_settings_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 // List of settings handled by the DeviceSettingsProvider. | 36 // List of settings handled by the DeviceSettingsProvider. |
37 const char* kKnownSettings[] = { | 37 const char* kKnownSettings[] = { |
38 kAccountsPrefAllowGuest, | 38 kAccountsPrefAllowGuest, |
39 kAccountsPrefAllowNewUser, | 39 kAccountsPrefAllowNewUser, |
40 kAccountsPrefEphemeralUsersEnabled, | 40 kAccountsPrefEphemeralUsersEnabled, |
41 kAccountsPrefShowUserNamesOnSignIn, | 41 kAccountsPrefShowUserNamesOnSignIn, |
42 kAccountsPrefUsers, | 42 kAccountsPrefUsers, |
| 43 kAccountsPrefDeviceLocalAccounts, |
43 kAppPack, | 44 kAppPack, |
44 kDeviceOwner, | 45 kDeviceOwner, |
45 kIdleLogoutTimeout, | 46 kIdleLogoutTimeout, |
46 kIdleLogoutWarningDuration, | 47 kIdleLogoutWarningDuration, |
47 kPolicyMissingMitigationMode, | 48 kPolicyMissingMitigationMode, |
48 kReleaseChannel, | 49 kReleaseChannel, |
49 kReleaseChannelDelegated, | 50 kReleaseChannelDelegated, |
50 kReportDeviceActivityTimes, | 51 kReportDeviceActivityTimes, |
51 kReportDeviceBootMode, | 52 kReportDeviceBootMode, |
52 kReportDeviceLocation, | 53 kReportDeviceLocation, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 else | 205 else |
205 NOTREACHED(); | 206 NOTREACHED(); |
206 } else if (prop == kAccountsPrefShowUserNamesOnSignIn) { | 207 } else if (prop == kAccountsPrefShowUserNamesOnSignIn) { |
207 em::ShowUserNamesOnSigninProto* show = | 208 em::ShowUserNamesOnSigninProto* show = |
208 device_settings_.mutable_show_user_names(); | 209 device_settings_.mutable_show_user_names(); |
209 bool show_value; | 210 bool show_value; |
210 if (value->GetAsBoolean(&show_value)) | 211 if (value->GetAsBoolean(&show_value)) |
211 show->set_show_user_names(show_value); | 212 show->set_show_user_names(show_value); |
212 else | 213 else |
213 NOTREACHED(); | 214 NOTREACHED(); |
| 215 } else if (prop == kAccountsPrefDeviceLocalAccounts) { |
| 216 em::DeviceLocalAccountsProto* device_local_accounts = |
| 217 device_settings_.mutable_device_local_accounts(); |
| 218 base::ListValue* accounts_list; |
| 219 if (value->GetAsList(&accounts_list)) { |
| 220 for (base::ListValue::const_iterator entry(accounts_list->begin()); |
| 221 entry != accounts_list->end(); ++entry) { |
| 222 std::string id; |
| 223 if ((*entry)->GetAsString(&id)) |
| 224 device_local_accounts->add_account()->set_id(id); |
| 225 else |
| 226 NOTREACHED(); |
| 227 } |
| 228 } else { |
| 229 NOTREACHED(); |
| 230 } |
214 } else if (prop == kSignedDataRoamingEnabled) { | 231 } else if (prop == kSignedDataRoamingEnabled) { |
215 em::DataRoamingEnabledProto* roam = | 232 em::DataRoamingEnabledProto* roam = |
216 device_settings_.mutable_data_roaming_enabled(); | 233 device_settings_.mutable_data_roaming_enabled(); |
217 bool roaming_value = false; | 234 bool roaming_value = false; |
218 if (value->GetAsBoolean(&roaming_value)) | 235 if (value->GetAsBoolean(&roaming_value)) |
219 roam->set_data_roaming_enabled(roaming_value); | 236 roam->set_data_roaming_enabled(roaming_value); |
220 else | 237 else |
221 NOTREACHED(); | 238 NOTREACHED(); |
222 ApplyRoamingSetting(roaming_value); | 239 ApplyRoamingSetting(roaming_value); |
223 } else if (prop == kSettingProxyEverywhere) { | 240 } else if (prop == kSettingProxyEverywhere) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 371 |
355 base::ListValue* list = new base::ListValue(); | 372 base::ListValue* list = new base::ListValue(); |
356 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist(); | 373 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist(); |
357 const RepeatedPtrField<std::string>& whitelist = | 374 const RepeatedPtrField<std::string>& whitelist = |
358 whitelist_proto.user_whitelist(); | 375 whitelist_proto.user_whitelist(); |
359 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); | 376 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); |
360 it != whitelist.end(); ++it) { | 377 it != whitelist.end(); ++it) { |
361 list->Append(base::Value::CreateStringValue(*it)); | 378 list->Append(base::Value::CreateStringValue(*it)); |
362 } | 379 } |
363 new_values_cache->SetValue(kAccountsPrefUsers, list); | 380 new_values_cache->SetValue(kAccountsPrefUsers, list); |
| 381 |
| 382 base::ListValue* account_list = new base::ListValue(); |
| 383 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = |
| 384 policy.device_local_accounts().account(); |
| 385 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; |
| 386 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { |
| 387 if (entry->has_id()) |
| 388 account_list->AppendString(entry->id()); |
| 389 } |
| 390 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list); |
364 } | 391 } |
365 | 392 |
366 void DeviceSettingsProvider::DecodeKioskPolicies( | 393 void DeviceSettingsProvider::DecodeKioskPolicies( |
367 const em::ChromeDeviceSettingsProto& policy, | 394 const em::ChromeDeviceSettingsProto& policy, |
368 PrefValueMap* new_values_cache) const { | 395 PrefValueMap* new_values_cache) const { |
369 if (policy.has_forced_logout_timeouts()) { | 396 if (policy.has_forced_logout_timeouts()) { |
370 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { | 397 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { |
371 new_values_cache->SetInteger( | 398 new_values_cache->SetInteger( |
372 kIdleLogoutTimeout, | 399 kIdleLogoutTimeout, |
373 policy.forced_logout_timeouts().idle_logout_timeout()); | 400 policy.forced_logout_timeouts().idle_logout_timeout()); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 void DeviceSettingsProvider::AttemptMigration() { | 762 void DeviceSettingsProvider::AttemptMigration() { |
736 if (device_settings_service_->HasPrivateOwnerKey()) { | 763 if (device_settings_service_->HasPrivateOwnerKey()) { |
737 PrefValueMap::const_iterator i; | 764 PrefValueMap::const_iterator i; |
738 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 765 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
739 DoSet(i->first, *i->second); | 766 DoSet(i->first, *i->second); |
740 migration_values_.Clear(); | 767 migration_values_.Clear(); |
741 } | 768 } |
742 } | 769 } |
743 | 770 |
744 } // namespace chromeos | 771 } // namespace chromeos |
OLD | NEW |