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

Unified Diff: components/policy/core/browser/configuration_policy_handler.cc

Issue 309553011: Enable policy support for registering protocol handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Issue_116119_pre
Patch Set: Fix for the windows compile error Created 6 years, 6 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/browser/configuration_policy_handler.cc
diff --git a/components/policy/core/browser/configuration_policy_handler.cc b/components/policy/core/browser/configuration_policy_handler.cc
index f4918a657b75682c9524804987a763b468689544..65d0a5611a86155c4181f1c8c80faf58d7d5385d 100644
--- a/components/policy/core/browser/configuration_policy_handler.cc
+++ b/components/policy/core/browser/configuration_policy_handler.cc
@@ -368,6 +368,54 @@ bool SchemaValidatingPolicyHandler::CheckAndGetValue(
return result;
}
+// SimpleSchemaValidatingPolicyHandler implementation --------------------------
+
+SimpleSchemaValidatingPolicyHandler::SimpleSchemaValidatingPolicyHandler(
+ const char* policy_name,
+ const char* pref_path,
+ Schema schema,
+ SchemaOnErrorStrategy strategy,
+ RecommendedPermission recommended_permission,
+ MandatoryPermission mandatory_permission)
+ : SchemaValidatingPolicyHandler(policy_name,
+ schema.GetKnownProperty(policy_name),
+ strategy),
+ pref_path_(pref_path),
+ allow_recommended_(recommended_permission == RECOMMENDED_ALLOWED),
+ allow_mandatory_(mandatory_permission == MANDATORY_ALLOWED) {
+}
+
+SimpleSchemaValidatingPolicyHandler::~SimpleSchemaValidatingPolicyHandler() {
+}
+
+bool SimpleSchemaValidatingPolicyHandler::CheckPolicySettings(
+ const PolicyMap& policies,
+ PolicyErrorMap* errors) {
+ const PolicyMap::Entry* policy_entry = policies.Get(policy_name());
+ if (!policy_entry)
+ return true;
+ if ((policy_entry->level == policy::POLICY_LEVEL_MANDATORY &&
+ !allow_mandatory_) ||
+ (policy_entry->level == policy::POLICY_LEVEL_RECOMMENDED &&
+ !allow_recommended_)) {
+ if (errors)
+ errors->AddError(policy_name(), IDS_POLICY_LEVEL_ERROR);
+ return false;
+ }
+
+ return SchemaValidatingPolicyHandler::CheckPolicySettings(policies, errors);
+}
+
+void SimpleSchemaValidatingPolicyHandler::ApplyPolicySettings(
+ const PolicyMap& policies,
+ PrefValueMap* prefs) {
+ if (!pref_path_)
+ return;
+ const base::Value* value = policies.GetValue(policy_name());
+ if (value)
+ prefs->SetValue(pref_path_, value->DeepCopy());
+}
+
// LegacyPoliciesDeprecatingPolicyHandler implementation -----------------------
// TODO(binjin): Add a new common base class for SchemaValidatingPolicyHandler

Powered by Google App Engine
This is Rietveld 408576698