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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 bool HasOldMetricsFile() { | 82 bool HasOldMetricsFile() { |
83 // TODO(pastarmovj): Remove this once migration is not needed anymore. | 83 // 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. | 84 // If the value is not set we should try to migrate legacy consent file. |
85 // Loading consent file state causes us to do blocking IO on UI thread. | 85 // Loading consent file state causes us to do blocking IO on UI thread. |
86 // Temporarily allow it until we fix http://crbug.com/62626 | 86 // Temporarily allow it until we fix http://crbug.com/62626 |
87 base::ThreadRestrictions::ScopedAllowIO allow_io; | 87 base::ThreadRestrictions::ScopedAllowIO allow_io; |
88 return GoogleUpdateSettings::GetCollectStatsConsent(); | 88 return GoogleUpdateSettings::GetCollectStatsConsent(); |
89 } | 89 } |
90 | 90 |
| 91 void DecodeLoginPolicies( |
| 92 const em::ChromeDeviceSettingsProto& policy, |
| 93 PrefValueMap* new_values_cache) { |
| 94 // For all our boolean settings the following is applicable: |
| 95 // true is default permissive value and false is safe prohibitive value. |
| 96 // Exceptions: |
| 97 // kAccountsPrefEphemeralUsersEnabled has a default value of false. |
| 98 // kAccountsPrefSupervisedUsersEnabled has a default value of false |
| 99 // for enterprise devices and true for consumer devices. |
| 100 // kAccountsPrefTransferSAMLCookies has a default value of false. |
| 101 if (policy.has_allow_new_users() && |
| 102 policy.allow_new_users().has_allow_new_users()) { |
| 103 if (policy.allow_new_users().allow_new_users()) { |
| 104 // New users allowed, user whitelist ignored. |
| 105 new_values_cache->SetBoolean(kAccountsPrefAllowNewUser, true); |
| 106 } else { |
| 107 // New users not allowed, enforce user whitelist if present. |
| 108 new_values_cache->SetBoolean(kAccountsPrefAllowNewUser, |
| 109 !policy.has_user_whitelist()); |
| 110 } |
| 111 } else { |
| 112 // No configured allow-new-users value, enforce whitelist if non-empty. |
| 113 new_values_cache->SetBoolean( |
| 114 kAccountsPrefAllowNewUser, |
| 115 policy.user_whitelist().user_whitelist_size() == 0); |
| 116 } |
| 117 |
| 118 new_values_cache->SetBoolean( |
| 119 kAccountsPrefAllowGuest, |
| 120 !policy.has_guest_mode_enabled() || |
| 121 !policy.guest_mode_enabled().has_guest_mode_enabled() || |
| 122 policy.guest_mode_enabled().guest_mode_enabled()); |
| 123 |
| 124 policy::BrowserPolicyConnectorChromeOS* connector = |
| 125 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 126 bool supervised_users_enabled = false; |
| 127 if (connector->IsEnterpriseManaged()) { |
| 128 supervised_users_enabled = |
| 129 policy.has_supervised_users_settings() && |
| 130 policy.supervised_users_settings().has_supervised_users_enabled() && |
| 131 policy.supervised_users_settings().supervised_users_enabled(); |
| 132 } else { |
| 133 supervised_users_enabled = |
| 134 !policy.has_supervised_users_settings() || |
| 135 !policy.supervised_users_settings().has_supervised_users_enabled() || |
| 136 policy.supervised_users_settings().supervised_users_enabled(); |
| 137 } |
| 138 new_values_cache->SetBoolean( |
| 139 kAccountsPrefSupervisedUsersEnabled, supervised_users_enabled); |
| 140 |
| 141 new_values_cache->SetBoolean( |
| 142 kAccountsPrefShowUserNamesOnSignIn, |
| 143 !policy.has_show_user_names() || |
| 144 !policy.show_user_names().has_show_user_names() || |
| 145 policy.show_user_names().show_user_names()); |
| 146 |
| 147 new_values_cache->SetBoolean( |
| 148 kAccountsPrefEphemeralUsersEnabled, |
| 149 policy.has_ephemeral_users_enabled() && |
| 150 policy.ephemeral_users_enabled().has_ephemeral_users_enabled() && |
| 151 policy.ephemeral_users_enabled().ephemeral_users_enabled()); |
| 152 |
| 153 base::ListValue* list = new base::ListValue(); |
| 154 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist(); |
| 155 const RepeatedPtrField<std::string>& whitelist = |
| 156 whitelist_proto.user_whitelist(); |
| 157 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); |
| 158 it != whitelist.end(); ++it) { |
| 159 list->Append(new base::StringValue(*it)); |
| 160 } |
| 161 new_values_cache->SetValue(kAccountsPrefUsers, list); |
| 162 |
| 163 scoped_ptr<base::ListValue> account_list(new base::ListValue()); |
| 164 const em::DeviceLocalAccountsProto device_local_accounts_proto = |
| 165 policy.device_local_accounts(); |
| 166 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = |
| 167 device_local_accounts_proto.account(); |
| 168 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; |
| 169 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { |
| 170 scoped_ptr<base::DictionaryValue> entry_dict(new base::DictionaryValue()); |
| 171 if (entry->has_type()) { |
| 172 if (entry->has_account_id()) { |
| 173 entry_dict->SetStringWithoutPathExpansion( |
| 174 kAccountsPrefDeviceLocalAccountsKeyId, entry->account_id()); |
| 175 } |
| 176 entry_dict->SetIntegerWithoutPathExpansion( |
| 177 kAccountsPrefDeviceLocalAccountsKeyType, entry->type()); |
| 178 if (entry->kiosk_app().has_app_id()) { |
| 179 entry_dict->SetStringWithoutPathExpansion( |
| 180 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, |
| 181 entry->kiosk_app().app_id()); |
| 182 } |
| 183 } else if (entry->has_deprecated_public_session_id()) { |
| 184 // Deprecated public session specification. |
| 185 entry_dict->SetStringWithoutPathExpansion( |
| 186 kAccountsPrefDeviceLocalAccountsKeyId, |
| 187 entry->deprecated_public_session_id()); |
| 188 entry_dict->SetIntegerWithoutPathExpansion( |
| 189 kAccountsPrefDeviceLocalAccountsKeyType, |
| 190 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); |
| 191 } |
| 192 account_list->Append(entry_dict.release()); |
| 193 } |
| 194 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, |
| 195 account_list.release()); |
| 196 |
| 197 if (policy.has_device_local_accounts()) { |
| 198 if (policy.device_local_accounts().has_auto_login_id()) { |
| 199 new_values_cache->SetString( |
| 200 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 201 policy.device_local_accounts().auto_login_id()); |
| 202 } |
| 203 if (policy.device_local_accounts().has_auto_login_delay()) { |
| 204 new_values_cache->SetInteger( |
| 205 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
| 206 policy.device_local_accounts().auto_login_delay()); |
| 207 } |
| 208 } |
| 209 |
| 210 new_values_cache->SetBoolean( |
| 211 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, |
| 212 policy.device_local_accounts().enable_auto_login_bailout()); |
| 213 new_values_cache->SetBoolean( |
| 214 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, |
| 215 policy.device_local_accounts().prompt_for_network_when_offline()); |
| 216 |
| 217 if (policy.has_start_up_flags()) { |
| 218 base::ListValue* list = new base::ListValue(); |
| 219 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags(); |
| 220 const RepeatedPtrField<std::string>& flags = flags_proto.flags(); |
| 221 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin(); |
| 222 it != flags.end(); ++it) { |
| 223 list->Append(new base::StringValue(*it)); |
| 224 } |
| 225 new_values_cache->SetValue(kStartUpFlags, list); |
| 226 } |
| 227 |
| 228 if (policy.has_saml_settings()) { |
| 229 new_values_cache->SetBoolean( |
| 230 kAccountsPrefTransferSAMLCookies, |
| 231 policy.saml_settings().transfer_saml_cookies()); |
| 232 } |
| 233 } |
| 234 |
| 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( |
| 299 const em::ChromeDeviceSettingsProto& policy, |
| 300 PrefValueMap* new_values_cache) { |
| 301 // kSignedDataRoamingEnabled has a default value of false. |
| 302 new_values_cache->SetBoolean( |
| 303 kSignedDataRoamingEnabled, |
| 304 policy.has_data_roaming_enabled() && |
| 305 policy.data_roaming_enabled().has_data_roaming_enabled() && |
| 306 policy.data_roaming_enabled().data_roaming_enabled()); |
| 307 } |
| 308 |
| 309 void DecodeAutoUpdatePolicies( |
| 310 const em::ChromeDeviceSettingsProto& policy, |
| 311 PrefValueMap* new_values_cache) { |
| 312 if (policy.has_auto_update_settings()) { |
| 313 const em::AutoUpdateSettingsProto& au_settings_proto = |
| 314 policy.auto_update_settings(); |
| 315 if (au_settings_proto.has_update_disabled()) { |
| 316 new_values_cache->SetBoolean(kUpdateDisabled, |
| 317 au_settings_proto.update_disabled()); |
| 318 } |
| 319 const RepeatedField<int>& allowed_connection_types = |
| 320 au_settings_proto.allowed_connection_types(); |
| 321 base::ListValue* list = new base::ListValue(); |
| 322 for (RepeatedField<int>::const_iterator i(allowed_connection_types.begin()); |
| 323 i != allowed_connection_types.end(); ++i) { |
| 324 list->Append(new base::FundamentalValue(*i)); |
| 325 } |
| 326 new_values_cache->SetValue(kAllowedConnectionTypesForUpdate, list); |
| 327 } |
| 328 } |
| 329 |
| 330 void DecodeReportingPolicies( |
| 331 const em::ChromeDeviceSettingsProto& policy, |
| 332 PrefValueMap* new_values_cache) { |
| 333 if (policy.has_device_reporting()) { |
| 334 const em::DeviceReportingProto& reporting_policy = |
| 335 policy.device_reporting(); |
| 336 if (reporting_policy.has_report_version_info()) { |
| 337 new_values_cache->SetBoolean( |
| 338 kReportDeviceVersionInfo, |
| 339 reporting_policy.report_version_info()); |
| 340 } |
| 341 if (reporting_policy.has_report_activity_times()) { |
| 342 new_values_cache->SetBoolean( |
| 343 kReportDeviceActivityTimes, |
| 344 reporting_policy.report_activity_times()); |
| 345 } |
| 346 if (reporting_policy.has_report_boot_mode()) { |
| 347 new_values_cache->SetBoolean( |
| 348 kReportDeviceBootMode, |
| 349 reporting_policy.report_boot_mode()); |
| 350 } |
| 351 if (reporting_policy.has_report_network_interfaces()) { |
| 352 new_values_cache->SetBoolean( |
| 353 kReportDeviceNetworkInterfaces, |
| 354 reporting_policy.report_network_interfaces()); |
| 355 } |
| 356 if (reporting_policy.has_report_users()) { |
| 357 new_values_cache->SetBoolean( |
| 358 kReportDeviceUsers, |
| 359 reporting_policy.report_users()); |
| 360 } |
| 361 } |
| 362 } |
| 363 |
| 364 void DecodeGenericPolicies( |
| 365 const em::ChromeDeviceSettingsProto& policy, |
| 366 PrefValueMap* new_values_cache) { |
| 367 if (policy.has_metrics_enabled()) { |
| 368 new_values_cache->SetBoolean(kStatsReportingPref, |
| 369 policy.metrics_enabled().metrics_enabled()); |
| 370 } else { |
| 371 new_values_cache->SetBoolean(kStatsReportingPref, HasOldMetricsFile()); |
| 372 } |
| 373 |
| 374 if (!policy.has_release_channel() || |
| 375 !policy.release_channel().has_release_channel()) { |
| 376 // Default to an invalid channel (will be ignored). |
| 377 new_values_cache->SetString(kReleaseChannel, ""); |
| 378 } else { |
| 379 new_values_cache->SetString(kReleaseChannel, |
| 380 policy.release_channel().release_channel()); |
| 381 } |
| 382 |
| 383 new_values_cache->SetBoolean( |
| 384 kReleaseChannelDelegated, |
| 385 policy.has_release_channel() && |
| 386 policy.release_channel().has_release_channel_delegated() && |
| 387 policy.release_channel().release_channel_delegated()); |
| 388 |
| 389 if (policy.has_system_timezone()) { |
| 390 if (policy.system_timezone().has_timezone()) { |
| 391 new_values_cache->SetString( |
| 392 kSystemTimezonePolicy, |
| 393 policy.system_timezone().timezone()); |
| 394 } |
| 395 } |
| 396 |
| 397 if (policy.has_use_24hour_clock()) { |
| 398 if (policy.use_24hour_clock().has_use_24hour_clock()) { |
| 399 new_values_cache->SetBoolean( |
| 400 kSystemUse24HourClock, policy.use_24hour_clock().use_24hour_clock()); |
| 401 } |
| 402 } |
| 403 |
| 404 if (policy.has_allow_redeem_offers()) { |
| 405 new_values_cache->SetBoolean( |
| 406 kAllowRedeemChromeOsRegistrationOffers, |
| 407 policy.allow_redeem_offers().allow_redeem_offers()); |
| 408 } else { |
| 409 new_values_cache->SetBoolean( |
| 410 kAllowRedeemChromeOsRegistrationOffers, |
| 411 true); |
| 412 } |
| 413 |
| 414 if (policy.has_variations_parameter()) { |
| 415 new_values_cache->SetString( |
| 416 kVariationsRestrictParameter, |
| 417 policy.variations_parameter().parameter()); |
| 418 } |
| 419 |
| 420 new_values_cache->SetBoolean( |
| 421 kDeviceAttestationEnabled, |
| 422 policy.attestation_settings().attestation_enabled()); |
| 423 |
| 424 if (policy.has_attestation_settings() && |
| 425 policy.attestation_settings().has_content_protection_enabled()) { |
| 426 new_values_cache->SetBoolean( |
| 427 kAttestationForContentProtectionEnabled, |
| 428 policy.attestation_settings().content_protection_enabled()); |
| 429 } else { |
| 430 new_values_cache->SetBoolean(kAttestationForContentProtectionEnabled, true); |
| 431 } |
| 432 } |
| 433 |
91 } // namespace | 434 } // namespace |
92 | 435 |
93 DeviceSettingsProvider::DeviceSettingsProvider( | 436 DeviceSettingsProvider::DeviceSettingsProvider( |
94 const NotifyObserversCallback& notify_cb, | 437 const NotifyObserversCallback& notify_cb, |
95 DeviceSettingsService* device_settings_service) | 438 DeviceSettingsService* device_settings_service) |
96 : CrosSettingsProvider(notify_cb), | 439 : CrosSettingsProvider(notify_cb), |
97 device_settings_service_(device_settings_service), | 440 device_settings_service_(device_settings_service), |
98 trusted_status_(TEMPORARILY_UNTRUSTED), | 441 trusted_status_(TEMPORARILY_UNTRUSTED), |
99 ownership_status_(device_settings_service_->GetOwnershipStatus()), | 442 ownership_status_(device_settings_service_->GetOwnershipStatus()), |
100 store_callback_factory_(this) { | 443 store_callback_factory_(this) { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 if (!device_settings_cache::Store(data, g_browser_process->local_state())) | 777 if (!device_settings_cache::Store(data, g_browser_process->local_state())) |
435 LOG(ERROR) << "Couldn't store to the temp storage."; | 778 LOG(ERROR) << "Couldn't store to the temp storage."; |
436 | 779 |
437 // OnStorePolicyCompleted won't get called in this case so proceed with any | 780 // OnStorePolicyCompleted won't get called in this case so proceed with any |
438 // pending operations immediately. | 781 // pending operations immediately. |
439 if (!pending_changes_.empty()) | 782 if (!pending_changes_.empty()) |
440 SetInPolicy(); | 783 SetInPolicy(); |
441 } | 784 } |
442 } | 785 } |
443 | 786 |
444 void DeviceSettingsProvider::DecodeLoginPolicies( | |
445 const em::ChromeDeviceSettingsProto& policy, | |
446 PrefValueMap* new_values_cache) const { | |
447 // For all our boolean settings the following is applicable: | |
448 // true is default permissive value and false is safe prohibitive value. | |
449 // Exceptions: | |
450 // kAccountsPrefEphemeralUsersEnabled has a default value of false. | |
451 // kAccountsPrefSupervisedUsersEnabled has a default value of false | |
452 // for enterprise devices and true for consumer devices. | |
453 // kAccountsPrefTransferSAMLCookies has a default value of false. | |
454 if (policy.has_allow_new_users() && | |
455 policy.allow_new_users().has_allow_new_users()) { | |
456 if (policy.allow_new_users().allow_new_users()) { | |
457 // New users allowed, user whitelist ignored. | |
458 new_values_cache->SetBoolean(kAccountsPrefAllowNewUser, true); | |
459 } else { | |
460 // New users not allowed, enforce user whitelist if present. | |
461 new_values_cache->SetBoolean(kAccountsPrefAllowNewUser, | |
462 !policy.has_user_whitelist()); | |
463 } | |
464 } else { | |
465 // No configured allow-new-users value, enforce whitelist if non-empty. | |
466 new_values_cache->SetBoolean( | |
467 kAccountsPrefAllowNewUser, | |
468 policy.user_whitelist().user_whitelist_size() == 0); | |
469 } | |
470 | |
471 new_values_cache->SetBoolean( | |
472 kAccountsPrefAllowGuest, | |
473 !policy.has_guest_mode_enabled() || | |
474 !policy.guest_mode_enabled().has_guest_mode_enabled() || | |
475 policy.guest_mode_enabled().guest_mode_enabled()); | |
476 | |
477 policy::BrowserPolicyConnectorChromeOS* connector = | |
478 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
479 bool supervised_users_enabled = false; | |
480 if (connector->IsEnterpriseManaged()) { | |
481 supervised_users_enabled = | |
482 policy.has_supervised_users_settings() && | |
483 policy.supervised_users_settings().has_supervised_users_enabled() && | |
484 policy.supervised_users_settings().supervised_users_enabled(); | |
485 } else { | |
486 supervised_users_enabled = | |
487 !policy.has_supervised_users_settings() || | |
488 !policy.supervised_users_settings().has_supervised_users_enabled() || | |
489 policy.supervised_users_settings().supervised_users_enabled(); | |
490 } | |
491 new_values_cache->SetBoolean( | |
492 kAccountsPrefSupervisedUsersEnabled, supervised_users_enabled); | |
493 | |
494 new_values_cache->SetBoolean( | |
495 kAccountsPrefShowUserNamesOnSignIn, | |
496 !policy.has_show_user_names() || | |
497 !policy.show_user_names().has_show_user_names() || | |
498 policy.show_user_names().show_user_names()); | |
499 | |
500 new_values_cache->SetBoolean( | |
501 kAccountsPrefEphemeralUsersEnabled, | |
502 policy.has_ephemeral_users_enabled() && | |
503 policy.ephemeral_users_enabled().has_ephemeral_users_enabled() && | |
504 policy.ephemeral_users_enabled().ephemeral_users_enabled()); | |
505 | |
506 base::ListValue* list = new base::ListValue(); | |
507 const em::UserWhitelistProto& whitelist_proto = policy.user_whitelist(); | |
508 const RepeatedPtrField<std::string>& whitelist = | |
509 whitelist_proto.user_whitelist(); | |
510 for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin(); | |
511 it != whitelist.end(); ++it) { | |
512 list->Append(new base::StringValue(*it)); | |
513 } | |
514 new_values_cache->SetValue(kAccountsPrefUsers, list); | |
515 | |
516 scoped_ptr<base::ListValue> account_list(new base::ListValue()); | |
517 const em::DeviceLocalAccountsProto device_local_accounts_proto = | |
518 policy.device_local_accounts(); | |
519 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = | |
520 device_local_accounts_proto.account(); | |
521 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; | |
522 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { | |
523 scoped_ptr<base::DictionaryValue> entry_dict(new base::DictionaryValue()); | |
524 if (entry->has_type()) { | |
525 if (entry->has_account_id()) { | |
526 entry_dict->SetStringWithoutPathExpansion( | |
527 kAccountsPrefDeviceLocalAccountsKeyId, entry->account_id()); | |
528 } | |
529 entry_dict->SetIntegerWithoutPathExpansion( | |
530 kAccountsPrefDeviceLocalAccountsKeyType, entry->type()); | |
531 if (entry->kiosk_app().has_app_id()) { | |
532 entry_dict->SetStringWithoutPathExpansion( | |
533 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, | |
534 entry->kiosk_app().app_id()); | |
535 } | |
536 } else if (entry->has_deprecated_public_session_id()) { | |
537 // Deprecated public session specification. | |
538 entry_dict->SetStringWithoutPathExpansion( | |
539 kAccountsPrefDeviceLocalAccountsKeyId, | |
540 entry->deprecated_public_session_id()); | |
541 entry_dict->SetIntegerWithoutPathExpansion( | |
542 kAccountsPrefDeviceLocalAccountsKeyType, | |
543 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); | |
544 } | |
545 account_list->Append(entry_dict.release()); | |
546 } | |
547 new_values_cache->SetValue(kAccountsPrefDeviceLocalAccounts, | |
548 account_list.release()); | |
549 | |
550 if (policy.has_device_local_accounts()) { | |
551 if (policy.device_local_accounts().has_auto_login_id()) { | |
552 new_values_cache->SetString( | |
553 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
554 policy.device_local_accounts().auto_login_id()); | |
555 } | |
556 if (policy.device_local_accounts().has_auto_login_delay()) { | |
557 new_values_cache->SetInteger( | |
558 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
559 policy.device_local_accounts().auto_login_delay()); | |
560 } | |
561 } | |
562 | |
563 new_values_cache->SetBoolean( | |
564 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, | |
565 policy.device_local_accounts().enable_auto_login_bailout()); | |
566 new_values_cache->SetBoolean( | |
567 kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline, | |
568 policy.device_local_accounts().prompt_for_network_when_offline()); | |
569 | |
570 if (policy.has_start_up_flags()) { | |
571 base::ListValue* list = new base::ListValue(); | |
572 const em::StartUpFlagsProto& flags_proto = policy.start_up_flags(); | |
573 const RepeatedPtrField<std::string>& flags = flags_proto.flags(); | |
574 for (RepeatedPtrField<std::string>::const_iterator it = flags.begin(); | |
575 it != flags.end(); ++it) { | |
576 list->Append(new base::StringValue(*it)); | |
577 } | |
578 new_values_cache->SetValue(kStartUpFlags, list); | |
579 } | |
580 | |
581 if (policy.has_saml_settings()) { | |
582 new_values_cache->SetBoolean( | |
583 kAccountsPrefTransferSAMLCookies, | |
584 policy.saml_settings().transfer_saml_cookies()); | |
585 } | |
586 } | |
587 | |
588 void DeviceSettingsProvider::DecodeKioskPolicies( | |
589 const em::ChromeDeviceSettingsProto& policy, | |
590 PrefValueMap* new_values_cache) const { | |
591 if (policy.has_forced_logout_timeouts()) { | |
592 if (policy.forced_logout_timeouts().has_idle_logout_timeout()) { | |
593 new_values_cache->SetInteger( | |
594 kIdleLogoutTimeout, | |
595 policy.forced_logout_timeouts().idle_logout_timeout()); | |
596 } | |
597 | |
598 if (policy.forced_logout_timeouts().has_idle_logout_warning_duration()) { | |
599 new_values_cache->SetInteger( | |
600 kIdleLogoutWarningDuration, | |
601 policy.forced_logout_timeouts().idle_logout_warning_duration()); | |
602 } | |
603 } | |
604 | |
605 if (policy.has_login_screen_saver()) { | |
606 if (policy.login_screen_saver().has_screen_saver_timeout()) { | |
607 new_values_cache->SetInteger( | |
608 kScreenSaverTimeout, | |
609 policy.login_screen_saver().screen_saver_timeout()); | |
610 } | |
611 | |
612 if (policy.login_screen_saver().has_screen_saver_extension_id()) { | |
613 new_values_cache->SetString( | |
614 kScreenSaverExtensionId, | |
615 policy.login_screen_saver().screen_saver_extension_id()); | |
616 } | |
617 } | |
618 | |
619 if (policy.has_app_pack()) { | |
620 typedef RepeatedPtrField<em::AppPackEntryProto> proto_type; | |
621 base::ListValue* list = new base::ListValue; | |
622 const proto_type& app_pack = policy.app_pack().app_pack(); | |
623 for (proto_type::const_iterator it = app_pack.begin(); | |
624 it != app_pack.end(); ++it) { | |
625 base::DictionaryValue* entry = new base::DictionaryValue; | |
626 if (it->has_extension_id()) { | |
627 entry->SetStringWithoutPathExpansion(kAppPackKeyExtensionId, | |
628 it->extension_id()); | |
629 } | |
630 if (it->has_update_url()) { | |
631 entry->SetStringWithoutPathExpansion(kAppPackKeyUpdateUrl, | |
632 it->update_url()); | |
633 } | |
634 list->Append(entry); | |
635 } | |
636 new_values_cache->SetValue(kAppPack, list); | |
637 } | |
638 | |
639 if (policy.has_start_up_urls()) { | |
640 base::ListValue* list = new base::ListValue(); | |
641 const em::StartUpUrlsProto& urls_proto = policy.start_up_urls(); | |
642 const RepeatedPtrField<std::string>& urls = urls_proto.start_up_urls(); | |
643 for (RepeatedPtrField<std::string>::const_iterator it = urls.begin(); | |
644 it != urls.end(); ++it) { | |
645 list->Append(new base::StringValue(*it)); | |
646 } | |
647 new_values_cache->SetValue(kStartUpUrls, list); | |
648 } | |
649 } | |
650 | |
651 void DeviceSettingsProvider::DecodeNetworkPolicies( | |
652 const em::ChromeDeviceSettingsProto& policy, | |
653 PrefValueMap* new_values_cache) const { | |
654 // kSignedDataRoamingEnabled has a default value of false. | |
655 new_values_cache->SetBoolean( | |
656 kSignedDataRoamingEnabled, | |
657 policy.has_data_roaming_enabled() && | |
658 policy.data_roaming_enabled().has_data_roaming_enabled() && | |
659 policy.data_roaming_enabled().data_roaming_enabled()); | |
660 } | |
661 | |
662 void DeviceSettingsProvider::DecodeAutoUpdatePolicies( | |
663 const em::ChromeDeviceSettingsProto& policy, | |
664 PrefValueMap* new_values_cache) const { | |
665 if (policy.has_auto_update_settings()) { | |
666 const em::AutoUpdateSettingsProto& au_settings_proto = | |
667 policy.auto_update_settings(); | |
668 if (au_settings_proto.has_update_disabled()) { | |
669 new_values_cache->SetBoolean(kUpdateDisabled, | |
670 au_settings_proto.update_disabled()); | |
671 } | |
672 const RepeatedField<int>& allowed_connection_types = | |
673 au_settings_proto.allowed_connection_types(); | |
674 base::ListValue* list = new base::ListValue(); | |
675 for (RepeatedField<int>::const_iterator i(allowed_connection_types.begin()); | |
676 i != allowed_connection_types.end(); ++i) { | |
677 list->Append(new base::FundamentalValue(*i)); | |
678 } | |
679 new_values_cache->SetValue(kAllowedConnectionTypesForUpdate, list); | |
680 } | |
681 } | |
682 | |
683 void DeviceSettingsProvider::DecodeReportingPolicies( | |
684 const em::ChromeDeviceSettingsProto& policy, | |
685 PrefValueMap* new_values_cache) const { | |
686 if (policy.has_device_reporting()) { | |
687 const em::DeviceReportingProto& reporting_policy = | |
688 policy.device_reporting(); | |
689 if (reporting_policy.has_report_version_info()) { | |
690 new_values_cache->SetBoolean( | |
691 kReportDeviceVersionInfo, | |
692 reporting_policy.report_version_info()); | |
693 } | |
694 if (reporting_policy.has_report_activity_times()) { | |
695 new_values_cache->SetBoolean( | |
696 kReportDeviceActivityTimes, | |
697 reporting_policy.report_activity_times()); | |
698 } | |
699 if (reporting_policy.has_report_boot_mode()) { | |
700 new_values_cache->SetBoolean( | |
701 kReportDeviceBootMode, | |
702 reporting_policy.report_boot_mode()); | |
703 } | |
704 if (reporting_policy.has_report_network_interfaces()) { | |
705 new_values_cache->SetBoolean( | |
706 kReportDeviceNetworkInterfaces, | |
707 reporting_policy.report_network_interfaces()); | |
708 } | |
709 if (reporting_policy.has_report_users()) { | |
710 new_values_cache->SetBoolean( | |
711 kReportDeviceUsers, | |
712 reporting_policy.report_users()); | |
713 } | |
714 } | |
715 } | |
716 | |
717 void DeviceSettingsProvider::DecodeGenericPolicies( | |
718 const em::ChromeDeviceSettingsProto& policy, | |
719 PrefValueMap* new_values_cache) const { | |
720 if (policy.has_metrics_enabled()) { | |
721 new_values_cache->SetBoolean(kStatsReportingPref, | |
722 policy.metrics_enabled().metrics_enabled()); | |
723 } else { | |
724 new_values_cache->SetBoolean(kStatsReportingPref, HasOldMetricsFile()); | |
725 } | |
726 | |
727 if (!policy.has_release_channel() || | |
728 !policy.release_channel().has_release_channel()) { | |
729 // Default to an invalid channel (will be ignored). | |
730 new_values_cache->SetString(kReleaseChannel, ""); | |
731 } else { | |
732 new_values_cache->SetString(kReleaseChannel, | |
733 policy.release_channel().release_channel()); | |
734 } | |
735 | |
736 new_values_cache->SetBoolean( | |
737 kReleaseChannelDelegated, | |
738 policy.has_release_channel() && | |
739 policy.release_channel().has_release_channel_delegated() && | |
740 policy.release_channel().release_channel_delegated()); | |
741 | |
742 if (policy.has_system_timezone()) { | |
743 if (policy.system_timezone().has_timezone()) { | |
744 new_values_cache->SetString( | |
745 kSystemTimezonePolicy, | |
746 policy.system_timezone().timezone()); | |
747 } | |
748 } | |
749 | |
750 if (policy.has_use_24hour_clock()) { | |
751 if (policy.use_24hour_clock().has_use_24hour_clock()) { | |
752 new_values_cache->SetBoolean( | |
753 kSystemUse24HourClock, policy.use_24hour_clock().use_24hour_clock()); | |
754 } | |
755 } | |
756 | |
757 if (policy.has_allow_redeem_offers()) { | |
758 new_values_cache->SetBoolean( | |
759 kAllowRedeemChromeOsRegistrationOffers, | |
760 policy.allow_redeem_offers().allow_redeem_offers()); | |
761 } else { | |
762 new_values_cache->SetBoolean( | |
763 kAllowRedeemChromeOsRegistrationOffers, | |
764 true); | |
765 } | |
766 | |
767 if (policy.has_variations_parameter()) { | |
768 new_values_cache->SetString( | |
769 kVariationsRestrictParameter, | |
770 policy.variations_parameter().parameter()); | |
771 } | |
772 | |
773 new_values_cache->SetBoolean( | |
774 kDeviceAttestationEnabled, | |
775 policy.attestation_settings().attestation_enabled()); | |
776 | |
777 if (policy.has_attestation_settings() && | |
778 policy.attestation_settings().has_content_protection_enabled()) { | |
779 new_values_cache->SetBoolean( | |
780 kAttestationForContentProtectionEnabled, | |
781 policy.attestation_settings().content_protection_enabled()); | |
782 } else { | |
783 new_values_cache->SetBoolean(kAttestationForContentProtectionEnabled, true); | |
784 } | |
785 } | |
786 | |
787 void DeviceSettingsProvider::UpdateValuesCache( | 787 void DeviceSettingsProvider::UpdateValuesCache( |
788 const em::PolicyData& policy_data, | 788 const em::PolicyData& policy_data, |
789 const em::ChromeDeviceSettingsProto& settings, | 789 const em::ChromeDeviceSettingsProto& settings, |
790 TrustedStatus trusted_status) { | 790 TrustedStatus trusted_status) { |
791 PrefValueMap new_values_cache; | 791 PrefValueMap new_values_cache; |
792 | 792 |
793 if (policy_data.has_username() && !policy_data.has_request_token()) | 793 if (policy_data.has_username() && !policy_data.has_request_token()) |
794 new_values_cache.SetString(kDeviceOwner, policy_data.username()); | 794 new_values_cache.SetString(kDeviceOwner, policy_data.username()); |
795 | 795 |
796 if (policy_data.has_service_account_identity()) { | 796 if (policy_data.has_service_account_identity()) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 void DeviceSettingsProvider::AttemptMigration() { | 1004 void DeviceSettingsProvider::AttemptMigration() { |
1005 if (device_settings_service_->HasPrivateOwnerKey()) { | 1005 if (device_settings_service_->HasPrivateOwnerKey()) { |
1006 PrefValueMap::const_iterator i; | 1006 PrefValueMap::const_iterator i; |
1007 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) | 1007 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) |
1008 DoSet(i->first, *i->second); | 1008 DoSet(i->first, *i->second); |
1009 migration_values_.Clear(); | 1009 migration_values_.Clear(); |
1010 } | 1010 } |
1011 } | 1011 } |
1012 | 1012 |
1013 } // namespace chromeos | 1013 } // namespace chromeos |
OLD | NEW |