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

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

Issue 12218078: Implement a policy to autologin a public account. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: last upload failed Created 7 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 | 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/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 26 matching lines...) Expand all
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 kAccountsPrefDeviceLocalAccounts, 46 kAccountsPrefDeviceLocalAccounts,
47 kAccountsPrefDeviceLocalAccountAutoLoginId,
48 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
47 kAppPack, 49 kAppPack,
48 kDeviceOwner, 50 kDeviceOwner,
49 kIdleLogoutTimeout, 51 kIdleLogoutTimeout,
50 kIdleLogoutWarningDuration, 52 kIdleLogoutWarningDuration,
51 kPolicyMissingMitigationMode, 53 kPolicyMissingMitigationMode,
52 kReleaseChannel, 54 kReleaseChannel,
53 kReleaseChannelDelegated, 55 kReleaseChannelDelegated,
54 kReportDeviceActivityTimes, 56 kReportDeviceActivityTimes,
55 kReportDeviceBootMode, 57 kReportDeviceBootMode,
56 kReportDeviceLocation, 58 kReportDeviceLocation,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 entry != accounts_list->end(); ++entry) { 227 entry != accounts_list->end(); ++entry) {
226 std::string id; 228 std::string id;
227 if ((*entry)->GetAsString(&id)) 229 if ((*entry)->GetAsString(&id))
228 device_local_accounts->add_account()->set_id(id); 230 device_local_accounts->add_account()->set_id(id);
229 else 231 else
230 NOTREACHED(); 232 NOTREACHED();
231 } 233 }
232 } else { 234 } else {
233 NOTREACHED(); 235 NOTREACHED();
234 } 236 }
237 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginId) {
238 em::DeviceLocalAccountAutoLoginProto* auto_login =
239 device_settings_.mutable_device_local_account_auto_login();
240 std::string id;
241 if (value->GetAsString(&id))
242 auto_login->set_id(id);
243 else
244 NOTREACHED();
245 } else if (prop == kAccountsPrefDeviceLocalAccountAutoLoginDelay) {
246 em::DeviceLocalAccountAutoLoginProto* auto_login =
247 device_settings_.mutable_device_local_account_auto_login();
248 int timer;
249 if (value->GetAsInteger(&timer))
250 auto_login->set_delay(timer);
251 else
252 NOTREACHED();
235 } else if (prop == kSignedDataRoamingEnabled) { 253 } else if (prop == kSignedDataRoamingEnabled) {
236 em::DataRoamingEnabledProto* roam = 254 em::DataRoamingEnabledProto* roam =
237 device_settings_.mutable_data_roaming_enabled(); 255 device_settings_.mutable_data_roaming_enabled();
238 bool roaming_value = false; 256 bool roaming_value = false;
239 if (value->GetAsBoolean(&roaming_value)) 257 if (value->GetAsBoolean(&roaming_value))
240 roam->set_data_roaming_enabled(roaming_value); 258 roam->set_data_roaming_enabled(roaming_value);
241 else 259 else
242 NOTREACHED(); 260 NOTREACHED();
243 ApplyRoamingSetting(roaming_value); 261 ApplyRoamingSetting(roaming_value);
244 } else if (prop == kSettingProxyEverywhere) { 262 } else if (prop == kSettingProxyEverywhere) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 if (!command_line->HasSwitch(switches::kDisableLocalAccounts)) { 406 if (!command_line->HasSwitch(switches::kDisableLocalAccounts)) {
389 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = 407 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts =
390 policy.device_local_accounts().account(); 408 policy.device_local_accounts().account();
391 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; 409 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry;
392 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { 410 for (entry = accounts.begin(); entry != accounts.end(); ++entry) {
393 if (entry->has_id()) 411 if (entry->has_id())
394 account_list->AppendString(entry->id()); 412 account_list->AppendString(entry->id());
395 } 413 }
396 } 414 }
397 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list); 415 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, account_list);
416
417 if (policy.has_device_local_account_auto_login()) {
418 if (policy.device_local_account_auto_login().has_id()) {
419 new_values_cache->SetString(
420 kAccountsPrefDeviceLocalAccountAutoLoginId,
421 policy.device_local_account_auto_login().id());
422 }
423 if (policy.device_local_account_auto_login().has_delay()) {
424 new_values_cache->SetInteger(
425 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
426 policy.device_local_account_auto_login().delay());
427 }
428 }
398 } 429 }
399 430
400 void DeviceSettingsProvider::DecodeKioskPolicies( 431 void DeviceSettingsProvider::DecodeKioskPolicies(
401 const em::ChromeDeviceSettingsProto& policy, 432 const em::ChromeDeviceSettingsProto& policy,
402 PrefValueMap* new_values_cache) const { 433 PrefValueMap* new_values_cache) const {
403 if (policy.has_forced_logout_timeouts()) { 434 if (policy.has_forced_logout_timeouts()) {
404 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { 435 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) {
405 new_values_cache->SetInteger( 436 new_values_cache->SetInteger(
406 kIdleLogoutTimeout, 437 kIdleLogoutTimeout,
407 policy.forced_logout_timeouts().idle_logout_timeout()); 438 policy.forced_logout_timeouts().idle_logout_timeout());
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 void DeviceSettingsProvider::AttemptMigration() { 804 void DeviceSettingsProvider::AttemptMigration() {
774 if (device_settings_service_->HasPrivateOwnerKey()) { 805 if (device_settings_service_->HasPrivateOwnerKey()) {
775 PrefValueMap::const_iterator i; 806 PrefValueMap::const_iterator i;
776 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) 807 for (i = migration_values_.begin(); i != migration_values_.end(); ++i)
777 DoSet(i->first, *i->second); 808 DoSet(i->first, *i->second);
778 migration_values_.Clear(); 809 migration_values_.Clear();
779 } 810 }
780 } 811 }
781 812
782 } // namespace chromeos 813 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698