OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/policy/configuration_policy_handler_list_factory.h" | 5 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 const base::Value* value = policies.GetValue(policy_name()); | 672 const base::Value* value = policies.GetValue(policy_name()); |
673 if (value) { | 673 if (value) { |
674 bool enabled; | 674 bool enabled; |
675 prefs->SetValue(prefs::kForceGoogleSafeSearch, value->CreateDeepCopy()); | 675 prefs->SetValue(prefs::kForceGoogleSafeSearch, value->CreateDeepCopy()); |
676 | 676 |
677 // Note that ForceYouTubeRestrict is an int policy, we cannot simply deep | 677 // Note that ForceYouTubeRestrict is an int policy, we cannot simply deep |
678 // copy value, which is a boolean. | 678 // copy value, which is a boolean. |
679 if (value->GetAsBoolean(&enabled)) { | 679 if (value->GetAsBoolean(&enabled)) { |
680 prefs->SetValue( | 680 prefs->SetValue( |
681 prefs::kForceYouTubeRestrict, | 681 prefs::kForceYouTubeRestrict, |
682 base::MakeUnique<base::FundamentalValue>( | 682 base::MakeUnique<base::Value>( |
683 enabled ? safe_search_util::YOUTUBE_RESTRICT_MODERATE | 683 enabled ? safe_search_util::YOUTUBE_RESTRICT_MODERATE |
684 : safe_search_util::YOUTUBE_RESTRICT_OFF)); | 684 : safe_search_util::YOUTUBE_RESTRICT_OFF)); |
685 } | 685 } |
686 } | 686 } |
687 } | 687 } |
688 | 688 |
689 private: | 689 private: |
690 DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler); | 690 DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler); |
691 }; | 691 }; |
692 | 692 |
693 class ForceYouTubeSafetyModePolicyHandler : public TypeCheckingPolicyHandler { | 693 class ForceYouTubeSafetyModePolicyHandler : public TypeCheckingPolicyHandler { |
694 public: | 694 public: |
695 ForceYouTubeSafetyModePolicyHandler() | 695 ForceYouTubeSafetyModePolicyHandler() |
696 : TypeCheckingPolicyHandler(key::kForceYouTubeSafetyMode, | 696 : TypeCheckingPolicyHandler(key::kForceYouTubeSafetyMode, |
697 base::Value::Type::BOOLEAN) {} | 697 base::Value::Type::BOOLEAN) {} |
698 ~ForceYouTubeSafetyModePolicyHandler() override {} | 698 ~ForceYouTubeSafetyModePolicyHandler() override {} |
699 | 699 |
700 // ConfigurationPolicyHandler implementation: | 700 // ConfigurationPolicyHandler implementation: |
701 void ApplyPolicySettings(const PolicyMap& policies, | 701 void ApplyPolicySettings(const PolicyMap& policies, |
702 PrefValueMap* prefs) override { | 702 PrefValueMap* prefs) override { |
703 // If only the deprecated ForceYouTubeSafetyMode policy is set, | 703 // If only the deprecated ForceYouTubeSafetyMode policy is set, |
704 // but not ForceYouTubeRestrict, set ForceYouTubeRestrict to Moderate. | 704 // but not ForceYouTubeRestrict, set ForceYouTubeRestrict to Moderate. |
705 if (policies.GetValue(key::kForceYouTubeRestrict)) | 705 if (policies.GetValue(key::kForceYouTubeRestrict)) |
706 return; | 706 return; |
707 | 707 |
708 const base::Value* value = policies.GetValue(policy_name()); | 708 const base::Value* value = policies.GetValue(policy_name()); |
709 bool enabled; | 709 bool enabled; |
710 if (value && value->GetAsBoolean(&enabled)) { | 710 if (value && value->GetAsBoolean(&enabled)) { |
711 prefs->SetValue( | 711 prefs->SetValue(prefs::kForceYouTubeRestrict, |
712 prefs::kForceYouTubeRestrict, | 712 base::MakeUnique<base::Value>( |
713 base::MakeUnique<base::FundamentalValue>( | 713 enabled ? safe_search_util::YOUTUBE_RESTRICT_MODERATE |
714 enabled ? safe_search_util::YOUTUBE_RESTRICT_MODERATE | 714 : safe_search_util::YOUTUBE_RESTRICT_OFF)); |
715 : safe_search_util::YOUTUBE_RESTRICT_OFF)); | |
716 } | 715 } |
717 } | 716 } |
718 | 717 |
719 private: | 718 private: |
720 DISALLOW_COPY_AND_ASSIGN(ForceYouTubeSafetyModePolicyHandler); | 719 DISALLOW_COPY_AND_ASSIGN(ForceYouTubeSafetyModePolicyHandler); |
721 }; | 720 }; |
722 | 721 |
723 class BrowsingHistoryPolicyHandler : public TypeCheckingPolicyHandler { | 722 class BrowsingHistoryPolicyHandler : public TypeCheckingPolicyHandler { |
724 public: | 723 public: |
725 BrowsingHistoryPolicyHandler() | 724 BrowsingHistoryPolicyHandler() |
(...skipping 21 matching lines...) Expand all Loading... |
747 result) { | 746 result) { |
748 // Mapping from extension type names to Manifest::Type. | 747 // Mapping from extension type names to Manifest::Type. |
749 for (size_t index = 0; | 748 for (size_t index = 0; |
750 index < extensions::schema_constants::kAllowedTypesMapSize; | 749 index < extensions::schema_constants::kAllowedTypesMapSize; |
751 ++index) { | 750 ++index) { |
752 const extensions::schema_constants::AllowedTypesMapEntry& entry = | 751 const extensions::schema_constants::AllowedTypesMapEntry& entry = |
753 extensions::schema_constants::kAllowedTypesMap[index]; | 752 extensions::schema_constants::kAllowedTypesMap[index]; |
754 result->push_back( | 753 result->push_back( |
755 base::MakeUnique<StringMappingListPolicyHandler::MappingEntry>( | 754 base::MakeUnique<StringMappingListPolicyHandler::MappingEntry>( |
756 entry.name, std::unique_ptr<base::Value>( | 755 entry.name, std::unique_ptr<base::Value>( |
757 new base::FundamentalValue(entry.manifest_type)))); | 756 new base::Value(entry.manifest_type)))); |
758 } | 757 } |
759 } | 758 } |
760 | 759 |
761 // Piggy-back kDeveloperToolsDisabled set to true to also force-disable | 760 // Piggy-back kDeveloperToolsDisabled set to true to also force-disable |
762 // kExtensionsUIDeveloperMode. | 761 // kExtensionsUIDeveloperMode. |
763 class DevToolsExtensionsUIPolicyHandler : public TypeCheckingPolicyHandler { | 762 class DevToolsExtensionsUIPolicyHandler : public TypeCheckingPolicyHandler { |
764 public: | 763 public: |
765 DevToolsExtensionsUIPolicyHandler() | 764 DevToolsExtensionsUIPolicyHandler() |
766 : TypeCheckingPolicyHandler(key::kDeveloperToolsDisabled, | 765 : TypeCheckingPolicyHandler(key::kDeveloperToolsDisabled, |
767 base::Value::Type::BOOLEAN) {} | 766 base::Value::Type::BOOLEAN) {} |
768 ~DevToolsExtensionsUIPolicyHandler() override {} | 767 ~DevToolsExtensionsUIPolicyHandler() override {} |
769 | 768 |
770 // ConfigurationPolicyHandler implementation: | 769 // ConfigurationPolicyHandler implementation: |
771 void ApplyPolicySettings(const PolicyMap& policies, | 770 void ApplyPolicySettings(const PolicyMap& policies, |
772 PrefValueMap* prefs) override { | 771 PrefValueMap* prefs) override { |
773 const base::Value* value = policies.GetValue(policy_name()); | 772 const base::Value* value = policies.GetValue(policy_name()); |
774 bool developerToolsDisabled; | 773 bool developerToolsDisabled; |
775 if (value && value->GetAsBoolean(&developerToolsDisabled) && | 774 if (value && value->GetAsBoolean(&developerToolsDisabled) && |
776 developerToolsDisabled) { | 775 developerToolsDisabled) { |
777 prefs->SetValue(prefs::kExtensionsUIDeveloperMode, | 776 prefs->SetValue(prefs::kExtensionsUIDeveloperMode, |
778 base::MakeUnique<base::FundamentalValue>(false)); | 777 base::MakeUnique<base::Value>(false)); |
779 } | 778 } |
780 } | 779 } |
781 | 780 |
782 private: | 781 private: |
783 DISALLOW_COPY_AND_ASSIGN(DevToolsExtensionsUIPolicyHandler); | 782 DISALLOW_COPY_AND_ASSIGN(DevToolsExtensionsUIPolicyHandler); |
784 }; | 783 }; |
785 #endif | 784 #endif |
786 | 785 |
787 void GetDeprecatedFeaturesMap( | 786 void GetDeprecatedFeaturesMap( |
788 std::vector<std::unique_ptr<StringMappingListPolicyHandler::MappingEntry>>* | 787 std::vector<std::unique_ptr<StringMappingListPolicyHandler::MappingEntry>>* |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 #endif // defined(OS_CHROMEOS) | 1008 #endif // defined(OS_CHROMEOS) |
1010 | 1009 |
1011 #if BUILDFLAG(ENABLE_PLUGINS) | 1010 #if BUILDFLAG(ENABLE_PLUGINS) |
1012 handlers->AddHandler(base::MakeUnique<PluginPolicyHandler>()); | 1011 handlers->AddHandler(base::MakeUnique<PluginPolicyHandler>()); |
1013 #endif // BUILDFLAG(ENABLE_PLUGINS) | 1012 #endif // BUILDFLAG(ENABLE_PLUGINS) |
1014 | 1013 |
1015 return handlers; | 1014 return handlers; |
1016 } | 1015 } |
1017 | 1016 |
1018 } // namespace policy | 1017 } // namespace policy |
OLD | NEW |