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

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

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad rebase Created 6 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 unified diff | Download patch | Annotate | Revision Log
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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 } 818 }
819 819
820 return new base::FundamentalValue(static_cast<int>(value)); 820 return new base::FundamentalValue(static_cast<int>(value));
821 } 821 }
822 822
823 base::ListValue* DecodeStringList(const em::StringList& string_list) { 823 base::ListValue* DecodeStringList(const em::StringList& string_list) {
824 base::ListValue* list_value = new base::ListValue; 824 base::ListValue* list_value = new base::ListValue;
825 RepeatedPtrField<std::string>::const_iterator entry; 825 RepeatedPtrField<std::string>::const_iterator entry;
826 for (entry = string_list.entries().begin(); 826 for (entry = string_list.entries().begin();
827 entry != string_list.entries().end(); ++entry) { 827 entry != string_list.entries().end(); ++entry) {
828 list_value->Append(base::Value::CreateStringValue(*entry)); 828 list_value->AppendString(*entry);
829 } 829 }
830 return list_value; 830 return list_value;
831 } 831 }
832 832
833 base::Value* DecodeJson(const std::string& json) { 833 base::Value* DecodeJson(const std::string& json) {
834 scoped_ptr<base::Value> root( 834 scoped_ptr<base::Value> root(
835 base::JSONReader::Read(json, base::JSON_ALLOW_TRAILING_COMMAS)); 835 base::JSONReader::Read(json, base::JSON_ALLOW_TRAILING_COMMAS));
836 836
837 if (!root) 837 if (!root)
838 LOG(WARNING) << "Invalid JSON string, ignoring: " << json; 838 LOG(WARNING) << "Invalid JSON string, ignoring: " << json;
(...skipping 14 matching lines...) Expand all
853 } // namespace policy 853 } // namespace policy
854 ''' 854 '''
855 855
856 856
857 def _CreateValue(type, arg): 857 def _CreateValue(type, arg):
858 if type == 'TYPE_BOOLEAN': 858 if type == 'TYPE_BOOLEAN':
859 return 'new base::FundamentalValue(%s)' % arg 859 return 'new base::FundamentalValue(%s)' % arg
860 elif type == 'TYPE_INTEGER': 860 elif type == 'TYPE_INTEGER':
861 return 'DecodeIntegerValue(%s)' % arg 861 return 'DecodeIntegerValue(%s)' % arg
862 elif type == 'TYPE_STRING': 862 elif type == 'TYPE_STRING':
863 return 'base::Value::CreateStringValue(%s)' % arg 863 return 'new base::StringValue(%s)' % arg
864 elif type == 'TYPE_LIST': 864 elif type == 'TYPE_LIST':
865 return 'DecodeStringList(%s)' % arg 865 return 'DecodeStringList(%s)' % arg
866 elif type == 'TYPE_DICTIONARY' or type == 'TYPE_EXTERNAL': 866 elif type == 'TYPE_DICTIONARY' or type == 'TYPE_EXTERNAL':
867 return 'DecodeJson(%s)' % arg 867 return 'DecodeJson(%s)' % arg
868 else: 868 else:
869 raise NotImplementedError('Unknown type %s' % type) 869 raise NotImplementedError('Unknown type %s' % type)
870 870
871 871
872 def _CreateExternalDataFetcher(type, name): 872 def _CreateExternalDataFetcher(type, name):
873 if type == 'TYPE_EXTERNAL': 873 if type == 'TYPE_EXTERNAL':
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 def _WriteCloudPolicyDecoder(policies, os, f): 919 def _WriteCloudPolicyDecoder(policies, os, f):
920 f.write(CPP_HEAD) 920 f.write(CPP_HEAD)
921 for policy in policies: 921 for policy in policies:
922 if policy.is_supported and not policy.is_device_only: 922 if policy.is_supported and not policy.is_device_only:
923 _WritePolicyCode(f, policy) 923 _WritePolicyCode(f, policy)
924 f.write(CPP_FOOT) 924 f.write(CPP_FOOT)
925 925
926 926
927 if __name__ == '__main__': 927 if __name__ == '__main__':
928 sys.exit(main()) 928 sys.exit(main())
OLDNEW
« no previous file with comments | « components/policy/core/common/schema_map_unittest.cc ('k') | components/pref_registry/pref_registry_syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698