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

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

Issue 9365078: Rename the ephemeral_users field in the device policy protobuf (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed reference to Chrome OS bug. Created 8 years, 10 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
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 22 matching lines...) Expand all
33 namespace em = enterprise_management; 33 namespace em = enterprise_management;
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 kAccountsPrefEphemeralUsers, 43 kAccountsPrefEphemeralUsersEnabled,
44 kSignedDataRoamingEnabled, 44 kSignedDataRoamingEnabled,
45 kStatsReportingPref, 45 kStatsReportingPref,
46 kReportDeviceVersionInfo, 46 kReportDeviceVersionInfo,
47 kReportDeviceActivityTimes, 47 kReportDeviceActivityTimes,
48 kReportDeviceBootMode 48 kReportDeviceBootMode
49 }; 49 };
50 50
51 const char* kStringSettings[] = { 51 const char* kStringSettings[] = {
52 kDeviceOwner, 52 kDeviceOwner,
53 kReleaseChannel, 53 kReleaseChannel,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } else if (prop == kAccountsPrefUsers) { 277 } else if (prop == kAccountsPrefUsers) {
278 em::UserWhitelistProto* whitelist_proto = pol.mutable_user_whitelist(); 278 em::UserWhitelistProto* whitelist_proto = pol.mutable_user_whitelist();
279 whitelist_proto->clear_user_whitelist(); 279 whitelist_proto->clear_user_whitelist();
280 base::ListValue& users = static_cast<base::ListValue&>(*value); 280 base::ListValue& users = static_cast<base::ListValue&>(*value);
281 for (base::ListValue::const_iterator i = users.begin(); 281 for (base::ListValue::const_iterator i = users.begin();
282 i != users.end(); ++i) { 282 i != users.end(); ++i) {
283 std::string email; 283 std::string email;
284 if ((*i)->GetAsString(&email)) 284 if ((*i)->GetAsString(&email))
285 whitelist_proto->add_user_whitelist(email.c_str()); 285 whitelist_proto->add_user_whitelist(email.c_str());
286 } 286 }
287 } else if (prop == kAccountsPrefEphemeralUsers) { 287 } else if (prop == kAccountsPrefEphemeralUsersEnabled) {
288 em::EphemeralUsersProto* ephemeral_users = pol.mutable_ephemeral_users(); 288 em::EphemeralUsersEnabledProto* ephemeral_users_enabled =
289 bool ephemeral_users_value = false; 289 pol.mutable_ephemeral_users_enabled();
290 if (value->GetAsBoolean(&ephemeral_users_value)) 290 bool ephemeral_users_enabled_value = false;
291 ephemeral_users->set_ephemeral_users(ephemeral_users_value); 291 if (value->GetAsBoolean(&ephemeral_users_enabled_value))
292 ephemeral_users_enabled->set_ephemeral_users_enabled(
293 ephemeral_users_enabled_value);
292 else 294 else
293 NOTREACHED(); 295 NOTREACHED();
294 } else { 296 } else {
295 // kReportDeviceVersionInfo, kReportDeviceActivityTimes, and 297 // kReportDeviceVersionInfo, kReportDeviceActivityTimes, and
296 // kReportDeviceBootMode do not support being set in the policy, since 298 // kReportDeviceBootMode do not support being set in the policy, since
297 // they are not intended to be user-controlled. 299 // they are not intended to be user-controlled.
298 NOTREACHED(); 300 NOTREACHED();
299 } 301 }
300 data.set_policy_value(pol.SerializeAsString()); 302 data.set_policy_value(pol.SerializeAsString());
301 // Set the cache to the updated value. 303 // Set the cache to the updated value.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 if (data.has_username() && !data.has_request_token()) 346 if (data.has_username() && !data.has_request_token())
345 new_values_cache.SetString(kDeviceOwner, data.username()); 347 new_values_cache.SetString(kDeviceOwner, data.username());
346 348
347 em::ChromeDeviceSettingsProto pol; 349 em::ChromeDeviceSettingsProto pol;
348 pol.ParseFromString(data.policy_value()); 350 pol.ParseFromString(data.policy_value());
349 351
350 // For all our boolean settings the following is applicable: 352 // For all our boolean settings the following is applicable:
351 // true is default permissive value and false is safe prohibitive value. 353 // true is default permissive value and false is safe prohibitive value.
352 // Exceptions: 354 // Exceptions:
353 // kSignedDataRoamingEnabled has a default value of false. 355 // kSignedDataRoamingEnabled has a default value of false.
354 // kAccountsPrefEphemeralUsers has a default value of false. 356 // kAccountsPrefEphemeralUsersEnabled has a default value of false.
355 if (pol.has_allow_new_users() && 357 if (pol.has_allow_new_users() &&
356 pol.allow_new_users().has_allow_new_users() && 358 pol.allow_new_users().has_allow_new_users() &&
357 pol.allow_new_users().allow_new_users()) { 359 pol.allow_new_users().allow_new_users()) {
358 // New users allowed, user_whitelist() ignored. 360 // New users allowed, user_whitelist() ignored.
359 new_values_cache.SetBoolean(kAccountsPrefAllowNewUser, true); 361 new_values_cache.SetBoolean(kAccountsPrefAllowNewUser, true);
360 } else if (!pol.has_user_whitelist()) { 362 } else if (!pol.has_user_whitelist()) {
361 // If we have the allow_new_users bool, and it is true, we honor that above. 363 // If we have the allow_new_users bool, and it is true, we honor that above.
362 // In all other cases (don't have it, have it and it is set to false, etc), 364 // In all other cases (don't have it, have it and it is set to false, etc),
363 // We will honor the user_whitelist() if it is there and populated. 365 // We will honor the user_whitelist() if it is there and populated.
364 // Otherwise we default to allowing new users. 366 // Otherwise we default to allowing new users.
(...skipping 16 matching lines...) Expand all
381 !pol.show_user_names().has_show_user_names() || 383 !pol.show_user_names().has_show_user_names() ||
382 pol.show_user_names().show_user_names()); 384 pol.show_user_names().show_user_names());
383 385
384 new_values_cache.SetBoolean( 386 new_values_cache.SetBoolean(
385 kSignedDataRoamingEnabled, 387 kSignedDataRoamingEnabled,
386 pol.has_data_roaming_enabled() && 388 pol.has_data_roaming_enabled() &&
387 pol.data_roaming_enabled().has_data_roaming_enabled() && 389 pol.data_roaming_enabled().has_data_roaming_enabled() &&
388 pol.data_roaming_enabled().data_roaming_enabled()); 390 pol.data_roaming_enabled().data_roaming_enabled());
389 391
390 new_values_cache.SetBoolean( 392 new_values_cache.SetBoolean(
391 kAccountsPrefEphemeralUsers, 393 kAccountsPrefEphemeralUsersEnabled,
392 pol.has_ephemeral_users() && 394 pol.has_ephemeral_users_enabled() &&
393 pol.ephemeral_users().has_ephemeral_users() && 395 pol.ephemeral_users_enabled().has_ephemeral_users_enabled() &&
394 pol.ephemeral_users().ephemeral_users()); 396 pol.ephemeral_users_enabled().ephemeral_users_enabled());
395 397
396 // TODO(cmasone): NOTIMPLEMENTED() once http://crosbug.com/13052 is fixed. 398 // TODO(cmasone): NOTIMPLEMENTED() once http://crosbug.com/13052 is fixed.
397 std::string serialized; 399 std::string serialized;
398 if (pol.has_device_proxy_settings() && 400 if (pol.has_device_proxy_settings() &&
399 pol.device_proxy_settings().SerializeToString(&serialized)) { 401 pol.device_proxy_settings().SerializeToString(&serialized)) {
400 new_values_cache.SetString(kSettingProxyEverywhere, serialized); 402 new_values_cache.SetString(kSettingProxyEverywhere, serialized);
401 } 403 }
402 404
403 if (!pol.has_release_channel() || 405 if (!pol.has_release_channel() ||
404 !pol.release_channel().has_release_channel()) { 406 !pol.release_channel().has_release_channel()) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 Reload(); 645 Reload();
644 return; 646 return;
645 } 647 }
646 LOG(ERROR) << "No retries left"; 648 LOG(ERROR) << "No retries left";
647 break; 649 break;
648 } 650 }
649 } 651 }
650 } 652 }
651 653
652 } // namespace chromeos 654 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros_settings_unittest.cc ('k') | chrome/browser/chromeos/stub_cros_settings_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698