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

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

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years, 1 month 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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 f.write('const internal::SchemaData* GetChromeSchemaData() {\n' 730 f.write('const internal::SchemaData* GetChromeSchemaData() {\n'
731 ' return &kChromeSchemaData;\n' 731 ' return &kChromeSchemaData;\n'
732 '}\n\n') 732 '}\n\n')
733 733
734 f.write('#if defined (OS_CHROMEOS)\n' 734 f.write('#if defined (OS_CHROMEOS)\n'
735 'void SetEnterpriseUsersDefaults(PolicyMap* policy_map) {\n') 735 'void SetEnterpriseUsersDefaults(PolicyMap* policy_map) {\n')
736 736
737 for policy in policies: 737 for policy in policies:
738 if policy.has_enterprise_default: 738 if policy.has_enterprise_default:
739 if policy.policy_type == 'TYPE_BOOLEAN': 739 if policy.policy_type == 'TYPE_BOOLEAN':
740 creation_expression = 'new base::FundamentalValue(%s)' %\ 740 creation_expression = 'new base::Value(%s)' %\
741 ('true' if policy.enterprise_default else 'false') 741 ('true' if policy.enterprise_default else 'false')
742 elif policy.policy_type == 'TYPE_INTEGER': 742 elif policy.policy_type == 'TYPE_INTEGER':
743 creation_expression = 'new base::FundamentalValue(%s)' %\ 743 creation_expression = 'new base::Value(%s)' %\
744 policy.enterprise_default 744 policy.enterprise_default
745 elif policy.policy_type == 'TYPE_STRING': 745 elif policy.policy_type == 'TYPE_STRING':
746 creation_expression = 'new base::StringValue("%s")' %\ 746 creation_expression = 'new base::StringValue("%s")' %\
747 policy.enterprise_default 747 policy.enterprise_default
748 else: 748 else:
749 raise RuntimeError('Type %s of policy %s is not supported at ' 749 raise RuntimeError('Type %s of policy %s is not supported at '
750 'enterprise defaults' % (policy.policy_type, 750 'enterprise defaults' % (policy.policy_type,
751 policy.name)) 751 policy.name))
752 f.write(' if (!policy_map->Get(key::k%s)) {\n' 752 f.write(' if (!policy_map->Get(key::k%s)) {\n'
753 ' policy_map->Set(key::k%s,\n' 753 ' policy_map->Set(key::k%s,\n'
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 std::unique_ptr<base::Value> DecodeIntegerValue( 1029 std::unique_ptr<base::Value> DecodeIntegerValue(
1030 google::protobuf::int64 value) { 1030 google::protobuf::int64 value) {
1031 if (value < std::numeric_limits<int>::min() || 1031 if (value < std::numeric_limits<int>::min() ||
1032 value > std::numeric_limits<int>::max()) { 1032 value > std::numeric_limits<int>::max()) {
1033 LOG(WARNING) << "Integer value " << value 1033 LOG(WARNING) << "Integer value " << value
1034 << " out of numeric limits, ignoring."; 1034 << " out of numeric limits, ignoring.";
1035 return nullptr; 1035 return nullptr;
1036 } 1036 }
1037 1037
1038 return base::WrapUnique( 1038 return base::WrapUnique(
1039 new base::FundamentalValue(static_cast<int>(value))); 1039 new base::Value(static_cast<int>(value)));
1040 } 1040 }
1041 1041
1042 std::unique_ptr<base::ListValue> DecodeStringList( 1042 std::unique_ptr<base::ListValue> DecodeStringList(
1043 const em::StringList& string_list) { 1043 const em::StringList& string_list) {
1044 std::unique_ptr<base::ListValue> list_value(new base::ListValue); 1044 std::unique_ptr<base::ListValue> list_value(new base::ListValue);
1045 for (const auto& entry : string_list.entries()) 1045 for (const auto& entry : string_list.entries())
1046 list_value->AppendString(entry); 1046 list_value->AppendString(entry);
1047 return list_value; 1047 return list_value;
1048 } 1048 }
1049 1049
(...skipping 16 matching lines...) Expand all
1066 1066
1067 1067
1068 CPP_FOOT = '''} 1068 CPP_FOOT = '''}
1069 1069
1070 } // namespace policy 1070 } // namespace policy
1071 ''' 1071 '''
1072 1072
1073 1073
1074 def _CreateValue(type, arg): 1074 def _CreateValue(type, arg):
1075 if type == 'TYPE_BOOLEAN': 1075 if type == 'TYPE_BOOLEAN':
1076 return 'new base::FundamentalValue(%s)' % arg 1076 return 'new base::Value(%s)' % arg
1077 elif type == 'TYPE_INTEGER': 1077 elif type == 'TYPE_INTEGER':
1078 return 'DecodeIntegerValue(%s)' % arg 1078 return 'DecodeIntegerValue(%s)' % arg
1079 elif type == 'TYPE_STRING': 1079 elif type == 'TYPE_STRING':
1080 return 'new base::StringValue(%s)' % arg 1080 return 'new base::StringValue(%s)' % arg
1081 elif type == 'TYPE_LIST': 1081 elif type == 'TYPE_LIST':
1082 return 'DecodeStringList(%s)' % arg 1082 return 'DecodeStringList(%s)' % arg
1083 elif type == 'TYPE_DICTIONARY' or type == 'TYPE_EXTERNAL': 1083 elif type == 'TYPE_DICTIONARY' or type == 'TYPE_EXTERNAL':
1084 return 'DecodeJson(%s)' % arg 1084 return 'DecodeJson(%s)' % arg
1085 else: 1085 else:
1086 raise NotImplementedError('Unknown type %s' % type) 1086 raise NotImplementedError('Unknown type %s' % type)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 # _WriteAppRestrictions body 1170 # _WriteAppRestrictions body
1171 f.write('<restrictions xmlns:android="' 1171 f.write('<restrictions xmlns:android="'
1172 'http://schemas.android.com/apk/res/android">\n\n') 1172 'http://schemas.android.com/apk/res/android">\n\n')
1173 for policy in policies: 1173 for policy in policies:
1174 if policy.is_supported and policy.restriction_type != 'invalid': 1174 if policy.is_supported and policy.restriction_type != 'invalid':
1175 WriteAppRestriction(policy) 1175 WriteAppRestriction(policy)
1176 f.write('</restrictions>') 1176 f.write('</restrictions>')
1177 1177
1178 if __name__ == '__main__': 1178 if __name__ == '__main__':
1179 sys.exit(main()) 1179 sys.exit(main())
OLDNEW
« no previous file with comments | « components/policy/core/common/schema_unittest.cc ('k') | components/prefs/command_line_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698