| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 325 } |
| 326 | 326 |
| 327 if (policy.has_login_apps()) { | 327 if (policy.has_login_apps()) { |
| 328 const em::LoginAppsProto& login_apps_proto(policy.login_apps()); | 328 const em::LoginAppsProto& login_apps_proto(policy.login_apps()); |
| 329 std::unique_ptr<base::ListValue> login_apps(new base::ListValue); | 329 std::unique_ptr<base::ListValue> login_apps(new base::ListValue); |
| 330 for (const auto& login_app : login_apps_proto.login_apps()) | 330 for (const auto& login_app : login_apps_proto.login_apps()) |
| 331 login_apps->AppendString(login_app); | 331 login_apps->AppendString(login_app); |
| 332 policies->Set(key::kLoginApps, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 332 policies->Set(key::kLoginApps, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 333 POLICY_SOURCE_CLOUD, std::move(login_apps), nullptr); | 333 POLICY_SOURCE_CLOUD, std::move(login_apps), nullptr); |
| 334 } | 334 } |
| 335 |
| 336 if (policy.has_login_screen_power_management()) { |
| 337 const em::LoginScreenPowerManagementProto& container( |
| 338 policy.login_screen_power_management()); |
| 339 if (container.has_login_screen_power_management()) { |
| 340 std::unique_ptr<base::Value> decoded_json; |
| 341 decoded_json = DecodeJsonStringAndDropUnknownBySchema( |
| 342 container.login_screen_power_management(), |
| 343 key::kDeviceLoginScreenPowerManagement); |
| 344 if (decoded_json) { |
| 345 policies->Set(key::kDeviceLoginScreenPowerManagement, |
| 346 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 347 POLICY_SOURCE_CLOUD, std::move(decoded_json), nullptr); |
| 348 } |
| 349 } |
| 350 } |
| 351 |
| 352 if (policy.has_login_screen_domain_auto_complete()) { |
| 353 const em::LoginScreenDomainAutoCompleteProto& container( |
| 354 policy.login_screen_domain_auto_complete()); |
| 355 policies->Set(key::kDeviceLoginScreenDomainAutoComplete, |
| 356 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 357 POLICY_SOURCE_CLOUD, |
| 358 base::MakeUnique<base::StringValue>( |
| 359 container.login_screen_domain_auto_complete()), |
| 360 nullptr); |
| 361 } |
| 362 |
| 363 if (policy.has_login_screen_locales()) { |
| 364 std::unique_ptr<base::ListValue> locales(new base::ListValue); |
| 365 const em::LoginScreenLocalesProto& login_screen_locales( |
| 366 policy.login_screen_locales()); |
| 367 for (const auto& locale : login_screen_locales.login_screen_locales()) |
| 368 locales->AppendString(locale); |
| 369 policies->Set(key::kDeviceLoginScreenLocales, POLICY_LEVEL_MANDATORY, |
| 370 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, std::move(locales), |
| 371 nullptr); |
| 372 } |
| 373 |
| 374 if (policy.has_login_screen_input_methods()) { |
| 375 std::unique_ptr<base::ListValue> input_methods(new base::ListValue); |
| 376 const em::LoginScreenInputMethodsProto& login_screen_input_methods( |
| 377 policy.login_screen_input_methods()); |
| 378 for (const auto& input_method : |
| 379 login_screen_input_methods.login_screen_input_methods()) |
| 380 input_methods->AppendString(input_method); |
| 381 policies->Set(key::kDeviceLoginScreenInputMethods, POLICY_LEVEL_MANDATORY, |
| 382 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 383 std::move(input_methods), nullptr); |
| 384 } |
| 335 } | 385 } |
| 336 | 386 |
| 337 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, | 387 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 338 PolicyMap* policies) { | 388 PolicyMap* policies) { |
| 339 if (policy.has_data_roaming_enabled()) { | 389 if (policy.has_data_roaming_enabled()) { |
| 340 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); | 390 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); |
| 341 if (container.has_data_roaming_enabled()) { | 391 if (container.has_data_roaming_enabled()) { |
| 342 policies->Set(key::kDeviceDataRoamingEnabled, POLICY_LEVEL_MANDATORY, | 392 policies->Set(key::kDeviceDataRoamingEnabled, POLICY_LEVEL_MANDATORY, |
| 343 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 393 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 344 base::MakeUnique<base::FundamentalValue>( | 394 base::MakeUnique<base::FundamentalValue>( |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 if (policy.attestation_settings().has_content_protection_enabled()) { | 796 if (policy.attestation_settings().has_content_protection_enabled()) { |
| 747 policies->Set( | 797 policies->Set( |
| 748 key::kAttestationForContentProtectionEnabled, POLICY_LEVEL_MANDATORY, | 798 key::kAttestationForContentProtectionEnabled, POLICY_LEVEL_MANDATORY, |
| 749 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 799 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 750 base::MakeUnique<base::FundamentalValue>( | 800 base::MakeUnique<base::FundamentalValue>( |
| 751 policy.attestation_settings().content_protection_enabled()), | 801 policy.attestation_settings().content_protection_enabled()), |
| 752 nullptr); | 802 nullptr); |
| 753 } | 803 } |
| 754 } | 804 } |
| 755 | 805 |
| 756 if (policy.has_login_screen_power_management()) { | |
| 757 const em::LoginScreenPowerManagementProto& container( | |
| 758 policy.login_screen_power_management()); | |
| 759 if (container.has_login_screen_power_management()) { | |
| 760 std::unique_ptr<base::Value> decoded_json; | |
| 761 decoded_json = DecodeJsonStringAndDropUnknownBySchema( | |
| 762 container.login_screen_power_management(), | |
| 763 key::kDeviceLoginScreenPowerManagement); | |
| 764 if (decoded_json) { | |
| 765 policies->Set(key::kDeviceLoginScreenPowerManagement, | |
| 766 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | |
| 767 POLICY_SOURCE_CLOUD, std::move(decoded_json), nullptr); | |
| 768 } | |
| 769 } | |
| 770 } | |
| 771 | |
| 772 if (policy.has_system_settings()) { | 806 if (policy.has_system_settings()) { |
| 773 const em::SystemSettingsProto& container(policy.system_settings()); | 807 const em::SystemSettingsProto& container(policy.system_settings()); |
| 774 if (container.has_block_devmode()) { | 808 if (container.has_block_devmode()) { |
| 775 policies->Set( | 809 policies->Set( |
| 776 key::kDeviceBlockDevmode, POLICY_LEVEL_MANDATORY, | 810 key::kDeviceBlockDevmode, POLICY_LEVEL_MANDATORY, |
| 777 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 811 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 778 base::MakeUnique<base::FundamentalValue>(container.block_devmode()), | 812 base::MakeUnique<base::FundamentalValue>(container.block_devmode()), |
| 779 nullptr); | 813 nullptr); |
| 780 } | 814 } |
| 781 } | 815 } |
| 782 | 816 |
| 783 if (policy.has_extension_cache_size()) { | 817 if (policy.has_extension_cache_size()) { |
| 784 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size()); | 818 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size()); |
| 785 if (container.has_extension_cache_size()) { | 819 if (container.has_extension_cache_size()) { |
| 786 policies->Set(key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY, | 820 policies->Set(key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY, |
| 787 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 821 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 788 DecodeIntegerValue(container.extension_cache_size()), | 822 DecodeIntegerValue(container.extension_cache_size()), |
| 789 nullptr); | 823 nullptr); |
| 790 } | 824 } |
| 791 } | 825 } |
| 792 | 826 |
| 793 if (policy.has_login_screen_domain_auto_complete()) { | |
| 794 const em::LoginScreenDomainAutoCompleteProto& container( | |
| 795 policy.login_screen_domain_auto_complete()); | |
| 796 policies->Set(key::kDeviceLoginScreenDomainAutoComplete, | |
| 797 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | |
| 798 POLICY_SOURCE_CLOUD, | |
| 799 base::MakeUnique<base::StringValue>( | |
| 800 container.login_screen_domain_auto_complete()), | |
| 801 nullptr); | |
| 802 } | |
| 803 | |
| 804 if (policy.has_display_rotation_default()) { | 827 if (policy.has_display_rotation_default()) { |
| 805 const em::DisplayRotationDefaultProto& container( | 828 const em::DisplayRotationDefaultProto& container( |
| 806 policy.display_rotation_default()); | 829 policy.display_rotation_default()); |
| 807 policies->Set(key::kDisplayRotationDefault, POLICY_LEVEL_MANDATORY, | 830 policies->Set(key::kDisplayRotationDefault, POLICY_LEVEL_MANDATORY, |
| 808 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, | 831 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, |
| 809 DecodeIntegerValue(container.display_rotation_default()), | 832 DecodeIntegerValue(container.display_rotation_default()), |
| 810 nullptr); | 833 nullptr); |
| 811 } | 834 } |
| 812 | 835 |
| 813 if (policy.has_usb_detachable_whitelist()) { | 836 if (policy.has_usb_detachable_whitelist()) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 // Decode the various groups of policies. | 885 // Decode the various groups of policies. |
| 863 DecodeLoginPolicies(policy, policies); | 886 DecodeLoginPolicies(policy, policies); |
| 864 DecodeNetworkPolicies(policy, policies); | 887 DecodeNetworkPolicies(policy, policies); |
| 865 DecodeReportingPolicies(policy, policies); | 888 DecodeReportingPolicies(policy, policies); |
| 866 DecodeAutoUpdatePolicies(policy, policies); | 889 DecodeAutoUpdatePolicies(policy, policies); |
| 867 DecodeAccessibilityPolicies(policy, policies); | 890 DecodeAccessibilityPolicies(policy, policies); |
| 868 DecodeGenericPolicies(policy, policies); | 891 DecodeGenericPolicies(policy, policies); |
| 869 } | 892 } |
| 870 | 893 |
| 871 } // namespace policy | 894 } // namespace policy |
| OLD | NEW |