| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 46 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
| 47 kAccountsPrefDeviceLocalAccountAutoLoginId, | 47 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 48 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, | 48 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, |
| 49 kAccountsPrefEphemeralUsersEnabled, | 49 kAccountsPrefEphemeralUsersEnabled, |
| 50 kAccountsPrefShowUserNamesOnSignIn, | 50 kAccountsPrefShowUserNamesOnSignIn, |
| 51 kAccountsPrefSupervisedUsersEnabled, | 51 kAccountsPrefSupervisedUsersEnabled, |
| 52 kAccountsPrefTransferSAMLCookies, | 52 kAccountsPrefTransferSAMLCookies, |
| 53 kAccountsPrefUsers, | 53 kAccountsPrefUsers, |
| 54 kAllowRedeemChromeOsRegistrationOffers, | 54 kAllowRedeemChromeOsRegistrationOffers, |
| 55 kAllowedConnectionTypesForUpdate, | 55 kAllowedConnectionTypesForUpdate, |
| 56 kAppPack, | |
| 57 kAttestationForContentProtectionEnabled, | 56 kAttestationForContentProtectionEnabled, |
| 58 kDeviceAttestationEnabled, | 57 kDeviceAttestationEnabled, |
| 59 kDeviceOwner, | 58 kDeviceOwner, |
| 60 kIdleLogoutTimeout, | |
| 61 kIdleLogoutWarningDuration, | |
| 62 kPolicyMissingMitigationMode, | 59 kPolicyMissingMitigationMode, |
| 63 kReleaseChannel, | 60 kReleaseChannel, |
| 64 kReleaseChannelDelegated, | 61 kReleaseChannelDelegated, |
| 65 kReportDeviceActivityTimes, | 62 kReportDeviceActivityTimes, |
| 66 kReportDeviceBootMode, | 63 kReportDeviceBootMode, |
| 67 kReportDeviceLocation, | 64 kReportDeviceLocation, |
| 68 kReportDeviceNetworkInterfaces, | 65 kReportDeviceNetworkInterfaces, |
| 69 kReportDeviceUsers, | 66 kReportDeviceUsers, |
| 70 kReportDeviceVersionInfo, | 67 kReportDeviceVersionInfo, |
| 71 kScreenSaverExtensionId, | |
| 72 kScreenSaverTimeout, | |
| 73 kServiceAccountIdentity, | 68 kServiceAccountIdentity, |
| 74 kSignedDataRoamingEnabled, | 69 kSignedDataRoamingEnabled, |
| 75 kStartUpFlags, | 70 kStartUpFlags, |
| 76 kStartUpUrls, | |
| 77 kStatsReportingPref, | 71 kStatsReportingPref, |
| 78 kSystemTimezonePolicy, | 72 kSystemTimezonePolicy, |
| 79 kSystemUse24HourClock, | 73 kSystemUse24HourClock, |
| 80 kUpdateDisabled, | 74 kUpdateDisabled, |
| 81 kVariationsRestrictParameter, | 75 kVariationsRestrictParameter, |
| 82 kDeviceDisabled, | 76 kDeviceDisabled, |
| 83 kDeviceDisabledMessage, | 77 kDeviceDisabledMessage, |
| 84 }; | 78 }; |
| 85 | 79 |
| 86 bool HasOldMetricsFile() { | 80 bool HasOldMetricsFile() { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 new_values_cache->SetValue(kStartUpFlags, list); | 228 new_values_cache->SetValue(kStartUpFlags, list); |
| 235 } | 229 } |
| 236 | 230 |
| 237 if (policy.has_saml_settings()) { | 231 if (policy.has_saml_settings()) { |
| 238 new_values_cache->SetBoolean( | 232 new_values_cache->SetBoolean( |
| 239 kAccountsPrefTransferSAMLCookies, | 233 kAccountsPrefTransferSAMLCookies, |
| 240 policy.saml_settings().transfer_saml_cookies()); | 234 policy.saml_settings().transfer_saml_cookies()); |
| 241 } | 235 } |
| 242 } | 236 } |
| 243 | 237 |
| 244 void DecodeKioskPolicies( | |
| 245 const em::ChromeDeviceSettingsProto& policy, | |
| 246 PrefValueMap* new_values_cache) { | |
| 247 if (policy.has_forced_logout_timeouts()) { | |
| 248 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { | |
| 249 new_values_cache->SetInteger( | |
| 250 kIdleLogoutTimeout, | |
| 251 policy.forced_logout_timeouts().idle_logout_timeout()); | |
| 252 } | |
| 253 | |
| 254 if (policy.forced_logout_timeouts().has_idle_logout_warning_duration()) { | |
| 255 new_values_cache->SetInteger( | |
| 256 kIdleLogoutWarningDuration, | |
| 257 policy.forced_logout_timeouts().idle_logout_warning_duration()); | |
| 258 } | |
| 259 } | |
| 260 | |
| 261 if (policy.has_login_screen_saver()) { | |
| 262 if (policy.login_screen_saver().has_screen_saver_timeout()) { | |
| 263 new_values_cache->SetInteger( | |
| 264 kScreenSaverTimeout, | |
| 265 policy.login_screen_saver().screen_saver_timeout()); | |
| 266 } | |
| 267 | |
| 268 if (policy.login_screen_saver().has_screen_saver_extension_id()) { | |
| 269 new_values_cache->SetString( | |
| 270 kScreenSaverExtensionId, | |
| 271 policy.login_screen_saver().screen_saver_extension_id()); | |
| 272 } | |
| 273 } | |
| 274 | |
| 275 if (policy.has_app_pack()) { | |
| 276 typedef RepeatedPtrField<em::AppPackEntryProto> proto_type; | |
| 277 base::ListValue* list = new base::ListValue; | |
| 278 const proto_type& app_pack = policy.app_pack().app_pack(); | |
| 279 for (proto_type::const_iterator it = app_pack.begin(); | |
| 280 it != app_pack.end(); ++it) { | |
| 281 base::DictionaryValue* entry = new base::DictionaryValue; | |
| 282 if (it->has_extension_id()) { | |
| 283 entry->SetStringWithoutPathExpansion(kAppPackKeyExtensionId, | |
| 284 it->extension_id()); | |
| 285 } | |
| 286 if (it->has_update_url()) { | |
| 287 entry->SetStringWithoutPathExpansion(kAppPackKeyUpdateUrl, | |
| 288 it->update_url()); | |
| 289 } | |
| 290 list->Append(entry); | |
| 291 } | |
| 292 new_values_cache->SetValue(kAppPack, list); | |
| 293 } | |
| 294 | |
| 295 if (policy.has_start_up_urls()) { | |
| 296 base::ListValue* list = new base::ListValue(); | |
| 297 const em::StartUpUrlsProto& urls_proto = policy.start_up_urls(); | |
| 298 const RepeatedPtrField<std::string>& urls = urls_proto.start_up_urls(); | |
| 299 for (RepeatedPtrField<std::string>::const_iterator it = urls.begin(); | |
| 300 it != urls.end(); ++it) { | |
| 301 list->Append(new base::StringValue(*it)); | |
| 302 } | |
| 303 new_values_cache->SetValue(kStartUpUrls, list); | |
| 304 } | |
| 305 } | |
| 306 | |
| 307 void DecodeNetworkPolicies( | 238 void DecodeNetworkPolicies( |
| 308 const em::ChromeDeviceSettingsProto& policy, | 239 const em::ChromeDeviceSettingsProto& policy, |
| 309 PrefValueMap* new_values_cache) { | 240 PrefValueMap* new_values_cache) { |
| 310 // kSignedDataRoamingEnabled has a default value of false. | 241 // kSignedDataRoamingEnabled has a default value of false. |
| 311 new_values_cache->SetBoolean( | 242 new_values_cache->SetBoolean( |
| 312 kSignedDataRoamingEnabled, | 243 kSignedDataRoamingEnabled, |
| 313 policy.has_data_roaming_enabled() && | 244 policy.has_data_roaming_enabled() && |
| 314 policy.data_roaming_enabled().has_data_roaming_enabled() && | 245 policy.data_roaming_enabled().has_data_roaming_enabled() && |
| 315 policy.data_roaming_enabled().data_roaming_enabled()); | 246 policy.data_roaming_enabled().data_roaming_enabled()); |
| 316 } | 247 } |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 policy::MANAGEMENT_MODE_CONSUMER_MANAGED)) { | 552 policy::MANAGEMENT_MODE_CONSUMER_MANAGED)) { |
| 622 new_values_cache.SetString(kDeviceOwner, policy_data.username()); | 553 new_values_cache.SetString(kDeviceOwner, policy_data.username()); |
| 623 } | 554 } |
| 624 | 555 |
| 625 if (policy_data.has_service_account_identity()) { | 556 if (policy_data.has_service_account_identity()) { |
| 626 new_values_cache.SetString(kServiceAccountIdentity, | 557 new_values_cache.SetString(kServiceAccountIdentity, |
| 627 policy_data.service_account_identity()); | 558 policy_data.service_account_identity()); |
| 628 } | 559 } |
| 629 | 560 |
| 630 DecodeLoginPolicies(settings, &new_values_cache); | 561 DecodeLoginPolicies(settings, &new_values_cache); |
| 631 DecodeKioskPolicies(settings, &new_values_cache); | |
| 632 DecodeNetworkPolicies(settings, &new_values_cache); | 562 DecodeNetworkPolicies(settings, &new_values_cache); |
| 633 DecodeAutoUpdatePolicies(settings, &new_values_cache); | 563 DecodeAutoUpdatePolicies(settings, &new_values_cache); |
| 634 DecodeReportingPolicies(settings, &new_values_cache); | 564 DecodeReportingPolicies(settings, &new_values_cache); |
| 635 DecodeGenericPolicies(settings, &new_values_cache); | 565 DecodeGenericPolicies(settings, &new_values_cache); |
| 636 DecodeDeviceState(policy_data, &new_values_cache); | 566 DecodeDeviceState(policy_data, &new_values_cache); |
| 637 | 567 |
| 638 // Collect all notifications but send them only after we have swapped the | 568 // Collect all notifications but send them only after we have swapped the |
| 639 // cache so that if somebody actually reads the cache will be already valid. | 569 // cache so that if somebody actually reads the cache will be already valid. |
| 640 std::vector<std::string> notifications; | 570 std::vector<std::string> notifications; |
| 641 // Go through the new values and verify in the old ones. | 571 // Go through the new values and verify in the old ones. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 void DeviceSettingsProvider::AttemptMigration() { | 748 void DeviceSettingsProvider::AttemptMigration() { |
| 819 if (device_settings_service_->HasPrivateOwnerKey()) { | 749 if (device_settings_service_->HasPrivateOwnerKey()) { |
| 820 PrefValueMap::const_iterator i; | 750 PrefValueMap::const_iterator i; |
| 821 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 751 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
| 822 DoSet(i->first, *i->second); | 752 DoSet(i->first, *i->second); |
| 823 migration_values_.Clear(); | 753 migration_values_.Clear(); |
| 824 } | 754 } |
| 825 } | 755 } |
| 826 | 756 |
| 827 } // namespace chromeos | 757 } // namespace chromeos |
| OLD | NEW |