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