Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: components/policy/core/common/config_dir_policy_loader.cc

Issue 1824743002: Drop non-user policy in ConfigDirPolicyLoader on Chrome OS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/config_dir_policy_loader.cc
diff --git a/components/policy/core/common/config_dir_policy_loader.cc b/components/policy/core/common/config_dir_policy_loader.cc
index c9344fd44754680e24162bbb1c1a566af2fd08c4..018a12ea7082dfbcfac9386f9e220b1b19887560 100644
--- a/components/policy/core/common/config_dir_policy_loader.cc
+++ b/components/policy/core/common/config_dir_policy_loader.cc
@@ -22,6 +22,7 @@
#include "components/policy/core/common/policy_bundle.h"
#include "components/policy/core/common/policy_load_status.h"
#include "components/policy/core/common/policy_types.h"
+#include "policy/policy_constants.h"
namespace policy {
@@ -58,6 +59,20 @@ PolicyLoadStatus JsonErrorToPolicyLoadStatus(int status) {
return POLICY_LOAD_STATUS_PARSE_ERROR;
}
+bool IsUserPolicy(const PolicyMap::const_iterator iter) {
+ const PolicyDetails* policy_details = GetChromePolicyDetails(iter->first);
+ if (!policy_details) {
+ LOG(ERROR) << "Ignoring unknown platform policy: " << iter->first;
+ return false;
+ }
+ if (policy_details->is_device_policy) {
+ // Device Policy is only implemented as Cloud Policy (not Platform Policy).
+ LOG(ERROR) << "Ignoring device platform policy: " << iter->first;
+ return false;
+ }
+ return true;
+}
+
} // namespace
ConfigDirPolicyLoader::ConfigDirPolicyLoader(
@@ -171,6 +186,7 @@ void ConfigDirPolicyLoader::LoadFromPath(const base::FilePath& path,
PolicyMap policy_map;
policy_map.LoadFrom(dictionary_value, level, scope_,
POLICY_SOURCE_PLATFORM);
+ policy_map.EraseNonmatching(base::Bind(&IsUserPolicy));
bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
.MergeFrom(policy_map);
}

Powered by Google App Engine
This is Rietveld 408576698