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 26 matching lines...) Expand all Loading... |
37 namespace { | 37 namespace { |
38 | 38 |
39 // List of settings handled by the DeviceSettingsProvider. | 39 // List of settings handled by the DeviceSettingsProvider. |
40 const char* kKnownSettings[] = { | 40 const char* kKnownSettings[] = { |
41 kAccountsPrefAllowGuest, | 41 kAccountsPrefAllowGuest, |
42 kAccountsPrefAllowNewUser, | 42 kAccountsPrefAllowNewUser, |
43 kAccountsPrefEphemeralUsersEnabled, | 43 kAccountsPrefEphemeralUsersEnabled, |
44 kAccountsPrefShowUserNamesOnSignIn, | 44 kAccountsPrefShowUserNamesOnSignIn, |
45 kAccountsPrefUsers, | 45 kAccountsPrefUsers, |
46 kAccountsPrefDeviceLocalAccounts, | 46 kAccountsPrefDeviceLocalAccounts, |
| 47 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 48 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
47 kAppPack, | 49 kAppPack, |
48 kDeviceOwner, | 50 kDeviceOwner, |
49 kIdleLogoutTimeout, | 51 kIdleLogoutTimeout, |
50 kIdleLogoutWarningDuration, | 52 kIdleLogoutWarningDuration, |
51 kPolicyMissingMitigationMode, | 53 kPolicyMissingMitigationMode, |
52 kReleaseChannel, | 54 kReleaseChannel, |
53 kReleaseChannelDelegated, | 55 kReleaseChannelDelegated, |
54 kReportDeviceActivityTimes, | 56 kReportDeviceActivityTimes, |
55 kReportDeviceBootMode, | 57 kReportDeviceBootMode, |
56 kReportDeviceLocation, | 58 kReportDeviceLocation, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 entry != accounts_list->end(); ++entry) { | 227 entry != accounts_list->end(); ++entry) { |
226 std::string id; | 228 std::string id; |
227 if ((*entry)->GetAsString(&id)) | 229 if ((*entry)->GetAsString(&id)) |
228 device_local_accounts->add_account()->set_id(id); | 230 device_local_accounts->add_account()->set_id(id); |
229 else | 231 else |
230 NOTREACHED(); | 232 NOTREACHED(); |
231 } | 233 } |
232 } else { | 234 } else { |
233 NOTREACHED(); | 235 NOTREACHED(); |
234 } | 236 } |
| 237 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginId) { |
| 238 em::DeviceLocalAccountsProto* device_local_accounts = |
| 239 device_settings_.mutable_device_local_accounts(); |
| 240 std::string id; |
| 241 if (value->GetAsString(&id)) |
| 242 device_local_accounts->set_auto_login_id(id); |
| 243 else |
| 244 NOTREACHED(); |
| 245 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginDelay) { |
| 246 em::DeviceLocalAccountsProto* device_local_accounts = |
| 247 device_settings_.mutable_device_local_accounts(); |
| 248 int timer; |
| 249 if (value->GetAsInteger(&timer)) |
| 250 device_local_accounts->set_auto_login_delay(timer); |
| 251 else |
| 252 NOTREACHED(); |
235 } else if (prop == kSignedDataRoamingEnabled) { | 253 } else if (prop == kSignedDataRoamingEnabled) { |
236 em::DataRoamingEnabledProto* roam = | 254 em::DataRoamingEnabledProto* roam = |
237 device_settings_.mutable_data_roaming_enabled(); | 255 device_settings_.mutable_data_roaming_enabled(); |
238 bool roaming_value = false; | 256 bool roaming_value = false; |
239 if (value->GetAsBoolean(&roaming_value)) | 257 if (value->GetAsBoolean(&roaming_value)) |
240 roam->set_data_roaming_enabled(roaming_value); | 258 roam->set_data_roaming_enabled(roaming_value); |
241 else | 259 else |
242 NOTREACHED(); | 260 NOTREACHED(); |
243 ApplyRoamingSetting(roaming_value); | 261 ApplyRoamingSetting(roaming_value); |
244 } else if (prop == kSettingProxyEverywhere) { | 262 } else if (prop == kSettingProxyEverywhere) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 whitelist_proto.user_whitelist(); | 397 whitelist_proto.user_whitelist(); |
380 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); | 398 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); |
381 it != whitelist.end(); ++it) { | 399 it != whitelist.end(); ++it) { |
382 list->Append(new base::StringValue(*it)); | 400 list->Append(new base::StringValue(*it)); |
383 } | 401 } |
384 new_values_cache->SetValue(kAccountsPrefUsers, list); | 402 new_values_cache->SetValue(kAccountsPrefUsers, list); |
385 | 403 |
386 base::ListValue* account_list = new base::ListValue(); | 404 base::ListValue* account_list = new base::ListValue(); |
387 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 405 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
388 if (!command_line->HasSwitch(switches::kDisableLocalAccounts)) { | 406 if (!command_line->HasSwitch(switches::kDisableLocalAccounts)) { |
| 407 const em::DeviceLocalAccountsProto device_local_accounts_proto = |
| 408 policy.device_local_accounts(); |
389 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = | 409 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = |
390 policy.device_local_accounts().account(); | 410 device_local_accounts_proto.account(); |
391 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; | 411 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; |
392 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { | 412 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { |
393 if (entry->has_id()) | 413 if (entry->has_id()) |
394 account_list->AppendString(entry->id()); | 414 account_list->AppendString(entry->id()); |
395 } | 415 } |
| 416 if (device_local_accounts_proto.has_auto_login_id()) { |
| 417 new_values_cache->SetString( |
| 418 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 419 device_local_accounts_proto.auto_login_id()); |
| 420 } |
| 421 if (device_local_accounts_proto.has_auto_login_delay()) { |
| 422 new_values_cache->SetInteger( |
| 423 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
| 424 device_local_accounts_proto.auto_login_delay()); |
| 425 } |
396 } | 426 } |
397 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list); | 427 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list); |
398 } | 428 } |
399 | 429 |
400 void DeviceSettingsProvider::DecodeKioskPolicies( | 430 void DeviceSettingsProvider::DecodeKioskPolicies( |
401 const em::ChromeDeviceSettingsProto& policy, | 431 const em::ChromeDeviceSettingsProto& policy, |
402 PrefValueMap* new_values_cache) const { | 432 PrefValueMap* new_values_cache) const { |
403 if (policy.has_forced_logout_timeouts()) { | 433 if (policy.has_forced_logout_timeouts()) { |
404 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { | 434 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { |
405 new_values_cache->SetInteger( | 435 new_values_cache->SetInteger( |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 void DeviceSettingsProvider::AttemptMigration() { | 803 void DeviceSettingsProvider::AttemptMigration() { |
774 if (device_settings_service_->HasPrivateOwnerKey()) { | 804 if (device_settings_service_->HasPrivateOwnerKey()) { |
775 PrefValueMap::const_iterator i; | 805 PrefValueMap::const_iterator i; |
776 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 806 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
777 DoSet(i->first, *i->second); | 807 DoSet(i->first, *i->second); |
778 migration_values_.Clear(); | 808 migration_values_.Clear(); |
779 } | 809 } |
780 } | 810 } |
781 | 811 |
782 } // namespace chromeos | 812 } // namespace chromeos |
OLD | NEW |