| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 kAllowRedeemChromeOsRegistrationOffers, | 55 kAllowRedeemChromeOsRegistrationOffers, |
| 56 kAllowedConnectionTypesForUpdate, | 56 kAllowedConnectionTypesForUpdate, |
| 57 kAttestationForContentProtectionEnabled, | 57 kAttestationForContentProtectionEnabled, |
| 58 kDeviceAttestationEnabled, | 58 kDeviceAttestationEnabled, |
| 59 kDeviceDisabled, | 59 kDeviceDisabled, |
| 60 kDeviceDisabledMessage, | 60 kDeviceDisabledMessage, |
| 61 kDeviceOwner, | 61 kDeviceOwner, |
| 62 kExtensionCacheSize, | 62 kExtensionCacheSize, |
| 63 kHeartbeatEnabled, | 63 kHeartbeatEnabled, |
| 64 kHeartbeatFrequency, | 64 kHeartbeatFrequency, |
| 65 kLogUploadEnabled, |
| 65 kPolicyMissingMitigationMode, | 66 kPolicyMissingMitigationMode, |
| 66 kRebootOnShutdown, | 67 kRebootOnShutdown, |
| 67 kReleaseChannel, | 68 kReleaseChannel, |
| 68 kReleaseChannelDelegated, | 69 kReleaseChannelDelegated, |
| 69 kReportDeviceActivityTimes, | 70 kReportDeviceActivityTimes, |
| 70 kReportDeviceBootMode, | 71 kReportDeviceBootMode, |
| 71 kReportDeviceHardwareStatus, | 72 kReportDeviceHardwareStatus, |
| 72 kReportDeviceLocation, | 73 kReportDeviceLocation, |
| 73 kReportDeviceNetworkInterfaces, | 74 kReportDeviceNetworkInterfaces, |
| 74 kReportDeviceSessionStatus, | 75 kReportDeviceSessionStatus, |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } | 435 } |
| 435 | 436 |
| 436 if (policy.has_extension_cache_size() && | 437 if (policy.has_extension_cache_size() && |
| 437 policy.extension_cache_size().has_extension_cache_size()) { | 438 policy.extension_cache_size().has_extension_cache_size()) { |
| 438 new_values_cache->SetInteger( | 439 new_values_cache->SetInteger( |
| 439 kExtensionCacheSize, | 440 kExtensionCacheSize, |
| 440 policy.extension_cache_size().extension_cache_size()); | 441 policy.extension_cache_size().extension_cache_size()); |
| 441 } | 442 } |
| 442 } | 443 } |
| 443 | 444 |
| 445 void DecodeLogUploadPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 446 PrefValueMap* new_values_cache) { |
| 447 if (!policy.has_device_log_upload_settings()) |
| 448 return; |
| 449 |
| 450 const em::DeviceLogUploadSettingsProto& log_upload_policy = |
| 451 policy.device_log_upload_settings(); |
| 452 if (log_upload_policy.has_log_upload_enabled()) { |
| 453 new_values_cache->SetBoolean(kLogUploadEnabled, |
| 454 log_upload_policy.log_upload_enabled()); |
| 455 } |
| 456 } |
| 457 |
| 444 void DecodeDeviceState(const em::PolicyData& policy_data, | 458 void DecodeDeviceState(const em::PolicyData& policy_data, |
| 445 PrefValueMap* new_values_cache) { | 459 PrefValueMap* new_values_cache) { |
| 446 if (!policy_data.has_device_state()) | 460 if (!policy_data.has_device_state()) |
| 447 return; | 461 return; |
| 448 | 462 |
| 449 const em::DeviceState& device_state = policy_data.device_state(); | 463 const em::DeviceState& device_state = policy_data.device_state(); |
| 450 | 464 |
| 451 if (device_state.device_mode() == em::DeviceState::DEVICE_MODE_DISABLED) | 465 if (device_state.device_mode() == em::DeviceState::DEVICE_MODE_DISABLED) |
| 452 new_values_cache->SetBoolean(kDeviceDisabled, true); | 466 new_values_cache->SetBoolean(kDeviceDisabled, true); |
| 453 if (device_state.has_disabled_state() && | 467 if (device_state.has_disabled_state() && |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 new_values_cache.SetString(kServiceAccountIdentity, | 641 new_values_cache.SetString(kServiceAccountIdentity, |
| 628 policy_data.service_account_identity()); | 642 policy_data.service_account_identity()); |
| 629 } | 643 } |
| 630 | 644 |
| 631 DecodeLoginPolicies(settings, &new_values_cache); | 645 DecodeLoginPolicies(settings, &new_values_cache); |
| 632 DecodeNetworkPolicies(settings, &new_values_cache); | 646 DecodeNetworkPolicies(settings, &new_values_cache); |
| 633 DecodeAutoUpdatePolicies(settings, &new_values_cache); | 647 DecodeAutoUpdatePolicies(settings, &new_values_cache); |
| 634 DecodeReportingPolicies(settings, &new_values_cache); | 648 DecodeReportingPolicies(settings, &new_values_cache); |
| 635 DecodeHeartbeatPolicies(settings, &new_values_cache); | 649 DecodeHeartbeatPolicies(settings, &new_values_cache); |
| 636 DecodeGenericPolicies(settings, &new_values_cache); | 650 DecodeGenericPolicies(settings, &new_values_cache); |
| 651 DecodeLogUploadPolicies(settings, &new_values_cache); |
| 637 DecodeDeviceState(policy_data, &new_values_cache); | 652 DecodeDeviceState(policy_data, &new_values_cache); |
| 638 | 653 |
| 639 // Collect all notifications but send them only after we have swapped the | 654 // Collect all notifications but send them only after we have swapped the |
| 640 // cache so that if somebody actually reads the cache will be already valid. | 655 // cache so that if somebody actually reads the cache will be already valid. |
| 641 std::vector<std::string> notifications; | 656 std::vector<std::string> notifications; |
| 642 // Go through the new values and verify in the old ones. | 657 // Go through the new values and verify in the old ones. |
| 643 PrefValueMap::iterator iter = new_values_cache.begin(); | 658 PrefValueMap::iterator iter = new_values_cache.begin(); |
| 644 for (; iter != new_values_cache.end(); ++iter) { | 659 for (; iter != new_values_cache.end(); ++iter) { |
| 645 const base::Value* old_value; | 660 const base::Value* old_value; |
| 646 if (!values_cache_.GetValue(iter->first, &old_value) || | 661 if (!values_cache_.GetValue(iter->first, &old_value) || |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 void DeviceSettingsProvider::AttemptMigration() { | 834 void DeviceSettingsProvider::AttemptMigration() { |
| 820 if (device_settings_service_->HasPrivateOwnerKey()) { | 835 if (device_settings_service_->HasPrivateOwnerKey()) { |
| 821 PrefValueMap::const_iterator i; | 836 PrefValueMap::const_iterator i; |
| 822 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 837 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
| 823 DoSet(i->first, *i->second); | 838 DoSet(i->first, *i->second); |
| 824 migration_values_.Clear(); | 839 migration_values_.Clear(); |
| 825 } | 840 } |
| 826 } | 841 } |
| 827 | 842 |
| 828 } // namespace chromeos | 843 } // namespace chromeos |
| OLD | NEW |