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

Side by Side Diff: components/policy/tools/generate_policy_source.py

Issue 2627083002: cros: Ensure quick unlock is disabled by default for enterprise policy. (Closed)
Patch Set: Add policy generation support Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 '''python %prog [options] platform chromium_os_flag template 6 '''python %prog [options] platform chromium_os_flag template
7 7
8 platform specifies which platform source is being generated for 8 platform specifies which platform source is being generated for
9 and can be one of (win, mac, linux) 9 and can be one of (win, mac, linux)
10 chromium_os_flag should be 1 if this is a Chromium OS build 10 chromium_os_flag should be 1 if this is a Chromium OS build
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 if policy.has_enterprise_default: 739 if policy.has_enterprise_default:
740 if policy.policy_type == 'Type::BOOLEAN': 740 if policy.policy_type == 'Type::BOOLEAN':
741 creation_expression = 'new base::FundamentalValue(%s)' %\ 741 creation_expression = 'new base::FundamentalValue(%s)' %\
742 ('true' if policy.enterprise_default else 'false') 742 ('true' if policy.enterprise_default else 'false')
743 elif policy.policy_type == 'Type::INTEGER': 743 elif policy.policy_type == 'Type::INTEGER':
744 creation_expression = 'new base::FundamentalValue(%s)' %\ 744 creation_expression = 'new base::FundamentalValue(%s)' %\
745 policy.enterprise_default 745 policy.enterprise_default
746 elif policy.policy_type == 'Type::STRING': 746 elif policy.policy_type == 'Type::STRING':
747 creation_expression = 'new base::StringValue("%s")' %\ 747 creation_expression = 'new base::StringValue("%s")' %\
748 policy.enterprise_default 748 policy.enterprise_default
749 elif (policy.policy_type == 'Type::LIST' and
pastarmovj 2017/01/23 23:38:12 If I get this right this code will only work for e
Thiemo Nagel 2017/01/24 10:27:35 +1 to that.
jdufault 2017/01/25 01:32:43 I've extended the logic, but I don't see a relativ
pastarmovj 2017/01/25 15:28:05 I think the easiest (and complete) way to test thi
750 policy.enterprise_default == []):
751 creation_expression = 'new base::ListValue()'
749 else: 752 else:
750 raise RuntimeError('Type %s of policy %s is not supported at ' 753 raise RuntimeError('Type %s of policy %s is not supported at '
751 'enterprise defaults' % (policy.policy_type, 754 'enterprise defaults' % (policy.policy_type,
752 policy.name)) 755 policy.name))
753 f.write(' if (!policy_map->Get(key::k%s)) {\n' 756 f.write(' if (!policy_map->Get(key::k%s)) {\n'
754 ' policy_map->Set(key::k%s,\n' 757 ' policy_map->Set(key::k%s,\n'
755 ' POLICY_LEVEL_MANDATORY,\n' 758 ' POLICY_LEVEL_MANDATORY,\n'
756 ' POLICY_SCOPE_USER,\n' 759 ' POLICY_SCOPE_USER,\n'
757 ' POLICY_SOURCE_ENTERPRISE_DEFAULT,\n' 760 ' POLICY_SOURCE_ENTERPRISE_DEFAULT,\n'
758 ' base::WrapUnique(%s),\n' 761 ' base::WrapUnique(%s),\n'
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 f.write('<restrictions xmlns:android="' 1175 f.write('<restrictions xmlns:android="'
1173 'http://schemas.android.com/apk/res/android">\n\n') 1176 'http://schemas.android.com/apk/res/android">\n\n')
1174 for policy in policies: 1177 for policy in policies:
1175 if (policy.is_supported and policy.restriction_type != 'invalid' and 1178 if (policy.is_supported and policy.restriction_type != 'invalid' and
1176 not policy.is_deprecated and not policy.is_future): 1179 not policy.is_deprecated and not policy.is_future):
1177 WriteAppRestriction(policy) 1180 WriteAppRestriction(policy)
1178 f.write('</restrictions>') 1181 f.write('</restrictions>')
1179 1182
1180 if __name__ == '__main__': 1183 if __name__ == '__main__':
1181 sys.exit(main()) 1184 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698