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 25 matching lines...) Expand all Loading... | |
36 | 36 |
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 kAllowRedeemChromeOsRegistrationOffers, | |
bartfab (slow)
2013/02/25 16:51:23
The list seems to have been ordered alphabetically
dconnelly
2013/02/26 18:04:15
Done.
| |
46 kAccountsPrefDeviceLocalAccounts, | 47 kAccountsPrefDeviceLocalAccounts, |
47 kAllowRedeemChromeOsRegistrationOffers, | 48 kAccountsPrefDeviceLocalAccountAutoLoginId, |
49 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
48 kAppPack, | 50 kAppPack, |
49 kDeviceOwner, | 51 kDeviceOwner, |
50 kIdleLogoutTimeout, | 52 kIdleLogoutTimeout, |
51 kIdleLogoutWarningDuration, | 53 kIdleLogoutWarningDuration, |
52 kPolicyMissingMitigationMode, | 54 kPolicyMissingMitigationMode, |
53 kReleaseChannel, | 55 kReleaseChannel, |
54 kReleaseChannelDelegated, | 56 kReleaseChannelDelegated, |
55 kReportDeviceActivityTimes, | 57 kReportDeviceActivityTimes, |
56 kReportDeviceBootMode, | 58 kReportDeviceBootMode, |
57 kReportDeviceLocation, | 59 kReportDeviceLocation, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 entry != accounts_list->end(); ++entry) { | 228 entry != accounts_list->end(); ++entry) { |
227 std::string id; | 229 std::string id; |
228 if ((*entry)->GetAsString(&id)) | 230 if ((*entry)->GetAsString(&id)) |
229 device_local_accounts->add_account()->set_id(id); | 231 device_local_accounts->add_account()->set_id(id); |
230 else | 232 else |
231 NOTREACHED(); | 233 NOTREACHED(); |
232 } | 234 } |
233 } else { | 235 } else { |
234 NOTREACHED(); | 236 NOTREACHED(); |
235 } | 237 } |
238 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginId) { | |
239 em::DeviceLocalAccountsProto* device_local_accounts = | |
240 device_settings_.mutable_device_local_accounts(); | |
241 std::string id; | |
242 if (value->GetAsString(&id)) | |
243 device_local_accounts->set_auto_login_id(id); | |
244 else | |
245 NOTREACHED(); | |
246 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginDelay) { | |
247 em::DeviceLocalAccountsProto* device_local_accounts = | |
248 device_settings_.mutable_device_local_accounts(); | |
249 int timer; | |
bartfab (slow)
2013/02/25 16:51:23
This should be called |delay|, not |timer|.
dconnelly
2013/02/26 18:04:15
Done.
| |
250 if (value->GetAsInteger(&timer)) | |
251 device_local_accounts->set_auto_login_delay(timer); | |
252 else | |
253 NOTREACHED(); | |
236 } else if (prop == kSignedDataRoamingEnabled) { | 254 } else if (prop == kSignedDataRoamingEnabled) { |
237 em::DataRoamingEnabledProto* roam = | 255 em::DataRoamingEnabledProto* roam = |
238 device_settings_.mutable_data_roaming_enabled(); | 256 device_settings_.mutable_data_roaming_enabled(); |
239 bool roaming_value = false; | 257 bool roaming_value = false; |
240 if (value->GetAsBoolean(&roaming_value)) | 258 if (value->GetAsBoolean(&roaming_value)) |
241 roam->set_data_roaming_enabled(roaming_value); | 259 roam->set_data_roaming_enabled(roaming_value); |
242 else | 260 else |
243 NOTREACHED(); | 261 NOTREACHED(); |
244 ApplyRoamingSetting(roaming_value); | 262 ApplyRoamingSetting(roaming_value); |
245 } else if (prop == kSettingProxyEverywhere) { | 263 } else if (prop == kSettingProxyEverywhere) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 whitelist_proto.user_whitelist(); | 408 whitelist_proto.user_whitelist(); |
391 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); | 409 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); |
392 it != whitelist.end(); ++it) { | 410 it != whitelist.end(); ++it) { |
393 list->Append(new base::StringValue(*it)); | 411 list->Append(new base::StringValue(*it)); |
394 } | 412 } |
395 new_values_cache->SetValue(kAccountsPrefUsers, list); | 413 new_values_cache->SetValue(kAccountsPrefUsers, list); |
396 | 414 |
397 base::ListValue* account_list = new base::ListValue(); | 415 base::ListValue* account_list = new base::ListValue(); |
398 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 416 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
399 if (!command_line->HasSwitch(switches::kDisableLocalAccounts)) { | 417 if (!command_line->HasSwitch(switches::kDisableLocalAccounts)) { |
418 const em::DeviceLocalAccountsProto device_local_accounts_proto = | |
419 policy.device_local_accounts(); | |
400 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = | 420 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = |
401 policy.device_local_accounts().account(); | 421 device_local_accounts_proto.account(); |
402 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; | 422 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; |
403 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { | 423 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { |
404 if (entry->has_id()) | 424 if (entry->has_id()) |
405 account_list->AppendString(entry->id()); | 425 account_list->AppendString(entry->id()); |
406 } | 426 } |
427 if (device_local_accounts_proto.has_auto_login_id()) { | |
428 new_values_cache->SetString( | |
429 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
430 device_local_accounts_proto.auto_login_id()); | |
431 } | |
432 if (device_local_accounts_proto.has_auto_login_delay()) { | |
433 new_values_cache->SetInteger( | |
434 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
435 device_local_accounts_proto.auto_login_delay()); | |
436 } | |
407 } | 437 } |
408 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list); | 438 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list); |
409 } | 439 } |
410 | 440 |
411 void DeviceSettingsProvider::DecodeKioskPolicies( | 441 void DeviceSettingsProvider::DecodeKioskPolicies( |
412 const em::ChromeDeviceSettingsProto& policy, | 442 const em::ChromeDeviceSettingsProto& policy, |
413 PrefValueMap* new_values_cache) const { | 443 PrefValueMap* new_values_cache) const { |
414 if (policy.has_forced_logout_timeouts()) { | 444 if (policy.has_forced_logout_timeouts()) { |
415 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { | 445 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { |
416 new_values_cache->SetInteger( | 446 new_values_cache->SetInteger( |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
794 void DeviceSettingsProvider::AttemptMigration() { | 824 void DeviceSettingsProvider::AttemptMigration() { |
795 if (device_settings_service_->HasPrivateOwnerKey()) { | 825 if (device_settings_service_->HasPrivateOwnerKey()) { |
796 PrefValueMap::const_iterator i; | 826 PrefValueMap::const_iterator i; |
797 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 827 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
798 DoSet(i->first, *i->second); | 828 DoSet(i->first, *i->second); |
799 migration_values_.Clear(); | 829 migration_values_.Clear(); |
800 } | 830 } |
801 } | 831 } |
802 | 832 |
803 } // namespace chromeos | 833 } // namespace chromeos |
OLD | NEW |