Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/chromeos/device_settings_provider.cc

Issue 9289017: Apply individual policies for the various parts of device status reports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Julian's comments. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {
287 // kReportDeviceVersionInfo, kReportDeviceActivityTimes, and
288 // kReportDeviceBootMode do not support being set in the policy, since
289 // they are not intended to be user-controlled.
284 NOTREACHED(); 290 NOTREACHED();
285 } 291 }
286 data.set_policy_value(pol.SerializeAsString()); 292 data.set_policy_value(pol.SerializeAsString());
287 // Set the cache to the updated value. 293 // Set the cache to the updated value.
288 policy_ = data; 294 policy_ = data;
289 UpdateValuesCache(); 295 UpdateValuesCache();
290 296
291 if (!signed_settings_cache::Store(data, g_browser_process->local_state())) 297 if (!signed_settings_cache::Store(data, g_browser_process->local_state()))
292 LOG(ERROR) << "Couldn't store to the temp storage."; 298 LOG(ERROR) << "Couldn't store to the temp storage.";
293 299
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 base::ListValue* list = new base::ListValue(); 402 base::ListValue* list = new base::ListValue();
397 const em::UserWhitelistProto& whitelist_proto = pol.user_whitelist(); 403 const em::UserWhitelistProto& whitelist_proto = pol.user_whitelist();
398 const RepeatedPtrField<std::string>& whitelist = 404 const RepeatedPtrField<std::string>& whitelist =
399 whitelist_proto.user_whitelist(); 405 whitelist_proto.user_whitelist();
400 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); 406 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin();
401 it != whitelist.end(); ++it) { 407 it != whitelist.end(); ++it) {
402 list->Append(base::Value::CreateStringValue(*it)); 408 list->Append(base::Value::CreateStringValue(*it));
403 } 409 }
404 new_values_cache.SetValue(kAccountsPrefUsers, list); 410 new_values_cache.SetValue(kAccountsPrefUsers, list);
405 411
412 if (pol.has_device_reporting()) {
413 if (pol.device_reporting().has_report_version_info()) {
414 new_values_cache.SetBoolean(kReportDeviceVersionInfo,
415 pol.device_reporting().report_version_info());
416 }
417 if (pol.device_reporting().has_report_activity_times()) {
418 new_values_cache.SetBoolean(kReportDeviceActivityTimes,
419 pol.device_reporting().report_activity_times());
420 }
421 if (pol.device_reporting().has_report_boot_mode()) {
422 new_values_cache.SetBoolean(kReportDeviceBootMode,
423 pol.device_reporting().report_boot_mode());
424 }
425 }
426
406 // Collect all notifications but send them only after we have swapped the 427 // 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. 428 // cache so that if somebody actually reads the cache will be already valid.
408 std::vector<std::string> notifications; 429 std::vector<std::string> notifications;
409 // Go through the new values and verify in the old ones. 430 // Go through the new values and verify in the old ones.
410 PrefValueMap::iterator iter = new_values_cache.begin(); 431 PrefValueMap::iterator iter = new_values_cache.begin();
411 for (; iter != new_values_cache.end(); ++iter) { 432 for (; iter != new_values_cache.end(); ++iter) {
412 const base::Value* old_value; 433 const base::Value* old_value;
413 if (!values_cache_.GetValue(iter->first, &old_value) || 434 if (!values_cache_.GetValue(iter->first, &old_value) ||
414 !old_value->Equals(iter->second)) { 435 !old_value->Equals(iter->second)) {
415 notifications.push_back(iter->first); 436 notifications.push_back(iter->first);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 Reload(); 628 Reload();
608 return; 629 return;
609 } 630 }
610 LOG(ERROR) << "No retries left"; 631 LOG(ERROR) << "No retries left";
611 break; 632 break;
612 } 633 }
613 } 634 }
614 } 635 }
615 636
616 } // namespace chromeos 637 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros_settings_provider.cc ('k') | chrome/browser/chromeos/stub_cros_settings_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698