Commit ecaf0275 authored by Julian Pastarmov's avatar Julian Pastarmov Committed by Commit Bot

Revert "Merge old and new list policies that were renamed"

This reverts commit b53e31ad.

Reason for revert: Crashes on Canary https://crbug.com/1148731

Original change's description:
> Merge old and new list policies that were renamed
>
> This change moves migrating of renamed policies from the PolicyHandler
> to a PolicyMigrator that happens right after the PolicyMerger has run.
> This guarantees that list policies can be properly merged between
> sources even if different sources provide different naming.
>
> BUG=1138572
> TEST=browser_tests:PolicyPrefsTest.PolicyToPrefsMapping
>
> Change-Id: Ibe335176ef52dabbe09c076ba57ae04d1c67c1c6
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2507771
> Commit-Queue: Julian Pastarmov <pastarmovj@chromium.org>
> Reviewed-by: Owen Min <zmin@chromium.org>
> Reviewed-by: Yann Dago <ydago@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#826903}

TBR=pastarmovj@chromium.org,zmin@chromium.org,ydago@chromium.org

Change-Id: I550446cbe736502003862ea9965b2277306b0890
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1138572
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536875Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Commit-Queue: Julian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827231}
parent 804f0bbd
...@@ -138,7 +138,7 @@ std::string GetTestPolicy(const char* homepage, int key_version) { ...@@ -138,7 +138,7 @@ std::string GetTestPolicy(const char* homepage, int key_version) {
" \"mandatory\": {" " \"mandatory\": {"
" \"ShowHomeButton\": true," " \"ShowHomeButton\": true,"
" \"RestoreOnStartup\": 4," " \"RestoreOnStartup\": 4,"
" \"URLBlocklist\": [ \"dev.chromium.org\", \"youtube.com\" ]," " \"URLBlacklist\": [ \"dev.chromium.org\", \"youtube.com\" ],"
" \"MaxInvalidationFetchDelay\": 1000" " \"MaxInvalidationFetchDelay\": 1000"
" }," " },"
" \"recommended\": {" " \"recommended\": {"
...@@ -167,7 +167,7 @@ void GetExpectedTestPolicy(PolicyMap* expected, const char* homepage) { ...@@ -167,7 +167,7 @@ void GetExpectedTestPolicy(PolicyMap* expected, const char* homepage) {
base::ListValue list; base::ListValue list;
list.AppendString("dev.chromium.org"); list.AppendString("dev.chromium.org");
list.AppendString("youtube.com"); list.AppendString("youtube.com");
expected->Set(key::kURLBlocklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, expected->Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
POLICY_SOURCE_CLOUD, list.Clone(), nullptr); POLICY_SOURCE_CLOUD, list.Clone(), nullptr);
expected->Set(key::kMaxInvalidationFetchDelay, POLICY_LEVEL_MANDATORY, expected->Set(key::kMaxInvalidationFetchDelay, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, base::Value(1000), POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, base::Value(1000),
......
...@@ -1447,17 +1447,26 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1447,17 +1447,26 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
key::kAuthNegotiateDelegateAllowlist, key::kAuthNegotiateDelegateAllowlist,
prefs::kAuthNegotiateDelegateAllowlist, base::Value::Type::STRING))); prefs::kAuthNegotiateDelegateAllowlist, base::Value::Type::STRING)));
handlers->AddHandler(std::make_unique<SimplePolicyHandler>( handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
key::kSafeBrowsingAllowlistDomains, prefs::kSafeBrowsingWhitelistDomains, std::make_unique<SimplePolicyHandler>(
base::Value::Type::LIST)); key::kSafeBrowsingWhitelistDomains,
prefs::kSafeBrowsingWhitelistDomains, base::Value::Type::LIST),
std::make_unique<SimplePolicyHandler>(
key::kSafeBrowsingAllowlistDomains,
prefs::kSafeBrowsingWhitelistDomains, base::Value::Type::LIST)));
handlers->AddHandler(std::make_unique<syncer::SyncPolicyHandler>()); handlers->AddHandler(std::make_unique<syncer::SyncPolicyHandler>());
handlers->AddHandler(std::make_unique<BrowsingHistoryPolicyHandler>()); handlers->AddHandler(std::make_unique<BrowsingHistoryPolicyHandler>());
handlers->AddHandler( handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
std::make_unique<URLBlocklistPolicyHandler>(key::kURLBlocklist)); std::make_unique<URLBlocklistPolicyHandler>(key::kURLBlacklist),
handlers->AddHandler(std::make_unique<SimplePolicyHandler>( std::make_unique<URLBlocklistPolicyHandler>(key::kURLBlocklist)));
key::kURLAllowlist, policy_prefs::kUrlWhitelist, handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
base::Value::Type::LIST)); std::make_unique<SimplePolicyHandler>(key::kURLWhitelist,
policy_prefs::kUrlWhitelist,
base::Value::Type::LIST),
std::make_unique<SimplePolicyHandler>(key::kURLAllowlist,
policy_prefs::kUrlWhitelist,
base::Value::Type::LIST)));
handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>( handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>(
key::kSafeBrowsingExtendedReportingEnabled, key::kSafeBrowsingExtendedReportingEnabled,
prefs::kSafeBrowsingScoutReportingEnabled, chrome_schema, prefs::kSafeBrowsingScoutReportingEnabled, chrome_schema,
...@@ -1484,9 +1493,13 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1484,9 +1493,13 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED, SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED,
SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED)); SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED));
handlers->AddHandler(std::make_unique<SimplePolicyHandler>( handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
key::kAutoplayAllowlist, prefs::kAutoplayWhitelist, std::make_unique<SimplePolicyHandler>(key::kAutoplayWhitelist,
base::Value::Type::LIST)); prefs::kAutoplayWhitelist,
base::Value::Type::LIST),
std::make_unique<SimplePolicyHandler>(key::kAutoplayAllowlist,
prefs::kAutoplayWhitelist,
base::Value::Type::LIST)));
// Handlers for policies with embedded JSON strings. These handlers are very // Handlers for policies with embedded JSON strings. These handlers are very
// lenient - as long as the root value is of the right type, they only display // lenient - as long as the root value is of the right type, they only display
...@@ -1608,13 +1621,21 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1608,13 +1621,21 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
std::move(screen_lock_legacy_policies), std::move(screen_lock_legacy_policies),
std::make_unique<ScreenLockDelayPolicyHandler>(chrome_schema))); std::make_unique<ScreenLockDelayPolicyHandler>(chrome_schema)));
handlers->AddHandler(std::make_unique<extensions::ExtensionListPolicyHandler>( handlers->AddHandler(std::make_unique<policy::SimpleDeprecatingPolicyHandler>(
std::make_unique<extensions::ExtensionListPolicyHandler>(
key::kAttestationExtensionAllowlist, key::kAttestationExtensionAllowlist,
prefs::kAttestationExtensionAllowlist, false)); prefs::kAttestationExtensionAllowlist, false),
std::make_unique<extensions::ExtensionListPolicyHandler>(
key::kAttestationExtensionWhitelist,
prefs::kAttestationExtensionAllowlist, false)));
handlers->AddHandler(std::make_unique<SimplePolicyHandler>( handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
key::kQuickUnlockModeAllowlist, prefs::kQuickUnlockModeAllowlist, std::make_unique<SimplePolicyHandler>(key::kQuickUnlockModeAllowlist,
base::Value::Type::LIST)); prefs::kQuickUnlockModeAllowlist,
base::Value::Type::LIST),
std::make_unique<SimplePolicyHandler>(key::kQuickUnlockModeWhitelist,
prefs::kQuickUnlockModeAllowlist,
base::Value::Type::LIST)));
handlers->AddHandler(base::WrapUnique( handlers->AddHandler(base::WrapUnique(
NetworkConfigurationPolicyHandler::CreateForDevicePolicy())); NetworkConfigurationPolicyHandler::CreateForDevicePolicy()));
...@@ -1681,12 +1702,20 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1681,12 +1702,20 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
std::make_unique<SimplePolicyHandler>( std::make_unique<SimplePolicyHandler>(
key::kPrintersBulkAccessMode, prefs::kRecommendedPrintersAccessMode, key::kPrintersBulkAccessMode, prefs::kRecommendedPrintersAccessMode,
base::Value::Type::INTEGER))); base::Value::Type::INTEGER)));
handlers->AddHandler(std::make_unique<SimplePolicyHandler>( handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
std::make_unique<SimplePolicyHandler>(
key::kNativePrintersBulkBlacklist,
prefs::kRecommendedPrintersBlocklist, base::Value::Type::LIST),
std::make_unique<SimplePolicyHandler>(
key::kPrintersBulkBlocklist, prefs::kRecommendedPrintersBlocklist, key::kPrintersBulkBlocklist, prefs::kRecommendedPrintersBlocklist,
base::Value::Type::LIST)); base::Value::Type::LIST)));
handlers->AddHandler(std::make_unique<SimplePolicyHandler>( handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
std::make_unique<SimplePolicyHandler>(
key::kNativePrintersBulkWhitelist,
prefs::kRecommendedPrintersAllowlist, base::Value::Type::LIST),
std::make_unique<SimplePolicyHandler>(
key::kPrintersBulkAllowlist, prefs::kRecommendedPrintersAllowlist, key::kPrintersBulkAllowlist, prefs::kRecommendedPrintersAllowlist,
base::Value::Type::LIST)); base::Value::Type::LIST)));
handlers->AddHandler( handlers->AddHandler(
std::make_unique<ExternalDataPolicyHandler>(key::kExternalPrintServers)); std::make_unique<ExternalDataPolicyHandler>(key::kExternalPrintServers));
handlers->AddHandler(std::make_unique<ExternalDataPolicyHandler>( handlers->AddHandler(std::make_unique<ExternalDataPolicyHandler>(
...@@ -1703,9 +1732,14 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1703,9 +1732,14 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
std::make_unique<chromeos::platform_keys::KeyPermissionsPolicyHandler>( std::make_unique<chromeos::platform_keys::KeyPermissionsPolicyHandler>(
chrome_schema)); chrome_schema));
handlers->AddHandler(std::make_unique<DefaultGeolocationPolicyHandler>()); handlers->AddHandler(std::make_unique<DefaultGeolocationPolicyHandler>());
handlers->AddHandler(std::make_unique<extensions::ExtensionListPolicyHandler>( handlers->AddHandler(std::make_unique<policy::SimpleDeprecatingPolicyHandler>(
std::make_unique<extensions::ExtensionListPolicyHandler>(
key::kNoteTakingAppsLockScreenWhitelist,
prefs::kNoteTakingAppsLockScreenAllowlist, false /*allow_wildcards*/),
std::make_unique<extensions::ExtensionListPolicyHandler>(
key::kNoteTakingAppsLockScreenAllowlist, key::kNoteTakingAppsLockScreenAllowlist,
prefs::kNoteTakingAppsLockScreenAllowlist, false /*allow_wildcards*/)); prefs::kNoteTakingAppsLockScreenAllowlist,
false /*allow_wildcards*/)));
handlers->AddHandler( handlers->AddHandler(
std::make_unique<SecondaryGoogleAccountSigninPolicyHandler>()); std::make_unique<SecondaryGoogleAccountSigninPolicyHandler>());
handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>( handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>(
...@@ -1750,11 +1784,19 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1750,11 +1784,19 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
SCHEMA_ALLOW_UNKNOWN, SCHEMA_ALLOW_UNKNOWN,
SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED, SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED,
SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED)); SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED));
handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>( handlers->AddHandler(std::make_unique<policy::SimpleDeprecatingPolicyHandler>(
key::kPerAppTimeLimitsAllowlist, prefs::kPerAppTimeLimitsAllowlistPolicy, std::make_unique<SimpleSchemaValidatingPolicyHandler>(
chrome_schema, SCHEMA_ALLOW_UNKNOWN, key::kPerAppTimeLimitsWhitelist,
prefs::kPerAppTimeLimitsAllowlistPolicy, chrome_schema,
SCHEMA_ALLOW_UNKNOWN,
SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED, SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED,
SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED)); SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED),
std::make_unique<SimpleSchemaValidatingPolicyHandler>(
key::kPerAppTimeLimitsAllowlist,
prefs::kPerAppTimeLimitsAllowlistPolicy, chrome_schema,
SCHEMA_ALLOW_UNKNOWN,
SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED,
SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED)));
handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>( handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>(
key::kEduCoexistenceToSVersion, key::kEduCoexistenceToSVersion,
chromeos::prefs::kEduCoexistenceToSVersion, chrome_schema, chromeos::prefs::kEduCoexistenceToSVersion, chrome_schema,
...@@ -1771,9 +1813,13 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1771,9 +1813,13 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
chrome_schema)); chrome_schema));
handlers->AddHandler( handlers->AddHandler(
std::make_unique<SystemFeaturesDisableListPolicyHandler>()); std::make_unique<SystemFeaturesDisableListPolicyHandler>());
handlers->AddHandler(std::make_unique<SimplePolicyHandler>( handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
std::make_unique<SimplePolicyHandler>(
key::kExternalPrintServersWhitelist,
prefs::kExternalPrintServersAllowlist, base::Value::Type::LIST),
std::make_unique<SimplePolicyHandler>(
key::kExternalPrintServersAllowlist, key::kExternalPrintServersAllowlist,
prefs::kExternalPrintServersAllowlist, base::Value::Type::LIST)); prefs::kExternalPrintServersAllowlist, base::Value::Type::LIST)));
handlers->AddHandler(std::make_unique<BooleanDisablingPolicyHandler>( handlers->AddHandler(std::make_unique<BooleanDisablingPolicyHandler>(
key::kNearbyShareAllowed, prefs::kNearbySharingEnabledPrefName)); key::kNearbyShareAllowed, prefs::kNearbySharingEnabledPrefName));
handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>( handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>(
...@@ -1782,9 +1828,13 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1782,9 +1828,13 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED, SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED,
SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED)); SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED));
#if defined(USE_CUPS) #if defined(USE_CUPS)
handlers->AddHandler(std::make_unique<extensions::ExtensionListPolicyHandler>( handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
std::make_unique<extensions::ExtensionListPolicyHandler>(
key::kPrintingAPIExtensionsWhitelist,
prefs::kPrintingAPIExtensionsAllowlist, /*allow_wildcards=*/false),
std::make_unique<extensions::ExtensionListPolicyHandler>(
key::kPrintingAPIExtensionsAllowlist, key::kPrintingAPIExtensionsAllowlist,
prefs::kPrintingAPIExtensionsAllowlist, /*allow_wildcards=*/false)); prefs::kPrintingAPIExtensionsAllowlist, /*allow_wildcards=*/false)));
#endif // defined(USE_CUPS) #endif // defined(USE_CUPS)
#else // defined(OS_CHROMEOS) #else // defined(OS_CHROMEOS)
std::vector<std::unique_ptr<ConfigurationPolicyHandler>> std::vector<std::unique_ptr<ConfigurationPolicyHandler>>
...@@ -1831,25 +1881,39 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1831,25 +1881,39 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
handlers->AddHandler(std::make_unique<DiskCacheDirPolicyHandler>()); handlers->AddHandler(std::make_unique<DiskCacheDirPolicyHandler>());
handlers->AddHandler( handlers->AddHandler(std::make_unique<policy::SimpleDeprecatingPolicyHandler>(
std::make_unique<extensions::NativeMessagingHostListPolicyHandler>(
key::kNativeMessagingWhitelist,
extensions::pref_names::kNativeMessagingAllowlist, false),
std::make_unique<extensions::NativeMessagingHostListPolicyHandler>( std::make_unique<extensions::NativeMessagingHostListPolicyHandler>(
key::kNativeMessagingAllowlist, key::kNativeMessagingAllowlist,
extensions::pref_names::kNativeMessagingAllowlist, false)); extensions::pref_names::kNativeMessagingAllowlist, false)));
handlers->AddHandler( handlers->AddHandler(std::make_unique<policy::SimpleDeprecatingPolicyHandler>(
std::make_unique<extensions::NativeMessagingHostListPolicyHandler>(
key::kNativeMessagingBlacklist,
extensions::pref_names::kNativeMessagingBlocklist, true),
std::make_unique<extensions::NativeMessagingHostListPolicyHandler>( std::make_unique<extensions::NativeMessagingHostListPolicyHandler>(
key::kNativeMessagingBlocklist, key::kNativeMessagingBlocklist,
extensions::pref_names::kNativeMessagingBlocklist, true)); extensions::pref_names::kNativeMessagingBlocklist, true)));
handlers->AddHandler( handlers->AddHandler(
std::make_unique<AutoLaunchProtocolsPolicyHandler>(chrome_schema)); std::make_unique<AutoLaunchProtocolsPolicyHandler>(chrome_schema));
#endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
handlers->AddHandler(std::make_unique<extensions::ExtensionListPolicyHandler>( handlers->AddHandler(std::make_unique<policy::SimpleDeprecatingPolicyHandler>(
std::make_unique<extensions::ExtensionListPolicyHandler>(
key::kExtensionInstallWhitelist,
extensions::pref_names::kInstallAllowList, false),
std::make_unique<extensions::ExtensionListPolicyHandler>(
key::kExtensionInstallAllowlist, key::kExtensionInstallAllowlist,
extensions::pref_names::kInstallAllowList, false)); extensions::pref_names::kInstallAllowList, false)));
handlers->AddHandler(std::make_unique<extensions::ExtensionListPolicyHandler>( handlers->AddHandler(std::make_unique<policy::SimpleDeprecatingPolicyHandler>(
key::kExtensionInstallBlocklist, extensions::pref_names::kInstallDenyList, std::make_unique<extensions::ExtensionListPolicyHandler>(
true)); key::kExtensionInstallBlacklist,
extensions::pref_names::kInstallDenyList, true),
std::make_unique<extensions::ExtensionListPolicyHandler>(
key::kExtensionInstallBlocklist,
extensions::pref_names::kInstallDenyList, true)));
handlers->AddHandler( handlers->AddHandler(
std::make_unique<extensions::ExtensionInstallForcelistPolicyHandler>()); std::make_unique<extensions::ExtensionInstallForcelistPolicyHandler>());
handlers->AddHandler( handlers->AddHandler(
...@@ -1878,9 +1942,11 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( ...@@ -1878,9 +1942,11 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
#if BUILDFLAG(ENABLE_SPELLCHECK) #if BUILDFLAG(ENABLE_SPELLCHECK)
handlers->AddHandler(std::make_unique<SpellcheckLanguagePolicyHandler>()); handlers->AddHandler(std::make_unique<SpellcheckLanguagePolicyHandler>());
handlers->AddHandler( handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>(
std::make_unique<SpellcheckLanguageBlocklistPolicyHandler>(
policy::key::kSpellcheckLanguageBlacklist),
std::make_unique<SpellcheckLanguageBlocklistPolicyHandler>( std::make_unique<SpellcheckLanguageBlocklistPolicyHandler>(
policy::key::kSpellcheckLanguageBlocklist)); policy::key::kSpellcheckLanguageBlocklist)));
#endif // BUILDFLAG(ENABLE_SPELLCHECK) #endif // BUILDFLAG(ENABLE_SPELLCHECK)
return handlers; return handlers;
......
...@@ -125,7 +125,7 @@ class RestoreOnStartupPolicyTest : public PolicyTest, ...@@ -125,7 +125,7 @@ class RestoreOnStartupPolicyTest : public PolicyTest,
base::Value urls(base::Value::Type::LIST); base::Value urls(base::Value::Type::LIST);
for (const auto* url_string : kRestoredURLs) for (const auto* url_string : kRestoredURLs)
urls.Append(url_string); urls.Append(url_string);
policies.Set(key::kURLBlocklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
POLICY_SOURCE_CLOUD, std::move(urls), nullptr); POLICY_SOURCE_CLOUD, std::move(urls), nullptr);
provider_.UpdateChromePolicy(policies); provider_.UpdateChromePolicy(policies);
// This should restore the tabs opened at PRE_RunTest below, yet all should // This should restore the tabs opened at PRE_RunTest below, yet all should
......
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h"
#include "components/policy/core/common/features.h" #include "components/policy/core/common/features.h"
#include "components/policy/core/common/policy_bundle.h" #include "components/policy/core/common/policy_bundle.h"
#include "components/policy/core/common/policy_map.h" #include "components/policy/core/common/policy_map.h"
...@@ -27,9 +25,6 @@ ...@@ -27,9 +25,6 @@
#include "components/policy/core/common/policy_types.h" #include "components/policy/core/common/policy_types.h"
#include "components/policy/core/common/values_util.h" #include "components/policy/core/common/values_util.h"
#include "components/policy/policy_constants.h" #include "components/policy/policy_constants.h"
#include "components/strings/grit/components_strings.h"
#include "extensions/buildflags/buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "components/policy/core/common/android/policy_service_android.h" #include "components/policy/core/common/android/policy_service_android.h"
...@@ -84,81 +79,6 @@ void RemapProxyPolicies(PolicyMap* policies) { ...@@ -84,81 +79,6 @@ void RemapProxyPolicies(PolicyMap* policies) {
} }
} }
// Maps the separate policies for proxy settings into a single Dictionary
// policy. This allows to keep the logic of merging policies from different
// sources simple, as all separate proxy policies should be considered as a
// single whole during merging.
void RemapRenamedPolicies(PolicyMap* policies) {
// For all renamed policies we need to explicitly merge the value of the
// old policy with the new one or else merging will not be carried over
// if desired.
base::Value* merge_list =
policies->GetMutableValue(key::kPolicyListMultipleSourceMergeList);
base::flat_set<std::string> policy_lists_to_merge =
policy::ValueToStringSet(merge_list);
const std::vector<std::pair<const char*, const char*>> renamed_policies = {{
{policy::key::kSafeBrowsingWhitelistDomains,
policy::key::kSafeBrowsingAllowlistDomains},
{policy::key::kSpellcheckLanguageBlacklist,
policy::key::kSpellcheckLanguageBlocklist},
{policy::key::kURLBlacklist, policy::key::kURLBlocklist},
{policy::key::kURLWhitelist, policy::key::kURLAllowlist},
#if !defined(OS_ANDROID)
{policy::key::kAutoplayWhitelist, policy::key::kAutoplayAllowlist},
#endif // !defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_EXTENSIONS)
{policy::key::kExtensionInstallBlacklist,
policy::key::kExtensionInstallBlocklist},
{policy::key::kExtensionInstallWhitelist,
policy::key::kExtensionInstallAllowlist},
{policy::key::kNativeMessagingBlacklist,
policy::key::kNativeMessagingBlocklist},
{policy::key::kNativeMessagingWhitelist,
policy::key::kNativeMessagingAllowlist},
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
#if defined(OS_CHROMEOS)
{policy::key::kAttestationExtensionWhitelist,
policy::key::kAttestationExtensionAllowlist},
{policy::key::kExternalPrintServersWhitelist,
policy::key::kExternalPrintServersAllowlist},
{policy::key::kNativePrintersBulkBlacklist,
policy::key::kPrintersBulkBlocklist},
{policy::key::kNativePrintersBulkWhitelist,
policy::key::kPrintersBulkAllowlist},
{policy::key::kPerAppTimeLimitsWhitelist,
policy::key::kPerAppTimeLimitsAllowlist},
{policy::key::kQuickUnlockModeWhitelist,
policy::key::kQuickUnlockModeAllowlist},
{policy::key::kNoteTakingAppsLockScreenWhitelist,
policy::key::kNoteTakingAppsLockScreenAllowlist},
#if defined(USE_CUPS)
{policy::key::kPrintingAPIExtensionsWhitelist,
policy::key::kPrintingAPIExtensionsAllowlist},
#endif // defined(USE_CUPS)
#endif // defined(OS_CHROMEOS)
}};
for (const auto& policy_pair : renamed_policies) {
PolicyMap::Entry* old_policy = policies->GetMutable(policy_pair.first);
const PolicyMap::Entry* new_policy = policies->Get(policy_pair.second);
if (old_policy && !new_policy) {
PolicyMap::Entry policy_entry = old_policy->DeepCopy();
policy_entry.AddError(
l10n_util::GetStringFUTF8(IDS_POLICY_MIGRATED_NEW_POLICY,
base::UTF8ToUTF16(policy_pair.first)));
// TOTO(pastarmovj): Readd the old_policy error when the tast tests
// for chromeos have been updated.
// old_policy->AddError(
// l10n_util::GetStringFUTF8(IDS_POLICY_MIGRATED_OLD_POLICY,
// base::UTF8ToUTF16(policy_pair.second)));
policies->Set(policy_pair.second, std::move(policy_entry));
}
if (policy_lists_to_merge.contains(policy_pair.first) &&
!policy_lists_to_merge.contains(policy_pair.second)) {
merge_list->Append(base::Value(policy_pair.second));
}
}
}
// Returns the string values of |policy|. Returns an empty set if the values are // Returns the string values of |policy|. Returns an empty set if the values are
// not strings. // not strings.
base::flat_set<std::string> GetStringListPolicyItems( base::flat_set<std::string> GetStringListPolicyItems(
...@@ -359,7 +279,6 @@ void PolicyServiceImpl::MergeAndTriggerUpdates() { ...@@ -359,7 +279,6 @@ void PolicyServiceImpl::MergeAndTriggerUpdates() {
PolicyBundle provided_bundle; PolicyBundle provided_bundle;
provided_bundle.CopyFrom(provider->policies()); provided_bundle.CopyFrom(provider->policies());
RemapProxyPolicies(&provided_bundle.Get(chrome_namespace)); RemapProxyPolicies(&provided_bundle.Get(chrome_namespace));
RemapRenamedPolicies(&provided_bundle.Get(chrome_namespace));
bundle.MergeFrom(provided_bundle); bundle.MergeFrom(provided_bundle);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment