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