| Index: chrome/browser/policy/configuration_policy_handler_list_factory.cc
|
| diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
|
| index 2be349187658d11c21556b5b3aca82c891afcf04..e96cb7fadd51ac488d08bd8530fb738ffbf06e8e 100644
|
| --- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc
|
| +++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
|
| @@ -16,6 +16,7 @@
|
| #include "base/values.h"
|
| #include "build/build_config.h"
|
| #include "chrome/browser/net/disk_cache_dir_policy_handler.h"
|
| +#include "chrome/browser/net/safe_search_util.h"
|
| #include "chrome/browser/policy/file_selection_dialogs_policy_handler.h"
|
| #include "chrome/browser/policy/javascript_policy_handler.h"
|
| #include "chrome/browser/policy/managed_bookmarks_policy_handler.h"
|
| @@ -119,9 +120,9 @@ const PolicyToPreferenceMapEntry kSimplePolicyMap[] = {
|
| { key::kForceGoogleSafeSearch,
|
| prefs::kForceGoogleSafeSearch,
|
| base::Value::TYPE_BOOLEAN },
|
| - { key::kForceYouTubeSafetyMode,
|
| - prefs::kForceYouTubeSafetyMode,
|
| - base::Value::TYPE_BOOLEAN },
|
| + { key::kForceYouTubeRestrict,
|
| + prefs::kForceYouTubeRestrict,
|
| + base::Value::TYPE_INTEGER},
|
| { key::kPasswordManagerEnabled,
|
| password_manager::prefs::kPasswordManagerSavingEnabled,
|
| base::Value::TYPE_BOOLEAN },
|
| @@ -612,17 +613,31 @@ class ForceSafeSearchPolicyHandler : public TypeCheckingPolicyHandler {
|
| // ConfigurationPolicyHandler implementation:
|
| void ApplyPolicySettings(const PolicyMap& policies,
|
| PrefValueMap* prefs) override {
|
| - // If either of the new GoogleSafeSearch or YouTubeSafetyMode policies is
|
| - // defined, then this one should be ignored. crbug.com/476908
|
| - // Note: Those policies are declared in kSimplePolicyMap above.
|
| + // If either of the new ForceGoogleSafeSearch, ForceYouTubeSafetyMode or
|
| + // ForceYouTubeRestrict policies are defined, then this one should be
|
| + // ignored. crbug.com/476908, crbug.com/590478
|
| + // Note: Those policies are declared in kSimplePolicyMap above. except
|
| + // ForceYouTubeSafetyMode, which has been replaced by
|
| + // ForceYouTubeRestrict.
|
| if (policies.GetValue(key::kForceGoogleSafeSearch) ||
|
| - policies.GetValue(key::kForceYouTubeSafetyMode)) {
|
| + policies.GetValue(key::kForceYouTubeSafetyMode) ||
|
| + policies.GetValue(key::kForceYouTubeRestrict)) {
|
| return;
|
| }
|
| const base::Value* value = policies.GetValue(policy_name());
|
| if (value) {
|
| + bool enabled;
|
| prefs->SetValue(prefs::kForceGoogleSafeSearch, value->CreateDeepCopy());
|
| - prefs->SetValue(prefs::kForceYouTubeSafetyMode, value->CreateDeepCopy());
|
| +
|
| + // Note that ForceYouTubeRestrict is an int policy,
|
| + // we cannot simply deep copy value, which is a boolean.
|
| + if (value->GetAsBoolean(&enabled)) {
|
| + prefs->SetValue(
|
| + prefs::kForceYouTubeRestrict,
|
| + base::MakeUnique<base::FundamentalValue>(static_cast<int>(
|
| + enabled ? safe_search_util::YouTubeRestrictMode::MODERATE
|
| + : safe_search_util::YouTubeRestrictMode::OFF)));
|
| + }
|
| }
|
| }
|
|
|
| @@ -630,6 +645,36 @@ class ForceSafeSearchPolicyHandler : public TypeCheckingPolicyHandler {
|
| DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler);
|
| };
|
|
|
| +class ForceYouTubeSafetyModePolicyHandler : public TypeCheckingPolicyHandler {
|
| + public:
|
| + ForceYouTubeSafetyModePolicyHandler()
|
| + : TypeCheckingPolicyHandler(key::kForceYouTubeSafetyMode,
|
| + base::Value::TYPE_BOOLEAN) {}
|
| + ~ForceYouTubeSafetyModePolicyHandler() override {}
|
| +
|
| + // ConfigurationPolicyHandler implementation:
|
| + void ApplyPolicySettings(const PolicyMap& policies,
|
| + PrefValueMap* prefs) override {
|
| + // If only the deprecated ForceYouTubeSafetyMode policy is set,
|
| + // but not ForceYouTubeRestrict, set ForceYouTubeRestrict to Moderate.
|
| + if (policies.GetValue(key::kForceYouTubeRestrict))
|
| + return;
|
| +
|
| + const base::Value* value = policies.GetValue(policy_name());
|
| + bool enabled;
|
| + if (value && value->GetAsBoolean(&enabled)) {
|
| + prefs->SetValue(
|
| + prefs::kForceYouTubeRestrict,
|
| + base::MakeUnique<base::FundamentalValue>(static_cast<int>(
|
| + enabled ? safe_search_util::YouTubeRestrictMode::MODERATE
|
| + : safe_search_util::YouTubeRestrictMode::OFF)));
|
| + }
|
| + }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(ForceYouTubeSafetyModePolicyHandler);
|
| +};
|
| +
|
| #if defined(ENABLE_EXTENSIONS)
|
| void GetExtensionAllowedTypesMap(
|
| ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) {
|
| @@ -680,6 +725,8 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
|
| handlers->AddHandler(base::WrapUnique(new AutofillPolicyHandler()));
|
| handlers->AddHandler(base::WrapUnique(new DefaultSearchPolicyHandler()));
|
| handlers->AddHandler(base::WrapUnique(new ForceSafeSearchPolicyHandler()));
|
| + handlers->AddHandler(
|
| + base::WrapUnique(new ForceYouTubeSafetyModePolicyHandler()));
|
| handlers->AddHandler(base::WrapUnique(new IncognitoModePolicyHandler()));
|
| handlers->AddHandler(
|
| base::WrapUnique(new ManagedBookmarksPolicyHandler(chrome_schema)));
|
|
|