Chromium Code Reviews| 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 kAccountsPrefLocalAccounts, | |
| 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 == kAccountsPrefLocalAccounts) { | |
| 216 em::LocalAccountsProto * local_accounts = | |
|
pastarmovj
2012/11/06 12:42:15
one space too much.
Mattias Nissler (ping if slow)
2012/11/12 15:50:51
Done.
| |
| 217 device_settings_.mutable_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 base::DictionaryValue* entry_dict; | |
| 223 std::string id; | |
| 224 std::string name; | |
| 225 if (!(*entry)->GetAsDictionary(&entry_dict) || | |
|
pastarmovj
2012/11/06 12:42:15
Isn't the logic inverted here?
If not read then se
Mattias Nissler (ping if slow)
2012/11/12 15:50:51
Done.
| |
| 226 !entry_dict->GetString(kLocalAccountId, &id) || | |
| 227 !entry_dict->GetString(kLocalAccountName, &name)) { | |
| 228 em::LocalAccountDefinitionProto* proto_entry = | |
| 229 local_accounts->add_local_account(); | |
| 230 proto_entry->set_id(id); | |
| 231 proto_entry->set_name(name); | |
| 232 } else { | |
| 233 NOTREACHED(); | |
| 234 } | |
| 235 } | |
| 236 } else { | |
| 237 NOTREACHED(); | |
| 238 } | |
| 214 } else if (prop == kSignedDataRoamingEnabled) { | 239 } else if (prop == kSignedDataRoamingEnabled) { |
| 215 em::DataRoamingEnabledProto* roam = | 240 em::DataRoamingEnabledProto* roam = |
| 216 device_settings_.mutable_data_roaming_enabled(); | 241 device_settings_.mutable_data_roaming_enabled(); |
| 217 bool roaming_value = false; | 242 bool roaming_value = false; |
| 218 if (value->GetAsBoolean(&roaming_value)) | 243 if (value->GetAsBoolean(&roaming_value)) |
| 219 roam->set_data_roaming_enabled(roaming_value); | 244 roam->set_data_roaming_enabled(roaming_value); |
| 220 else | 245 else |
| 221 NOTREACHED(); | 246 NOTREACHED(); |
| 222 ApplyRoamingSetting(roaming_value); | 247 ApplyRoamingSetting(roaming_value); |
| 223 } else if (prop == kSettingProxyEverywhere) { | 248 } else if (prop == kSettingProxyEverywhere) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 | 379 |
| 355 base::ListValue* list = new base::ListValue(); | 380 base::ListValue* list = new base::ListValue(); |
| 356 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist(); | 381 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist(); |
| 357 const RepeatedPtrField<std::string>& whitelist = | 382 const RepeatedPtrField<std::string>& whitelist = |
| 358 whitelist_proto.user_whitelist(); | 383 whitelist_proto.user_whitelist(); |
| 359 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); | 384 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); |
| 360 it != whitelist.end(); ++it) { | 385 it != whitelist.end(); ++it) { |
| 361 list->Append(base::Value::CreateStringValue(*it)); | 386 list->Append(base::Value::CreateStringValue(*it)); |
| 362 } | 387 } |
| 363 new_values_cache->SetValue(kAccountsPrefUsers, list); | 388 new_values_cache->SetValue(kAccountsPrefUsers, list); |
| 389 | |
| 390 base::ListValue* account_list = new base::ListValue(); | |
| 391 const RepeatedPtrField<em::LocalAccountDefinitionProto>& local_accounts = | |
| 392 policy.local_accounts().local_account(); | |
| 393 RepeatedPtrField<em::LocalAccountDefinitionProto>::const_iterator entry; | |
| 394 for (entry = local_accounts.begin(); entry != local_accounts.end(); ++entry) { | |
| 395 if (entry->has_id() && entry->has_name()) { | |
| 396 base::DictionaryValue* account_dict = new base::DictionaryValue(); | |
| 397 account_dict->SetString(kLocalAccountId, entry->id()); | |
| 398 account_dict->SetString(kLocalAccountName, entry->name()); | |
| 399 account_list->Append(account_dict); | |
| 400 } | |
| 401 } | |
| 402 new_values_cache->SetValue(kAccountsPrefLocalAccounts, account_list); | |
| 364 } | 403 } |
| 365 | 404 |
| 366 void DeviceSettingsProvider::DecodeKioskPolicies( | 405 void DeviceSettingsProvider::DecodeKioskPolicies( |
| 367 const em::ChromeDeviceSettingsProto& policy, | 406 const em::ChromeDeviceSettingsProto& policy, |
| 368 PrefValueMap* new_values_cache) const { | 407 PrefValueMap* new_values_cache) const { |
| 369 if (policy.has_forced_logout_timeouts()) { | 408 if (policy.has_forced_logout_timeouts()) { |
| 370 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { | 409 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { |
| 371 new_values_cache->SetInteger( | 410 new_values_cache->SetInteger( |
| 372 kIdleLogoutTimeout, | 411 kIdleLogoutTimeout, |
| 373 policy.forced_logout_timeouts().idle_logout_timeout()); | 412 policy.forced_logout_timeouts().idle_logout_timeout()); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 735 void DeviceSettingsProvider::AttemptMigration() { | 774 void DeviceSettingsProvider::AttemptMigration() { |
| 736 if (device_settings_service_->HasPrivateOwnerKey()) { | 775 if (device_settings_service_->HasPrivateOwnerKey()) { |
| 737 PrefValueMap::const_iterator i; | 776 PrefValueMap::const_iterator i; |
| 738 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 777 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
| 739 DoSet(i->first, *i->second); | 778 DoSet(i->first, *i->second); |
| 740 migration_values_.Clear(); | 779 migration_values_.Clear(); |
| 741 } | 780 } |
| 742 } | 781 } |
| 743 | 782 |
| 744 } // namespace chromeos | 783 } // namespace chromeos |
| OLD | NEW |