| 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/policy/device_policy_decoder_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_policy_decoder_chromeos.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 shill::kTypeEthernet, | 100 shill::kTypeEthernet, |
| 101 shill::kTypeWifi, | 101 shill::kTypeWifi, |
| 102 shill::kTypeWimax, | 102 shill::kTypeWimax, |
| 103 shill::kTypeBluetooth, | 103 shill::kTypeBluetooth, |
| 104 shill::kTypeCellular, | 104 shill::kTypeCellular, |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 if (value < 0 || value >= static_cast<int>(arraysize(kConnectionTypes))) | 107 if (value < 0 || value >= static_cast<int>(arraysize(kConnectionTypes))) |
| 108 return nullptr; | 108 return nullptr; |
| 109 | 109 |
| 110 return base::MakeUnique<base::StringValue>(kConnectionTypes[value]); | 110 return base::MakeUnique<base::Value>(kConnectionTypes[value]); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy, | 113 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 114 PolicyMap* policies) { | 114 PolicyMap* policies) { |
| 115 if (policy.has_guest_mode_enabled()) { | 115 if (policy.has_guest_mode_enabled()) { |
| 116 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled()); | 116 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled()); |
| 117 if (container.has_guest_mode_enabled()) { | 117 if (container.has_guest_mode_enabled()) { |
| 118 policies->Set( | 118 policies->Set( |
| 119 key::kDeviceGuestModeEnabled, POLICY_LEVEL_MANDATORY, | 119 key::kDeviceGuestModeEnabled, POLICY_LEVEL_MANDATORY, |
| 120 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 120 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 entry_dict->SetIntegerWithoutPathExpansion( | 231 entry_dict->SetIntegerWithoutPathExpansion( |
| 232 chromeos::kAccountsPrefDeviceLocalAccountsKeyType, | 232 chromeos::kAccountsPrefDeviceLocalAccountsKeyType, |
| 233 DeviceLocalAccount::TYPE_PUBLIC_SESSION); | 233 DeviceLocalAccount::TYPE_PUBLIC_SESSION); |
| 234 } | 234 } |
| 235 account_list->Append(std::move(entry_dict)); | 235 account_list->Append(std::move(entry_dict)); |
| 236 } | 236 } |
| 237 policies->Set(key::kDeviceLocalAccounts, POLICY_LEVEL_MANDATORY, | 237 policies->Set(key::kDeviceLocalAccounts, POLICY_LEVEL_MANDATORY, |
| 238 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 238 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 239 std::move(account_list), nullptr); | 239 std::move(account_list), nullptr); |
| 240 if (container.has_auto_login_id()) { | 240 if (container.has_auto_login_id()) { |
| 241 policies->Set( | 241 policies->Set(key::kDeviceLocalAccountAutoLoginId, POLICY_LEVEL_MANDATORY, |
| 242 key::kDeviceLocalAccountAutoLoginId, POLICY_LEVEL_MANDATORY, | 242 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 243 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 243 base::MakeUnique<base::Value>(container.auto_login_id()), |
| 244 base::MakeUnique<base::StringValue>(container.auto_login_id()), | 244 nullptr); |
| 245 nullptr); | |
| 246 } | 245 } |
| 247 if (container.has_auto_login_delay()) { | 246 if (container.has_auto_login_delay()) { |
| 248 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, | 247 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, |
| 249 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 248 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 250 POLICY_SOURCE_CLOUD, | 249 POLICY_SOURCE_CLOUD, |
| 251 DecodeIntegerValue(container.auto_login_delay()), nullptr); | 250 DecodeIntegerValue(container.auto_login_delay()), nullptr); |
| 252 } | 251 } |
| 253 if (container.has_enable_auto_login_bailout()) { | 252 if (container.has_enable_auto_login_bailout()) { |
| 254 policies->Set( | 253 policies->Set( |
| 255 key::kDeviceLocalAccountAutoLoginBailoutEnabled, | 254 key::kDeviceLocalAccountAutoLoginBailoutEnabled, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 } | 349 } |
| 351 } | 350 } |
| 352 } | 351 } |
| 353 | 352 |
| 354 if (policy.has_login_screen_domain_auto_complete()) { | 353 if (policy.has_login_screen_domain_auto_complete()) { |
| 355 const em::LoginScreenDomainAutoCompleteProto& container( | 354 const em::LoginScreenDomainAutoCompleteProto& container( |
| 356 policy.login_screen_domain_auto_complete()); | 355 policy.login_screen_domain_auto_complete()); |
| 357 policies->Set(key::kDeviceLoginScreenDomainAutoComplete, | 356 policies->Set(key::kDeviceLoginScreenDomainAutoComplete, |
| 358 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 357 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 359 POLICY_SOURCE_CLOUD, | 358 POLICY_SOURCE_CLOUD, |
| 360 base::MakeUnique<base::StringValue>( | 359 base::MakeUnique<base::Value>( |
| 361 container.login_screen_domain_auto_complete()), | 360 container.login_screen_domain_auto_complete()), |
| 362 nullptr); | 361 nullptr); |
| 363 } | 362 } |
| 364 | 363 |
| 365 if (policy.has_login_screen_locales()) { | 364 if (policy.has_login_screen_locales()) { |
| 366 std::unique_ptr<base::ListValue> locales(new base::ListValue); | 365 std::unique_ptr<base::ListValue> locales(new base::ListValue); |
| 367 const em::LoginScreenLocalesProto& login_screen_locales( | 366 const em::LoginScreenLocalesProto& login_screen_locales( |
| 368 policy.login_screen_locales()); | 367 policy.login_screen_locales()); |
| 369 for (const auto& locale : login_screen_locales.login_screen_locales()) | 368 for (const auto& locale : login_screen_locales.login_screen_locales()) |
| 370 locales->AppendString(locale); | 369 locales->AppendString(locale); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 417 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 419 std::move(throttling_status), nullptr); | 418 std::move(throttling_status), nullptr); |
| 420 } | 419 } |
| 421 | 420 |
| 422 if (policy.has_open_network_configuration() && | 421 if (policy.has_open_network_configuration() && |
| 423 policy.open_network_configuration().has_open_network_configuration()) { | 422 policy.open_network_configuration().has_open_network_configuration()) { |
| 424 std::string config( | 423 std::string config( |
| 425 policy.open_network_configuration().open_network_configuration()); | 424 policy.open_network_configuration().open_network_configuration()); |
| 426 policies->Set(key::kDeviceOpenNetworkConfiguration, POLICY_LEVEL_MANDATORY, | 425 policies->Set(key::kDeviceOpenNetworkConfiguration, POLICY_LEVEL_MANDATORY, |
| 427 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 426 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 428 base::MakeUnique<base::StringValue>(config), nullptr); | 427 base::MakeUnique<base::Value>(config), nullptr); |
| 429 } | 428 } |
| 430 } | 429 } |
| 431 | 430 |
| 432 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy, | 431 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 433 PolicyMap* policies) { | 432 PolicyMap* policies) { |
| 434 if (policy.has_device_reporting()) { | 433 if (policy.has_device_reporting()) { |
| 435 const em::DeviceReportingProto& container(policy.device_reporting()); | 434 const em::DeviceReportingProto& container(policy.device_reporting()); |
| 436 if (container.has_report_version_info()) { | 435 if (container.has_report_version_info()) { |
| 437 policies->Set( | 436 policies->Set( |
| 438 key::kReportDeviceVersionInfo, POLICY_LEVEL_MANDATORY, | 437 key::kReportDeviceVersionInfo, POLICY_LEVEL_MANDATORY, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 } | 525 } |
| 527 | 526 |
| 528 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, | 527 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, |
| 529 PolicyMap* policies) { | 528 PolicyMap* policies) { |
| 530 if (policy.has_release_channel()) { | 529 if (policy.has_release_channel()) { |
| 531 const em::ReleaseChannelProto& container(policy.release_channel()); | 530 const em::ReleaseChannelProto& container(policy.release_channel()); |
| 532 if (container.has_release_channel()) { | 531 if (container.has_release_channel()) { |
| 533 std::string channel(container.release_channel()); | 532 std::string channel(container.release_channel()); |
| 534 policies->Set(key::kChromeOsReleaseChannel, POLICY_LEVEL_MANDATORY, | 533 policies->Set(key::kChromeOsReleaseChannel, POLICY_LEVEL_MANDATORY, |
| 535 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 534 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 536 base::MakeUnique<base::StringValue>(channel), nullptr); | 535 base::MakeUnique<base::Value>(channel), nullptr); |
| 537 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't | 536 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't |
| 538 // have to pass the channel in here, only ping the update engine to tell | 537 // have to pass the channel in here, only ping the update engine to tell |
| 539 // it to fetch the channel from the policy. | 538 // it to fetch the channel from the policy. |
| 540 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> | 539 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> |
| 541 SetChannel(channel, false); | 540 SetChannel(channel, false); |
| 542 } | 541 } |
| 543 if (container.has_release_channel_delegated()) { | 542 if (container.has_release_channel_delegated()) { |
| 544 policies->Set( | 543 policies->Set( |
| 545 key::kChromeOsReleaseChannelDelegated, POLICY_LEVEL_MANDATORY, | 544 key::kChromeOsReleaseChannelDelegated, POLICY_LEVEL_MANDATORY, |
| 546 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 545 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 547 base::MakeUnique<base::Value>(container.release_channel_delegated()), | 546 base::MakeUnique<base::Value>(container.release_channel_delegated()), |
| 548 nullptr); | 547 nullptr); |
| 549 } | 548 } |
| 550 } | 549 } |
| 551 | 550 |
| 552 if (policy.has_auto_update_settings()) { | 551 if (policy.has_auto_update_settings()) { |
| 553 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings()); | 552 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings()); |
| 554 if (container.has_update_disabled()) { | 553 if (container.has_update_disabled()) { |
| 555 policies->Set(key::kDeviceAutoUpdateDisabled, POLICY_LEVEL_MANDATORY, | 554 policies->Set(key::kDeviceAutoUpdateDisabled, POLICY_LEVEL_MANDATORY, |
| 556 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 555 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 557 base::MakeUnique<base::Value>(container.update_disabled()), | 556 base::MakeUnique<base::Value>(container.update_disabled()), |
| 558 nullptr); | 557 nullptr); |
| 559 } | 558 } |
| 560 | 559 |
| 561 if (container.has_target_version_prefix()) { | 560 if (container.has_target_version_prefix()) { |
| 562 policies->Set(key::kDeviceTargetVersionPrefix, POLICY_LEVEL_MANDATORY, | 561 policies->Set( |
| 563 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 562 key::kDeviceTargetVersionPrefix, POLICY_LEVEL_MANDATORY, |
| 564 base::MakeUnique<base::StringValue>( | 563 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 565 container.target_version_prefix()), | 564 base::MakeUnique<base::Value>(container.target_version_prefix()), |
| 566 nullptr); | 565 nullptr); |
| 567 } | 566 } |
| 568 | 567 |
| 569 // target_version_display_name is not actually a policy, but a display | 568 // target_version_display_name is not actually a policy, but a display |
| 570 // string for target_version_prefix, so we ignore it. | 569 // string for target_version_prefix, so we ignore it. |
| 571 | 570 |
| 572 if (container.has_scatter_factor_in_seconds()) { | 571 if (container.has_scatter_factor_in_seconds()) { |
| 573 // TODO(dcheng): Shouldn't this use DecodeIntegerValue? | 572 // TODO(dcheng): Shouldn't this use DecodeIntegerValue? |
| 574 policies->Set(key::kDeviceUpdateScatterFactor, POLICY_LEVEL_MANDATORY, | 573 policies->Set(key::kDeviceUpdateScatterFactor, POLICY_LEVEL_MANDATORY, |
| 575 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 574 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 576 base::MakeUnique<base::Value>(static_cast<int>( | 575 base::MakeUnique<base::Value>(static_cast<int>( |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 if (container.has_metrics_enabled()) { | 700 if (container.has_metrics_enabled()) { |
| 702 policies->Set(key::kDeviceMetricsReportingEnabled, POLICY_LEVEL_MANDATORY, | 701 policies->Set(key::kDeviceMetricsReportingEnabled, POLICY_LEVEL_MANDATORY, |
| 703 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 702 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 704 base::MakeUnique<base::Value>(container.metrics_enabled()), | 703 base::MakeUnique<base::Value>(container.metrics_enabled()), |
| 705 nullptr); | 704 nullptr); |
| 706 } | 705 } |
| 707 } | 706 } |
| 708 | 707 |
| 709 if (policy.has_system_timezone()) { | 708 if (policy.has_system_timezone()) { |
| 710 if (policy.system_timezone().has_timezone()) { | 709 if (policy.system_timezone().has_timezone()) { |
| 711 policies->Set(key::kSystemTimezone, POLICY_LEVEL_MANDATORY, | 710 policies->Set( |
| 712 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 711 key::kSystemTimezone, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 713 base::MakeUnique<base::StringValue>( | 712 POLICY_SOURCE_CLOUD, |
| 714 policy.system_timezone().timezone()), | 713 base::MakeUnique<base::Value>(policy.system_timezone().timezone()), |
| 715 nullptr); | 714 nullptr); |
| 716 } | 715 } |
| 717 | 716 |
| 718 if (policy.system_timezone().has_timezone_detection_type()) { | 717 if (policy.system_timezone().has_timezone_detection_type()) { |
| 719 std::unique_ptr<base::Value> value(DecodeIntegerValue( | 718 std::unique_ptr<base::Value> value(DecodeIntegerValue( |
| 720 policy.system_timezone().timezone_detection_type())); | 719 policy.system_timezone().timezone_detection_type())); |
| 721 if (value) { | 720 if (value) { |
| 722 policies->Set(key::kSystemTimezoneAutomaticDetection, | 721 policies->Set(key::kSystemTimezoneAutomaticDetection, |
| 723 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 722 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 724 POLICY_SOURCE_CLOUD, std::move(value), nullptr); | 723 POLICY_SOURCE_CLOUD, std::move(value), nullptr); |
| 725 } | 724 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 754 policies->Set(key::kUptimeLimit, POLICY_LEVEL_MANDATORY, | 753 policies->Set(key::kUptimeLimit, POLICY_LEVEL_MANDATORY, |
| 755 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 754 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 756 DecodeIntegerValue(container.uptime_limit()), nullptr); | 755 DecodeIntegerValue(container.uptime_limit()), nullptr); |
| 757 } | 756 } |
| 758 } | 757 } |
| 759 | 758 |
| 760 if (policy.has_start_up_flags()) { | 759 if (policy.has_start_up_flags()) { |
| 761 const em::StartUpFlagsProto& container(policy.start_up_flags()); | 760 const em::StartUpFlagsProto& container(policy.start_up_flags()); |
| 762 std::unique_ptr<base::ListValue> flags(new base::ListValue()); | 761 std::unique_ptr<base::ListValue> flags(new base::ListValue()); |
| 763 for (const auto& entry : container.flags()) | 762 for (const auto& entry : container.flags()) |
| 764 flags->Append(base::MakeUnique<base::StringValue>(entry)); | 763 flags->Append(base::MakeUnique<base::Value>(entry)); |
| 765 policies->Set(key::kDeviceStartUpFlags, POLICY_LEVEL_MANDATORY, | 764 policies->Set(key::kDeviceStartUpFlags, POLICY_LEVEL_MANDATORY, |
| 766 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, std::move(flags), | 765 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, std::move(flags), |
| 767 nullptr); | 766 nullptr); |
| 768 } | 767 } |
| 769 | 768 |
| 770 if (policy.has_variations_parameter()) { | 769 if (policy.has_variations_parameter()) { |
| 771 if (policy.variations_parameter().has_parameter()) { | 770 if (policy.variations_parameter().has_parameter()) { |
| 772 policies->Set(key::kDeviceVariationsRestrictParameter, | 771 policies->Set(key::kDeviceVariationsRestrictParameter, |
| 773 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 772 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 774 POLICY_SOURCE_CLOUD, | 773 POLICY_SOURCE_CLOUD, |
| 775 base::MakeUnique<base::StringValue>( | 774 base::MakeUnique<base::Value>( |
| 776 policy.variations_parameter().parameter()), | 775 policy.variations_parameter().parameter()), |
| 777 nullptr); | 776 nullptr); |
| 778 } | 777 } |
| 779 } | 778 } |
| 780 | 779 |
| 781 if (policy.has_attestation_settings()) { | 780 if (policy.has_attestation_settings()) { |
| 782 if (policy.attestation_settings().has_attestation_enabled()) { | 781 if (policy.attestation_settings().has_attestation_enabled()) { |
| 783 policies->Set(key::kAttestationEnabledForDevice, POLICY_LEVEL_MANDATORY, | 782 policies->Set(key::kAttestationEnabledForDevice, POLICY_LEVEL_MANDATORY, |
| 784 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 783 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 785 base::MakeUnique<base::Value>( | 784 base::MakeUnique<base::Value>( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 // Decode the various groups of policies. | 876 // Decode the various groups of policies. |
| 878 DecodeLoginPolicies(policy, policies); | 877 DecodeLoginPolicies(policy, policies); |
| 879 DecodeNetworkPolicies(policy, policies); | 878 DecodeNetworkPolicies(policy, policies); |
| 880 DecodeReportingPolicies(policy, policies); | 879 DecodeReportingPolicies(policy, policies); |
| 881 DecodeAutoUpdatePolicies(policy, policies); | 880 DecodeAutoUpdatePolicies(policy, policies); |
| 882 DecodeAccessibilityPolicies(policy, policies); | 881 DecodeAccessibilityPolicies(policy, policies); |
| 883 DecodeGenericPolicies(policy, policies); | 882 DecodeGenericPolicies(policy, policies); |
| 884 } | 883 } |
| 885 | 884 |
| 886 } // namespace policy | 885 } // namespace policy |
| OLD | NEW |