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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "chrome/browser/net/disk_cache_dir_policy_handler.h" | 18 #include "chrome/browser/net/disk_cache_dir_policy_handler.h" |
19 #include "chrome/browser/net/safe_search_util.h" | |
19 #include "chrome/browser/policy/file_selection_dialogs_policy_handler.h" | 20 #include "chrome/browser/policy/file_selection_dialogs_policy_handler.h" |
20 #include "chrome/browser/policy/javascript_policy_handler.h" | 21 #include "chrome/browser/policy/javascript_policy_handler.h" |
21 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h" | 22 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h" |
22 #include "chrome/browser/policy/network_prediction_policy_handler.h" | 23 #include "chrome/browser/policy/network_prediction_policy_handler.h" |
23 #include "chrome/browser/profiles/incognito_mode_policy_handler.h" | 24 #include "chrome/browser/profiles/incognito_mode_policy_handler.h" |
24 #include "chrome/browser/sessions/restore_on_startup_policy_handler.h" | 25 #include "chrome/browser/sessions/restore_on_startup_policy_handler.h" |
25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/features.h" | 27 #include "chrome/common/features.h" |
27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
28 #include "components/bookmarks/common/bookmark_pref_names.h" | 29 #include "components/bookmarks/common/bookmark_pref_names.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 base::Value::TYPE_BOOLEAN }, | 113 base::Value::TYPE_BOOLEAN }, |
113 { key::kPacHttpsUrlStrippingEnabled, | 114 { key::kPacHttpsUrlStrippingEnabled, |
114 prefs::kPacHttpsUrlStrippingEnabled, | 115 prefs::kPacHttpsUrlStrippingEnabled, |
115 base::Value::TYPE_BOOLEAN }, | 116 base::Value::TYPE_BOOLEAN }, |
116 { key::kSafeBrowsingEnabled, | 117 { key::kSafeBrowsingEnabled, |
117 prefs::kSafeBrowsingEnabled, | 118 prefs::kSafeBrowsingEnabled, |
118 base::Value::TYPE_BOOLEAN }, | 119 base::Value::TYPE_BOOLEAN }, |
119 { key::kForceGoogleSafeSearch, | 120 { key::kForceGoogleSafeSearch, |
120 prefs::kForceGoogleSafeSearch, | 121 prefs::kForceGoogleSafeSearch, |
121 base::Value::TYPE_BOOLEAN }, | 122 base::Value::TYPE_BOOLEAN }, |
122 { key::kForceYouTubeSafetyMode, | 123 { key::kForceYouTubeRestrict, |
123 prefs::kForceYouTubeSafetyMode, | 124 prefs::kForceYouTubeRestrict, |
124 base::Value::TYPE_BOOLEAN }, | 125 base::Value::TYPE_INTEGER}, |
125 { key::kPasswordManagerEnabled, | 126 { key::kPasswordManagerEnabled, |
126 password_manager::prefs::kPasswordManagerSavingEnabled, | 127 password_manager::prefs::kPasswordManagerSavingEnabled, |
127 base::Value::TYPE_BOOLEAN }, | 128 base::Value::TYPE_BOOLEAN }, |
128 { key::kPrintingEnabled, | 129 { key::kPrintingEnabled, |
129 prefs::kPrintingEnabled, | 130 prefs::kPrintingEnabled, |
130 base::Value::TYPE_BOOLEAN }, | 131 base::Value::TYPE_BOOLEAN }, |
131 { key::kDisablePrintPreview, | 132 { key::kDisablePrintPreview, |
132 prefs::kPrintPreviewDisabled, | 133 prefs::kPrintPreviewDisabled, |
133 base::Value::TYPE_BOOLEAN }, | 134 base::Value::TYPE_BOOLEAN }, |
134 { key::kDefaultPrinterSelection, | 135 { key::kDefaultPrinterSelection, |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 class ForceSafeSearchPolicyHandler : public TypeCheckingPolicyHandler { | 609 class ForceSafeSearchPolicyHandler : public TypeCheckingPolicyHandler { |
609 public: | 610 public: |
610 ForceSafeSearchPolicyHandler() | 611 ForceSafeSearchPolicyHandler() |
611 : TypeCheckingPolicyHandler(key::kForceSafeSearch, | 612 : TypeCheckingPolicyHandler(key::kForceSafeSearch, |
612 base::Value::TYPE_BOOLEAN) {} | 613 base::Value::TYPE_BOOLEAN) {} |
613 ~ForceSafeSearchPolicyHandler() override {} | 614 ~ForceSafeSearchPolicyHandler() override {} |
614 | 615 |
615 // ConfigurationPolicyHandler implementation: | 616 // ConfigurationPolicyHandler implementation: |
616 void ApplyPolicySettings(const PolicyMap& policies, | 617 void ApplyPolicySettings(const PolicyMap& policies, |
617 PrefValueMap* prefs) override { | 618 PrefValueMap* prefs) override { |
618 // If either of the new GoogleSafeSearch or YouTubeSafetyMode policies is | 619 // If either of the new ForceGoogleSafeSearch, ForceYouTubeSafetyMode or |
619 // defined, then this one should be ignored. crbug.com/476908 | 620 // ForceYouTubeRestrict policies are defined, then this one should be |
620 // Note: Those policies are declared in kSimplePolicyMap above. | 621 // ignored. crbug.com/476908, crbug.com/590478 |
622 // Note: Those policies are declared in kSimplePolicyMap above. except | |
Thiemo Nagel
2016/10/05 17:38:14
Nit: Since you're continuing with small caps, the
ljusten (tachyonic)
2016/10/06 10:14:45
Done.
| |
623 // ForceYouTubeSafetyMode, which has been replaced by | |
Thiemo Nagel
2016/10/05 17:38:14
Nit: I'd suggest to not indent inside the comment,
ljusten (tachyonic)
2016/10/06 10:14:45
Done.
| |
624 // ForceYouTubeRestrict. | |
621 if (policies.GetValue(key::kForceGoogleSafeSearch) || | 625 if (policies.GetValue(key::kForceGoogleSafeSearch) || |
Thiemo Nagel
2016/10/05 17:38:14
As I read the code, the combination of ForceSafeSe
ljusten (tachyonic)
2016/10/06 10:14:45
This is correct, see crbug.com/476908. As soon as
Thiemo Nagel
2016/10/06 14:05:57
Alright. Thanks for updating the CL description t
| |
622 policies.GetValue(key::kForceYouTubeSafetyMode)) { | 626 policies.GetValue(key::kForceYouTubeSafetyMode) || |
627 policies.GetValue(key::kForceYouTubeRestrict)) { | |
623 return; | 628 return; |
624 } | 629 } |
625 const base::Value* value = policies.GetValue(policy_name()); | 630 const base::Value* value = policies.GetValue(policy_name()); |
626 if (value) { | 631 if (value) { |
632 bool enabled; | |
627 prefs->SetValue(prefs::kForceGoogleSafeSearch, value->CreateDeepCopy()); | 633 prefs->SetValue(prefs::kForceGoogleSafeSearch, value->CreateDeepCopy()); |
628 prefs->SetValue(prefs::kForceYouTubeSafetyMode, value->CreateDeepCopy()); | 634 |
635 // Note that ForceYouTubeRestrict is an int policy, | |
Thiemo Nagel
2016/10/05 17:38:14
Nit: Please wrap comments at 80 characters.
ljusten (tachyonic)
2016/10/06 10:14:45
Done.
| |
636 // we cannot simply deep copy value, which is a boolean. | |
637 if (value->GetAsBoolean(&enabled)) { | |
638 prefs->SetValue( | |
639 prefs::kForceYouTubeRestrict, | |
640 base::MakeUnique<base::FundamentalValue>(static_cast<int>( | |
641 enabled ? safe_search_util::YouTubeRestrictMode::kModerate | |
642 : safe_search_util::YouTubeRestrictMode::kOff))); | |
643 } | |
629 } | 644 } |
630 } | 645 } |
631 | 646 |
632 private: | 647 private: |
633 DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler); | 648 DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler); |
634 }; | 649 }; |
635 | 650 |
651 class ForceYouTubeSafetyModePolicyHandler : public TypeCheckingPolicyHandler { | |
652 public: | |
653 ForceYouTubeSafetyModePolicyHandler() | |
654 : TypeCheckingPolicyHandler(key::kForceYouTubeSafetyMode, | |
655 base::Value::TYPE_BOOLEAN) {} | |
656 ~ForceYouTubeSafetyModePolicyHandler() override {} | |
657 | |
658 // ConfigurationPolicyHandler implementation: | |
659 void ApplyPolicySettings(const PolicyMap& policies, | |
660 PrefValueMap* prefs) override { | |
661 // If only the deprecated ForceYouTubeSafetyMode policy is set, | |
662 // but not ForceYouTubeRestrict, set ForceYouTubeRestrict to Moderate. | |
663 if (policies.GetValue(key::kForceYouTubeRestrict)) | |
664 return; | |
665 | |
666 const base::Value* value = policies.GetValue(policy_name()); | |
667 bool enabled; | |
668 if (value && value->GetAsBoolean(&enabled)) { | |
669 prefs->SetValue( | |
670 prefs::kForceYouTubeRestrict, | |
671 base::MakeUnique<base::FundamentalValue>(static_cast<int>( | |
672 enabled ? safe_search_util::YouTubeRestrictMode::kModerate | |
673 : safe_search_util::YouTubeRestrictMode::kOff))); | |
674 } | |
675 } | |
676 | |
677 private: | |
678 DISALLOW_COPY_AND_ASSIGN(ForceYouTubeSafetyModePolicyHandler); | |
679 }; | |
680 | |
636 #if defined(ENABLE_EXTENSIONS) | 681 #if defined(ENABLE_EXTENSIONS) |
637 void GetExtensionAllowedTypesMap( | 682 void GetExtensionAllowedTypesMap( |
638 ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) { | 683 ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) { |
639 // Mapping from extension type names to Manifest::Type. | 684 // Mapping from extension type names to Manifest::Type. |
640 for (size_t index = 0; | 685 for (size_t index = 0; |
641 index < extensions::schema_constants::kAllowedTypesMapSize; | 686 index < extensions::schema_constants::kAllowedTypesMapSize; |
642 ++index) { | 687 ++index) { |
643 const extensions::schema_constants::AllowedTypesMapEntry& entry = | 688 const extensions::schema_constants::AllowedTypesMapEntry& entry = |
644 extensions::schema_constants::kAllowedTypesMap[index]; | 689 extensions::schema_constants::kAllowedTypesMap[index]; |
645 result->push_back(new StringMappingListPolicyHandler::MappingEntry( | 690 result->push_back(new StringMappingListPolicyHandler::MappingEntry( |
(...skipping 30 matching lines...) Expand all Loading... | |
676 base::Bind(&GetChromePolicyDetails))); | 721 base::Bind(&GetChromePolicyDetails))); |
677 for (size_t i = 0; i < arraysize(kSimplePolicyMap); ++i) { | 722 for (size_t i = 0; i < arraysize(kSimplePolicyMap); ++i) { |
678 handlers->AddHandler(base::MakeUnique<SimplePolicyHandler>( | 723 handlers->AddHandler(base::MakeUnique<SimplePolicyHandler>( |
679 kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path, | 724 kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path, |
680 kSimplePolicyMap[i].value_type)); | 725 kSimplePolicyMap[i].value_type)); |
681 } | 726 } |
682 | 727 |
683 handlers->AddHandler(base::MakeUnique<AutofillPolicyHandler>()); | 728 handlers->AddHandler(base::MakeUnique<AutofillPolicyHandler>()); |
684 handlers->AddHandler(base::MakeUnique<DefaultSearchPolicyHandler>()); | 729 handlers->AddHandler(base::MakeUnique<DefaultSearchPolicyHandler>()); |
685 handlers->AddHandler(base::MakeUnique<ForceSafeSearchPolicyHandler>()); | 730 handlers->AddHandler(base::MakeUnique<ForceSafeSearchPolicyHandler>()); |
731 handlers->AddHandler(base::MakeUnique<ForceYouTubeSafetyModePolicyHandler>()); | |
686 handlers->AddHandler(base::MakeUnique<IncognitoModePolicyHandler>()); | 732 handlers->AddHandler(base::MakeUnique<IncognitoModePolicyHandler>()); |
687 handlers->AddHandler( | 733 handlers->AddHandler( |
688 base::MakeUnique<ManagedBookmarksPolicyHandler>(chrome_schema)); | 734 base::MakeUnique<ManagedBookmarksPolicyHandler>(chrome_schema)); |
689 handlers->AddHandler(base::MakeUnique<ProxyPolicyHandler>()); | 735 handlers->AddHandler(base::MakeUnique<ProxyPolicyHandler>()); |
690 handlers->AddHandler(base::MakeUnique<URLBlacklistPolicyHandler>()); | 736 handlers->AddHandler(base::MakeUnique<URLBlacklistPolicyHandler>()); |
691 | 737 |
692 handlers->AddHandler(base::MakeUnique<SimpleSchemaValidatingPolicyHandler>( | 738 handlers->AddHandler(base::MakeUnique<SimpleSchemaValidatingPolicyHandler>( |
693 key::kCertificateTransparencyEnforcementDisabledForUrls, | 739 key::kCertificateTransparencyEnforcementDisabledForUrls, |
694 certificate_transparency::prefs::kCTExcludedHosts, chrome_schema, | 740 certificate_transparency::prefs::kCTExcludedHosts, chrome_schema, |
695 SCHEMA_STRICT, SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED, | 741 SCHEMA_STRICT, SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED))); | 927 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED))); |
882 handlers->AddHandler( | 928 handlers->AddHandler( |
883 base::MakeUnique<chromeos::KeyPermissionsPolicyHandler>(chrome_schema)); | 929 base::MakeUnique<chromeos::KeyPermissionsPolicyHandler>(chrome_schema)); |
884 handlers->AddHandler(base::WrapUnique(new DefaultGeolocationPolicyHandler())); | 930 handlers->AddHandler(base::WrapUnique(new DefaultGeolocationPolicyHandler())); |
885 #endif // defined(OS_CHROMEOS) | 931 #endif // defined(OS_CHROMEOS) |
886 | 932 |
887 return handlers; | 933 return handlers; |
888 } | 934 } |
889 | 935 |
890 } // namespace policy | 936 } // namespace policy |
OLD | NEW |