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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 namespace em = enterprise_management; | 34 namespace em = enterprise_management; |
35 | 35 |
36 namespace chromeos { | 36 namespace chromeos { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 // List of settings handled by the DeviceSettingsProvider. | 40 // List of settings handled by the DeviceSettingsProvider. |
41 const char* kKnownSettings[] = { | 41 const char* kKnownSettings[] = { |
42 kAccountsPrefAllowGuest, | 42 kAccountsPrefAllowGuest, |
43 kAccountsPrefAllowNewUser, | 43 kAccountsPrefAllowNewUser, |
| 44 kAccountsPrefDeviceLocalAccounts, |
| 45 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
| 46 kAccountsPrefDeviceLocalAccountAutoLoginId, |
44 kAccountsPrefEphemeralUsersEnabled, | 47 kAccountsPrefEphemeralUsersEnabled, |
45 kAccountsPrefShowUserNamesOnSignIn, | 48 kAccountsPrefShowUserNamesOnSignIn, |
46 kAccountsPrefUsers, | 49 kAccountsPrefUsers, |
47 kAccountsPrefDeviceLocalAccounts, | |
48 kAllowRedeemChromeOsRegistrationOffers, | 50 kAllowRedeemChromeOsRegistrationOffers, |
49 kAppPack, | 51 kAppPack, |
50 kDeviceOwner, | 52 kDeviceOwner, |
51 kIdleLogoutTimeout, | 53 kIdleLogoutTimeout, |
52 kIdleLogoutWarningDuration, | 54 kIdleLogoutWarningDuration, |
53 kPolicyMissingMitigationMode, | 55 kPolicyMissingMitigationMode, |
54 kReleaseChannel, | 56 kReleaseChannel, |
55 kReleaseChannelDelegated, | 57 kReleaseChannelDelegated, |
56 kReportDeviceActivityTimes, | 58 kReportDeviceActivityTimes, |
57 kReportDeviceBootMode, | 59 kReportDeviceBootMode, |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 entry != accounts_list->end(); ++entry) { | 230 entry != accounts_list->end(); ++entry) { |
229 std::string id; | 231 std::string id; |
230 if ((*entry)->GetAsString(&id)) | 232 if ((*entry)->GetAsString(&id)) |
231 device_local_accounts->add_account()->set_id(id); | 233 device_local_accounts->add_account()->set_id(id); |
232 else | 234 else |
233 NOTREACHED(); | 235 NOTREACHED(); |
234 } | 236 } |
235 } else { | 237 } else { |
236 NOTREACHED(); | 238 NOTREACHED(); |
237 } | 239 } |
| 240 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginId) { |
| 241 em::DeviceLocalAccountsProto* device_local_accounts = |
| 242 device_settings_.mutable_device_local_accounts(); |
| 243 std::string id; |
| 244 if (value->GetAsString(&id)) |
| 245 device_local_accounts->set_auto_login_id(id); |
| 246 else |
| 247 NOTREACHED(); |
| 248 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginDelay) { |
| 249 em::DeviceLocalAccountsProto* device_local_accounts = |
| 250 device_settings_.mutable_device_local_accounts(); |
| 251 int delay; |
| 252 if (value->GetAsInteger(&delay)) |
| 253 device_local_accounts->set_auto_login_delay(delay); |
| 254 else |
| 255 NOTREACHED(); |
238 } else if (prop == kSignedDataRoamingEnabled) { | 256 } else if (prop == kSignedDataRoamingEnabled) { |
239 em::DataRoamingEnabledProto* roam = | 257 em::DataRoamingEnabledProto* roam = |
240 device_settings_.mutable_data_roaming_enabled(); | 258 device_settings_.mutable_data_roaming_enabled(); |
241 bool roaming_value = false; | 259 bool roaming_value = false; |
242 if (value->GetAsBoolean(&roaming_value)) | 260 if (value->GetAsBoolean(&roaming_value)) |
243 roam->set_data_roaming_enabled(roaming_value); | 261 roam->set_data_roaming_enabled(roaming_value); |
244 else | 262 else |
245 NOTREACHED(); | 263 NOTREACHED(); |
246 ApplyRoamingSetting(roaming_value); | 264 ApplyRoamingSetting(roaming_value); |
247 } else if (prop == kSettingProxyEverywhere) { | 265 } else if (prop == kSettingProxyEverywhere) { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 whitelist_proto.user_whitelist(); | 422 whitelist_proto.user_whitelist(); |
405 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); | 423 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); |
406 it != whitelist.end(); ++it) { | 424 it != whitelist.end(); ++it) { |
407 list->Append(new base::StringValue(*it)); | 425 list->Append(new base::StringValue(*it)); |
408 } | 426 } |
409 new_values_cache->SetValue(kAccountsPrefUsers, list); | 427 new_values_cache->SetValue(kAccountsPrefUsers, list); |
410 | 428 |
411 base::ListValue* account_list = new base::ListValue(); | 429 base::ListValue* account_list = new base::ListValue(); |
412 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 430 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
413 if (!command_line->HasSwitch(switches::kDisableLocalAccounts)) { | 431 if (!command_line->HasSwitch(switches::kDisableLocalAccounts)) { |
| 432 const em::DeviceLocalAccountsProto device_local_accounts_proto = |
| 433 policy.device_local_accounts(); |
414 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = | 434 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = |
415 policy.device_local_accounts().account(); | 435 device_local_accounts_proto.account(); |
416 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; | 436 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; |
417 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { | 437 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { |
418 if (entry->has_id()) | 438 if (entry->has_id()) |
419 account_list->AppendString(entry->id()); | 439 account_list->AppendString(entry->id()); |
420 } | 440 } |
421 } | 441 } |
422 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list); | 442 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list); |
423 | 443 |
424 if (policy.has_start_up_flags()) { | 444 if (policy.has_start_up_flags()) { |
425 base::ListValue* list = new base::ListValue(); | 445 base::ListValue* list = new base::ListValue(); |
426 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags(); | 446 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags(); |
427 const RepeatedPtrField<std::string>& flags = flags_proto.flags(); | 447 const RepeatedPtrField<std::string>& flags = flags_proto.flags(); |
428 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin(); | 448 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin(); |
429 it != flags.end(); ++it) { | 449 it != flags.end(); ++it) { |
430 list->Append(new base::StringValue(*it)); | 450 list->Append(new base::StringValue(*it)); |
431 } | 451 } |
432 new_values_cache->SetValue(kStartUpFlags, list); | 452 new_values_cache->SetValue(kStartUpFlags, list); |
433 } | 453 } |
| 454 |
| 455 if (policy.has_device_local_accounts()) { |
| 456 if (policy.device_local_accounts().has_auto_login_id()) { |
| 457 new_values_cache->SetString( |
| 458 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 459 policy.device_local_accounts().auto_login_id()); |
| 460 } |
| 461 if (policy.device_local_accounts().has_auto_login_delay()) { |
| 462 new_values_cache->SetInteger( |
| 463 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
| 464 policy.device_local_accounts().auto_login_delay()); |
| 465 } |
| 466 } |
434 } | 467 } |
435 | 468 |
436 void DeviceSettingsProvider::DecodeKioskPolicies( | 469 void DeviceSettingsProvider::DecodeKioskPolicies( |
437 const em::ChromeDeviceSettingsProto& policy, | 470 const em::ChromeDeviceSettingsProto& policy, |
438 PrefValueMap* new_values_cache) const { | 471 PrefValueMap* new_values_cache) const { |
439 if (policy.has_forced_logout_timeouts()) { | 472 if (policy.has_forced_logout_timeouts()) { |
440 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { | 473 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { |
441 new_values_cache->SetInteger( | 474 new_values_cache->SetInteger( |
442 kIdleLogoutTimeout, | 475 kIdleLogoutTimeout, |
443 policy.forced_logout_timeouts().idle_logout_timeout()); | 476 policy.forced_logout_timeouts().idle_logout_timeout()); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 void DeviceSettingsProvider::AttemptMigration() { | 853 void DeviceSettingsProvider::AttemptMigration() { |
821 if (device_settings_service_->HasPrivateOwnerKey()) { | 854 if (device_settings_service_->HasPrivateOwnerKey()) { |
822 PrefValueMap::const_iterator i; | 855 PrefValueMap::const_iterator i; |
823 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 856 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
824 DoSet(i->first, *i->second); | 857 DoSet(i->first, *i->second); |
825 migration_values_.Clear(); | 858 migration_values_.Clear(); |
826 } | 859 } |
827 } | 860 } |
828 | 861 |
829 } // namespace chromeos | 862 } // namespace chromeos |
OLD | NEW |