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/device_settings_provider.h" | 5 #include "chrome/browser/chromeos/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 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 namespace chromeos { | 35 namespace chromeos { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 const char* kBooleanSettings[] = { | 39 const char* kBooleanSettings[] = { |
40 kAccountsPrefAllowNewUser, | 40 kAccountsPrefAllowNewUser, |
41 kAccountsPrefAllowGuest, | 41 kAccountsPrefAllowGuest, |
42 kAccountsPrefShowUserNamesOnSignIn, | 42 kAccountsPrefShowUserNamesOnSignIn, |
43 kSignedDataRoamingEnabled, | 43 kSignedDataRoamingEnabled, |
44 kStatsReportingPref | 44 kStatsReportingPref, |
45 kReportDeviceVersionInfo, | |
46 kReportDeviceActivityTimes, | |
47 kReportDeviceBootMode | |
45 }; | 48 }; |
46 | 49 |
47 const char* kStringSettings[] = { | 50 const char* kStringSettings[] = { |
48 kDeviceOwner, | 51 kDeviceOwner, |
49 kReleaseChannel, | 52 kReleaseChannel, |
50 kSettingProxyEverywhere | 53 kSettingProxyEverywhere |
51 }; | 54 }; |
52 | 55 |
53 const char* kListSettings[] = { | 56 const char* kListSettings[] = { |
54 kAccountsPrefUsers | 57 kAccountsPrefUsers |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 } else if (prop == kAccountsPrefUsers) { | 276 } else if (prop == kAccountsPrefUsers) { |
274 em::UserWhitelistProto* whitelist_proto = pol.mutable_user_whitelist(); | 277 em::UserWhitelistProto* whitelist_proto = pol.mutable_user_whitelist(); |
275 whitelist_proto->clear_user_whitelist(); | 278 whitelist_proto->clear_user_whitelist(); |
276 base::ListValue& users = static_cast<base::ListValue&>(*value); | 279 base::ListValue& users = static_cast<base::ListValue&>(*value); |
277 for (base::ListValue::const_iterator i = users.begin(); | 280 for (base::ListValue::const_iterator i = users.begin(); |
278 i != users.end(); ++i) { | 281 i != users.end(); ++i) { |
279 std::string email; | 282 std::string email; |
280 if ((*i)->GetAsString(&email)) | 283 if ((*i)->GetAsString(&email)) |
281 whitelist_proto->add_user_whitelist(email.c_str()); | 284 whitelist_proto->add_user_whitelist(email.c_str()); |
282 } | 285 } |
283 } else { | 286 } else { |
pastarmovj
2012/01/27 15:39:03
Please put a TODO here at least that those three p
Patrick Dubroy
2012/01/27 16:18:12
Done.
| |
284 NOTREACHED(); | 287 NOTREACHED(); |
285 } | 288 } |
286 data.set_policy_value(pol.SerializeAsString()); | 289 data.set_policy_value(pol.SerializeAsString()); |
287 // Set the cache to the updated value. | 290 // Set the cache to the updated value. |
288 policy_ = data; | 291 policy_ = data; |
289 UpdateValuesCache(); | 292 UpdateValuesCache(); |
290 | 293 |
291 if (!signed_settings_cache::Store(data, g_browser_process->local_state())) | 294 if (!signed_settings_cache::Store(data, g_browser_process->local_state())) |
292 LOG(ERROR) << "Couldn't store to the temp storage."; | 295 LOG(ERROR) << "Couldn't store to the temp storage."; |
293 | 296 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 base::ListValue* list = new base::ListValue(); | 399 base::ListValue* list = new base::ListValue(); |
397 const em::UserWhitelistProto& whitelist_proto = pol.user_whitelist(); | 400 const em::UserWhitelistProto& whitelist_proto = pol.user_whitelist(); |
398 const RepeatedPtrField<std::string>& whitelist = | 401 const RepeatedPtrField<std::string>& whitelist = |
399 whitelist_proto.user_whitelist(); | 402 whitelist_proto.user_whitelist(); |
400 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); | 403 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); |
401 it != whitelist.end(); ++it) { | 404 it != whitelist.end(); ++it) { |
402 list->Append(base::Value::CreateStringValue(*it)); | 405 list->Append(base::Value::CreateStringValue(*it)); |
403 } | 406 } |
404 new_values_cache.SetValue(kAccountsPrefUsers, list); | 407 new_values_cache.SetValue(kAccountsPrefUsers, list); |
405 | 408 |
409 if (pol.has_device_reporting()) { | |
410 if (pol.device_reporting().has_report_version_info()) { | |
411 new_values_cache.SetBoolean(kReportDeviceVersionInfo, | |
412 pol.device_reporting().report_version_info()); | |
413 } | |
414 if (pol.device_reporting().has_report_activity_times()) { | |
415 new_values_cache.SetBoolean(kReportDeviceActivityTimes, | |
416 pol.device_reporting().report_activity_times()); | |
417 } | |
418 if (pol.device_reporting().has_report_boot_mode()) { | |
419 new_values_cache.SetBoolean(kReportDeviceBootMode, | |
420 pol.device_reporting().report_boot_mode()); | |
421 } | |
422 } | |
423 | |
406 // Collect all notifications but send them only after we have swapped the | 424 // Collect all notifications but send them only after we have swapped the |
407 // cache so that if somebody actually reads the cache will be already valid. | 425 // cache so that if somebody actually reads the cache will be already valid. |
408 std::vector<std::string> notifications; | 426 std::vector<std::string> notifications; |
409 // Go through the new values and verify in the old ones. | 427 // Go through the new values and verify in the old ones. |
410 PrefValueMap::iterator iter = new_values_cache.begin(); | 428 PrefValueMap::iterator iter = new_values_cache.begin(); |
411 for (; iter != new_values_cache.end(); ++iter) { | 429 for (; iter != new_values_cache.end(); ++iter) { |
412 const base::Value* old_value; | 430 const base::Value* old_value; |
413 if (!values_cache_.GetValue(iter->first, &old_value) || | 431 if (!values_cache_.GetValue(iter->first, &old_value) || |
414 !old_value->Equals(iter->second)) { | 432 !old_value->Equals(iter->second)) { |
415 notifications.push_back(iter->first); | 433 notifications.push_back(iter->first); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 Reload(); | 625 Reload(); |
608 return; | 626 return; |
609 } | 627 } |
610 LOG(ERROR) << "No retries left"; | 628 LOG(ERROR) << "No retries left"; |
611 break; | 629 break; |
612 } | 630 } |
613 } | 631 } |
614 } | 632 } |
615 | 633 |
616 } // namespace chromeos | 634 } // namespace chromeos |
OLD | NEW |