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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 26 matching lines...) Expand all Loading... |
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 kAllowRedeemChromeOsRegistrationOffers, |
47 kAppPack, | 48 kAppPack, |
48 kDeviceOwner, | 49 kDeviceOwner, |
49 kIdleLogoutTimeout, | 50 kIdleLogoutTimeout, |
50 kIdleLogoutWarningDuration, | 51 kIdleLogoutWarningDuration, |
51 kPolicyMissingMitigationMode, | 52 kPolicyMissingMitigationMode, |
52 kReleaseChannel, | 53 kReleaseChannel, |
53 kReleaseChannelDelegated, | 54 kReleaseChannelDelegated, |
54 kReportDeviceActivityTimes, | 55 kReportDeviceActivityTimes, |
55 kReportDeviceBootMode, | 56 kReportDeviceBootMode, |
56 kReportDeviceLocation, | 57 kReportDeviceLocation, |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } else if (prop == kAccountsPrefEphemeralUsersEnabled) { | 284 } else if (prop == kAccountsPrefEphemeralUsersEnabled) { |
284 em::EphemeralUsersEnabledProto* ephemeral_users_enabled = | 285 em::EphemeralUsersEnabledProto* ephemeral_users_enabled = |
285 device_settings_.mutable_ephemeral_users_enabled(); | 286 device_settings_.mutable_ephemeral_users_enabled(); |
286 bool ephemeral_users_enabled_value = false; | 287 bool ephemeral_users_enabled_value = false; |
287 if (value->GetAsBoolean(&ephemeral_users_enabled_value)) { | 288 if (value->GetAsBoolean(&ephemeral_users_enabled_value)) { |
288 ephemeral_users_enabled->set_ephemeral_users_enabled( | 289 ephemeral_users_enabled->set_ephemeral_users_enabled( |
289 ephemeral_users_enabled_value); | 290 ephemeral_users_enabled_value); |
290 } else { | 291 } else { |
291 NOTREACHED(); | 292 NOTREACHED(); |
292 } | 293 } |
| 294 } else if (prop == kAllowRedeemChromeOsRegistrationOffers) { |
| 295 em::AllowRedeemChromeOsRegistrationOffersProto* allow_redeem_offers = |
| 296 device_settings_.mutable_allow_redeem_offers(); |
| 297 bool allow_redeem_offers_value = true; |
| 298 if (value->GetAsBoolean(&allow_redeem_offers_value)) { |
| 299 allow_redeem_offers->set_allow_redeem_offers( |
| 300 allow_redeem_offers_value); |
| 301 } else { |
| 302 NOTREACHED(); |
| 303 } |
293 } else { | 304 } else { |
294 // The remaining settings don't support Set(), since they are not | 305 // The remaining settings don't support Set(), since they are not |
295 // intended to be customizable by the user: | 306 // intended to be customizable by the user: |
296 // kAppPack | 307 // kAppPack |
297 // kDeviceOwner | 308 // kDeviceOwner |
298 // kIdleLogoutTimeout | 309 // kIdleLogoutTimeout |
299 // kIdleLogoutWarningDuration | 310 // kIdleLogoutWarningDuration |
300 // kReleaseChannelDelegated | 311 // kReleaseChannelDelegated |
301 // kReportDeviceVersionInfo | 312 // kReportDeviceVersionInfo |
302 // kReportDeviceActivityTimes | 313 // kReportDeviceActivityTimes |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 policy.release_channel().has_release_channel_delegated() && | 540 policy.release_channel().has_release_channel_delegated() && |
530 policy.release_channel().release_channel_delegated()); | 541 policy.release_channel().release_channel_delegated()); |
531 | 542 |
532 if (policy.has_system_timezone()) { | 543 if (policy.has_system_timezone()) { |
533 if (policy.system_timezone().has_timezone()) { | 544 if (policy.system_timezone().has_timezone()) { |
534 new_values_cache->SetString( | 545 new_values_cache->SetString( |
535 kSystemTimezonePolicy, | 546 kSystemTimezonePolicy, |
536 policy.system_timezone().timezone()); | 547 policy.system_timezone().timezone()); |
537 } | 548 } |
538 } | 549 } |
| 550 |
| 551 if (policy.has_allow_redeem_offers()) { |
| 552 new_values_cache->SetBoolean( |
| 553 kAllowRedeemChromeOsRegistrationOffers, |
| 554 policy.allow_redeem_offers().allow_redeem_offers()); |
| 555 } else { |
| 556 new_values_cache->SetBoolean( |
| 557 kAllowRedeemChromeOsRegistrationOffers, |
| 558 true); |
| 559 } |
539 } | 560 } |
540 | 561 |
541 void DeviceSettingsProvider::UpdateValuesCache( | 562 void DeviceSettingsProvider::UpdateValuesCache( |
542 const em::PolicyData& policy_data, | 563 const em::PolicyData& policy_data, |
543 const em::ChromeDeviceSettingsProto& settings, | 564 const em::ChromeDeviceSettingsProto& settings, |
544 TrustedStatus trusted_status) { | 565 TrustedStatus trusted_status) { |
545 PrefValueMap new_values_cache; | 566 PrefValueMap new_values_cache; |
546 | 567 |
547 if (policy_data.has_username() && !policy_data.has_request_token()) | 568 if (policy_data.has_username() && !policy_data.has_request_token()) |
548 new_values_cache.SetString(kDeviceOwner, policy_data.username()); | 569 new_values_cache.SetString(kDeviceOwner, policy_data.username()); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 void DeviceSettingsProvider::AttemptMigration() { | 794 void DeviceSettingsProvider::AttemptMigration() { |
774 if (device_settings_service_->HasPrivateOwnerKey()) { | 795 if (device_settings_service_->HasPrivateOwnerKey()) { |
775 PrefValueMap::const_iterator i; | 796 PrefValueMap::const_iterator i; |
776 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 797 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
777 DoSet(i->first, *i->second); | 798 DoSet(i->first, *i->second); |
778 migration_values_.Clear(); | 799 migration_values_.Clear(); |
779 } | 800 } |
780 } | 801 } |
781 | 802 |
782 } // namespace chromeos | 803 } // namespace chromeos |
OLD | NEW |