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

Unified Diff: components/policy/tools/generate_policy_source.py

Issue 519643002: Default values for enterprise users are supported. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/tools/generate_policy_source.py
diff --git a/components/policy/tools/generate_policy_source.py b/components/policy/tools/generate_policy_source.py
index 4e07baa70dbd6ed870dfa982ecc14ad883fe9237..db98095ca861d0855714423abe081b328aa69d92 100755
--- a/components/policy/tools/generate_policy_source.py
+++ b/components/policy/tools/generate_policy_source.py
@@ -57,6 +57,9 @@ class PolicyDetails:
self.is_deprecated = policy.get('deprecated', False)
self.is_device_only = policy.get('device_only', False)
self.schema = policy.get('schema', {})
+ self.has_enterprise_default = 'default_for_enterprise_users' in policy
+ if self.has_enterprise_default:
+ self.enterprise_default = policy['default_for_enterprise_users']
expected_platform = 'chrome_os' if is_chromium_os else os.lower()
self.platforms = []
@@ -573,6 +576,7 @@ def _WritePolicyConstantSource(policies, os, f):
'\n'
'#include "base/logging.h"\n'
'#include "components/policy/core/common/schema_internal.h"\n'
+ '#include "components/policy/core/common/policy_map.h"\n'
Joao da Silva 2014/08/29 09:11:42 Includes in alphabetical order, so this comes befo
merkulova 2014/08/29 14:02:53 Done.
'\n'
'namespace policy {\n'
'\n'
@@ -630,6 +634,33 @@ def _WritePolicyConstantSource(policies, os, f):
' return &kChromeSchemaData;\n'
'}\n\n')
+ f.write('#if defined(OS_CHROMEOS)\n'
+ 'void SetEnterpriseUsersDefaults(PolicyMap* policy_map) {\n')
+
+ for policy in policies:
+ if policy.has_enterprise_default:
Joao da Silva 2014/08/29 09:11:42 Use 2 spaces for indentation instead of 4 (below t
merkulova 2014/08/29 14:02:53 Done.
+ if policy.policy_type == 'TYPE_BOOLEAN':
+ creation_expression = 'new bool(%s)' % policy.enterprise_default
Joao da Silva 2014/08/29 09:11:43 new base::FundamentalValue() Also, the |policy.en
merkulova 2014/08/29 14:02:53 Done.
+ elif policy.policy_type == 'TYPE_INTEGER':
+ creation_expression = 'new int(%s)' % policy.enterprise_default
Joao da Silva 2014/08/29 09:11:42 new base::FundamentalValue
merkulova 2014/08/29 14:02:52 Done.
+ elif policy.policy_type == 'TYPE_STRING':
+ creation_expression = 'new base::StringValue("%s")' %\
+ policy.enterprise_default
+ else:
+ raise RuntimeError('Type %s of policy %s is not supported at '
+ 'enterprise defaults' % (policy.policy_type,
+ policy.name))
+ f.write(' if (!policy_map->Get("%s")) {\n'
+ ' policy_map->Set("%s",\n'
Joao da Silva 2014/08/29 09:11:42 These 2 lines are duplicating the string for the p
merkulova 2014/08/29 14:02:52 Done.
+ ' POLICY_LEVEL_MANDATORY,\n'
+ ' POLICY_SCOPE_USER,\n'
+ ' %s,\n'
+ ' NULL);\n'
+ ' }\n' % (policy.name, policy.name, creation_expression))
+
+ f.write('}\n\n'
Joao da Silva 2014/08/29 09:11:42 Single newline here, so that the #endif comes righ
merkulova 2014/08/29 14:02:52 Done.
+ '#endif\n\n')
+
f.write('const PolicyDetails* GetChromePolicyDetails('
'const std::string& policy) {\n'
' // First index in kPropertyNodes of the Chrome policies.\n'

Powered by Google App Engine
This is Rietveld 408576698