| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 kReportDeviceBootMode, | 64 kReportDeviceBootMode, |
| 65 kReportDeviceLocation, | 65 kReportDeviceLocation, |
| 66 kReportDeviceNetworkInterfaces, | 66 kReportDeviceNetworkInterfaces, |
| 67 kReportDeviceUsers, | 67 kReportDeviceUsers, |
| 68 kReportDeviceVersionInfo, | 68 kReportDeviceVersionInfo, |
| 69 kScreenSaverExtensionId, | 69 kScreenSaverExtensionId, |
| 70 kScreenSaverTimeout, | 70 kScreenSaverTimeout, |
| 71 kServiceAccountIdentity, | 71 kServiceAccountIdentity, |
| 72 kSignedDataRoamingEnabled, | 72 kSignedDataRoamingEnabled, |
| 73 kStartUpFlags, | 73 kStartUpFlags, |
| 74 kStartUpUrls, | |
| 75 kStatsReportingPref, | 74 kStatsReportingPref, |
| 76 kSystemTimezonePolicy, | 75 kSystemTimezonePolicy, |
| 77 kSystemUse24HourClock, | 76 kSystemUse24HourClock, |
| 78 kUpdateDisabled, | 77 kUpdateDisabled, |
| 79 kVariationsRestrictParameter, | 78 kVariationsRestrictParameter, |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 bool HasOldMetricsFile() { | 81 bool HasOldMetricsFile() { |
| 83 // TODO(pastarmovj): Remove this once migration is not needed anymore. | 82 // TODO(pastarmovj): Remove this once migration is not needed anymore. |
| 84 // If the value is not set we should try to migrate legacy consent file. | 83 // If the value is not set we should try to migrate legacy consent file. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 new_values_cache->SetValue(kStartUpFlags, list); | 224 new_values_cache->SetValue(kStartUpFlags, list); |
| 226 } | 225 } |
| 227 | 226 |
| 228 if (policy.has_saml_settings()) { | 227 if (policy.has_saml_settings()) { |
| 229 new_values_cache->SetBoolean( | 228 new_values_cache->SetBoolean( |
| 230 kAccountsPrefTransferSAMLCookies, | 229 kAccountsPrefTransferSAMLCookies, |
| 231 policy.saml_settings().transfer_saml_cookies()); | 230 policy.saml_settings().transfer_saml_cookies()); |
| 232 } | 231 } |
| 233 } | 232 } |
| 234 | 233 |
| 235 void DecodeKioskPolicies( | |
| 236 const em::ChromeDeviceSettingsProto& policy, | |
| 237 PrefValueMap* new_values_cache) { | |
| 238 if (policy.has_forced_logout_timeouts()) { | |
| 239 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { | |
| 240 new_values_cache->SetInteger( | |
| 241 kIdleLogoutTimeout, | |
| 242 policy.forced_logout_timeouts().idle_logout_timeout()); | |
| 243 } | |
| 244 | |
| 245 if (policy.forced_logout_timeouts().has_idle_logout_warning_duration()) { | |
| 246 new_values_cache->SetInteger( | |
| 247 kIdleLogoutWarningDuration, | |
| 248 policy.forced_logout_timeouts().idle_logout_warning_duration()); | |
| 249 } | |
| 250 } | |
| 251 | |
| 252 if (policy.has_login_screen_saver()) { | |
| 253 if (policy.login_screen_saver().has_screen_saver_timeout()) { | |
| 254 new_values_cache->SetInteger( | |
| 255 kScreenSaverTimeout, | |
| 256 policy.login_screen_saver().screen_saver_timeout()); | |
| 257 } | |
| 258 | |
| 259 if (policy.login_screen_saver().has_screen_saver_extension_id()) { | |
| 260 new_values_cache->SetString( | |
| 261 kScreenSaverExtensionId, | |
| 262 policy.login_screen_saver().screen_saver_extension_id()); | |
| 263 } | |
| 264 } | |
| 265 | |
| 266 if (policy.has_app_pack()) { | |
| 267 typedef RepeatedPtrField<em::AppPackEntryProto> proto_type; | |
| 268 base::ListValue* list = new base::ListValue; | |
| 269 const proto_type& app_pack = policy.app_pack().app_pack(); | |
| 270 for (proto_type::const_iterator it = app_pack.begin(); | |
| 271 it != app_pack.end(); ++it) { | |
| 272 base::DictionaryValue* entry = new base::DictionaryValue; | |
| 273 if (it->has_extension_id()) { | |
| 274 entry->SetStringWithoutPathExpansion(kAppPackKeyExtensionId, | |
| 275 it->extension_id()); | |
| 276 } | |
| 277 if (it->has_update_url()) { | |
| 278 entry->SetStringWithoutPathExpansion(kAppPackKeyUpdateUrl, | |
| 279 it->update_url()); | |
| 280 } | |
| 281 list->Append(entry); | |
| 282 } | |
| 283 new_values_cache->SetValue(kAppPack, list); | |
| 284 } | |
| 285 | |
| 286 if (policy.has_start_up_urls()) { | |
| 287 base::ListValue* list = new base::ListValue(); | |
| 288 const em::StartUpUrlsProto& urls_proto = policy.start_up_urls(); | |
| 289 const RepeatedPtrField<std::string>& urls = urls_proto.start_up_urls(); | |
| 290 for (RepeatedPtrField<std::string>::const_iterator it = urls.begin(); | |
| 291 it != urls.end(); ++it) { | |
| 292 list->Append(new base::StringValue(*it)); | |
| 293 } | |
| 294 new_values_cache->SetValue(kStartUpUrls, list); | |
| 295 } | |
| 296 } | |
| 297 | |
| 298 void DecodeNetworkPolicies( | 234 void DecodeNetworkPolicies( |
| 299 const em::ChromeDeviceSettingsProto& policy, | 235 const em::ChromeDeviceSettingsProto& policy, |
| 300 PrefValueMap* new_values_cache) { | 236 PrefValueMap* new_values_cache) { |
| 301 // kSignedDataRoamingEnabled has a default value of false. | 237 // kSignedDataRoamingEnabled has a default value of false. |
| 302 new_values_cache->SetBoolean( | 238 new_values_cache->SetBoolean( |
| 303 kSignedDataRoamingEnabled, | 239 kSignedDataRoamingEnabled, |
| 304 policy.has_data_roaming_enabled() && | 240 policy.has_data_roaming_enabled() && |
| 305 policy.data_roaming_enabled().has_data_roaming_enabled() && | 241 policy.data_roaming_enabled().has_data_roaming_enabled() && |
| 306 policy.data_roaming_enabled().data_roaming_enabled()); | 242 policy.data_roaming_enabled().data_roaming_enabled()); |
| 307 } | 243 } |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 | 728 |
| 793 if (policy_data.has_username() && !policy_data.has_request_token()) | 729 if (policy_data.has_username() && !policy_data.has_request_token()) |
| 794 new_values_cache.SetString(kDeviceOwner, policy_data.username()); | 730 new_values_cache.SetString(kDeviceOwner, policy_data.username()); |
| 795 | 731 |
| 796 if (policy_data.has_service_account_identity()) { | 732 if (policy_data.has_service_account_identity()) { |
| 797 new_values_cache.SetString(kServiceAccountIdentity, | 733 new_values_cache.SetString(kServiceAccountIdentity, |
| 798 policy_data.service_account_identity()); | 734 policy_data.service_account_identity()); |
| 799 } | 735 } |
| 800 | 736 |
| 801 DecodeLoginPolicies(settings, &new_values_cache); | 737 DecodeLoginPolicies(settings, &new_values_cache); |
| 802 DecodeKioskPolicies(settings, &new_values_cache); | |
| 803 DecodeNetworkPolicies(settings, &new_values_cache); | 738 DecodeNetworkPolicies(settings, &new_values_cache); |
| 804 DecodeAutoUpdatePolicies(settings, &new_values_cache); | 739 DecodeAutoUpdatePolicies(settings, &new_values_cache); |
| 805 DecodeReportingPolicies(settings, &new_values_cache); | 740 DecodeReportingPolicies(settings, &new_values_cache); |
| 806 DecodeGenericPolicies(settings, &new_values_cache); | 741 DecodeGenericPolicies(settings, &new_values_cache); |
| 807 | 742 |
| 808 // Collect all notifications but send them only after we have swapped the | 743 // Collect all notifications but send them only after we have swapped the |
| 809 // cache so that if somebody actually reads the cache will be already valid. | 744 // cache so that if somebody actually reads the cache will be already valid. |
| 810 std::vector<std::string> notifications; | 745 std::vector<std::string> notifications; |
| 811 // Go through the new values and verify in the old ones. | 746 // Go through the new values and verify in the old ones. |
| 812 PrefValueMap::iterator iter = new_values_cache.begin(); | 747 PrefValueMap::iterator iter = new_values_cache.begin(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 void DeviceSettingsProvider::AttemptMigration() { | 939 void DeviceSettingsProvider::AttemptMigration() { |
| 1005 if (device_settings_service_->HasPrivateOwnerKey()) { | 940 if (device_settings_service_->HasPrivateOwnerKey()) { |
| 1006 PrefValueMap::const_iterator i; | 941 PrefValueMap::const_iterator i; |
| 1007 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 942 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
| 1008 DoSet(i->first, *i->second); | 943 DoSet(i->first, *i->second); |
| 1009 migration_values_.Clear(); | 944 migration_values_.Clear(); |
| 1010 } | 945 } |
| 1011 } | 946 } |
| 1012 | 947 |
| 1013 } // namespace chromeos | 948 } // namespace chromeos |
| OLD | NEW |