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

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

Issue 1348903007: Revert of Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 self.properties_nodes = map(partial(self.ResolveID, 3), 632 self.properties_nodes = map(partial(self.ResolveID, 3),
633 self.properties_nodes) 633 self.properties_nodes)
634 634
635 def _WritePolicyConstantSource(policies, os, f): 635 def _WritePolicyConstantSource(policies, os, f):
636 f.write('#include "policy/policy_constants.h"\n' 636 f.write('#include "policy/policy_constants.h"\n'
637 '\n' 637 '\n'
638 '#include <algorithm>\n' 638 '#include <algorithm>\n'
639 '#include <climits>\n' 639 '#include <climits>\n'
640 '\n' 640 '\n'
641 '#include "base/logging.h"\n' 641 '#include "base/logging.h"\n'
642 '#include "components/policy/core/common/policy_types.h"\n'
643 '#include "components/policy/core/common/schema_internal.h"\n' 642 '#include "components/policy/core/common/schema_internal.h"\n'
644 '\n' 643 '\n'
645 'namespace policy {\n' 644 'namespace policy {\n'
646 '\n' 645 '\n'
647 'namespace {\n' 646 'namespace {\n'
648 '\n') 647 '\n')
649 648
650 # Generate the Chrome schema. 649 # Generate the Chrome schema.
651 chrome_schema = { 650 chrome_schema = {
652 'type': 'object', 651 'type': 'object',
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 creation_expression = 'new base::StringValue("%s")' %\ 712 creation_expression = 'new base::StringValue("%s")' %\
714 policy.enterprise_default 713 policy.enterprise_default
715 else: 714 else:
716 raise RuntimeError('Type %s of policy %s is not supported at ' 715 raise RuntimeError('Type %s of policy %s is not supported at '
717 'enterprise defaults' % (policy.policy_type, 716 'enterprise defaults' % (policy.policy_type,
718 policy.name)) 717 policy.name))
719 f.write(' if (!policy_map->Get(key::k%s)) {\n' 718 f.write(' if (!policy_map->Get(key::k%s)) {\n'
720 ' policy_map->Set(key::k%s,\n' 719 ' policy_map->Set(key::k%s,\n'
721 ' POLICY_LEVEL_MANDATORY,\n' 720 ' POLICY_LEVEL_MANDATORY,\n'
722 ' POLICY_SCOPE_USER,\n' 721 ' POLICY_SCOPE_USER,\n'
723 ' POLICY_SOURCE_ENTERPRISE_DEFAULT,\n'
724 ' %s,\n' 722 ' %s,\n'
725 ' NULL);\n' 723 ' NULL);\n'
726 ' }\n' % (policy.name, policy.name, creation_expression)) 724 ' }\n' % (policy.name, policy.name, creation_expression))
727 725
728 f.write('}\n' 726 f.write('}\n'
729 '#endif\n\n') 727 '#endif\n\n')
730 728
731 f.write('const PolicyDetails* GetChromePolicyDetails(' 729 f.write('const PolicyDetails* GetChromePolicyDetails('
732 'const std::string& policy) {\n' 730 'const std::string& policy) {\n'
733 ' // First index in kPropertyNodes of the Chrome policies.\n' 731 ' // First index in kPropertyNodes of the Chrome policies.\n'
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 #include "base/basictypes.h" 892 #include "base/basictypes.h"
895 #include "base/callback.h" 893 #include "base/callback.h"
896 #include "base/json/json_reader.h" 894 #include "base/json/json_reader.h"
897 #include "base/logging.h" 895 #include "base/logging.h"
898 #include "base/memory/scoped_ptr.h" 896 #include "base/memory/scoped_ptr.h"
899 #include "base/memory/weak_ptr.h" 897 #include "base/memory/weak_ptr.h"
900 #include "base/values.h" 898 #include "base/values.h"
901 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" 899 #include "components/policy/core/common/cloud/cloud_external_data_manager.h"
902 #include "components/policy/core/common/external_data_fetcher.h" 900 #include "components/policy/core/common/external_data_fetcher.h"
903 #include "components/policy/core/common/policy_map.h" 901 #include "components/policy/core/common/policy_map.h"
904 #include "components/policy/core/common/policy_types.h"
905 #include "policy/policy_constants.h" 902 #include "policy/policy_constants.h"
906 #include "policy/proto/cloud_policy.pb.h" 903 #include "policy/proto/cloud_policy.pb.h"
907 904
908 using google::protobuf::RepeatedPtrField; 905 using google::protobuf::RepeatedPtrField;
909 906
910 namespace policy { 907 namespace policy {
911 908
912 namespace em = enterprise_management; 909 namespace em = enterprise_management;
913 910
914 base::Value* DecodeIntegerValue(google::protobuf::int64 value) { 911 base::Value* DecodeIntegerValue(google::protobuf::int64 value) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 ' }\n' 999 ' }\n'
1003 ' }\n' 1000 ' }\n'
1004 ' if (do_set) {\n') 1001 ' if (do_set) {\n')
1005 f.write(' base::Value* value = %s;\n' % 1002 f.write(' base::Value* value = %s;\n' %
1006 (_CreateValue(policy.policy_type, 'policy_proto.value()'))) 1003 (_CreateValue(policy.policy_type, 'policy_proto.value()')))
1007 # TODO(bartfab): |value| == NULL indicates that the policy value could not be 1004 # TODO(bartfab): |value| == NULL indicates that the policy value could not be
1008 # parsed successfully. Surface such errors in the UI. 1005 # parsed successfully. Surface such errors in the UI.
1009 f.write(' if (value) {\n') 1006 f.write(' if (value) {\n')
1010 f.write(' ExternalDataFetcher* external_data_fetcher = %s;\n' % 1007 f.write(' ExternalDataFetcher* external_data_fetcher = %s;\n' %
1011 _CreateExternalDataFetcher(policy.policy_type, policy.name)) 1008 _CreateExternalDataFetcher(policy.policy_type, policy.name))
1012 f.write(' map->Set(key::k%s, \n' % policy.name) 1009 f.write(' map->Set(key::k%s, level, POLICY_SCOPE_USER,\n' %
1013 f.write(' level, \n' 1010 policy.name)
1014 ' POLICY_SCOPE_USER, \n' 1011 f.write(' value, external_data_fetcher);\n'
1015 ' POLICY_SOURCE_CLOUD, \n'
1016 ' value, \n'
1017 ' external_data_fetcher);\n'
1018 ' }\n' 1012 ' }\n'
1019 ' }\n' 1013 ' }\n'
1020 ' }\n' 1014 ' }\n'
1021 ' }\n') 1015 ' }\n')
1022 1016
1023 1017
1024 def _WriteCloudPolicyDecoder(policies, os, f): 1018 def _WriteCloudPolicyDecoder(policies, os, f):
1025 f.write(CPP_HEAD) 1019 f.write(CPP_HEAD)
1026 for policy in policies: 1020 for policy in policies:
1027 if policy.is_supported and not policy.is_device_only: 1021 if policy.is_supported and not policy.is_device_only:
(...skipping 26 matching lines...) Expand all
1054 # _WriteAppRestrictions body 1048 # _WriteAppRestrictions body
1055 f.write('<restrictions xmlns:android="' 1049 f.write('<restrictions xmlns:android="'
1056 'http://schemas.android.com/apk/res/android">\n\n') 1050 'http://schemas.android.com/apk/res/android">\n\n')
1057 for policy in policies: 1051 for policy in policies:
1058 if policy.is_supported and policy.restriction_type != 'invalid': 1052 if policy.is_supported and policy.restriction_type != 'invalid':
1059 WriteAppRestriction(policy) 1053 WriteAppRestriction(policy)
1060 f.write('</restrictions>') 1054 f.write('</restrictions>')
1061 1055
1062 if __name__ == '__main__': 1056 if __name__ == '__main__':
1063 sys.exit(main()) 1057 sys.exit(main())
OLDNEW
« no previous file with comments | « components/policy/core/common/schema_registry_tracking_policy_provider_unittest.cc ('k') | components/policy_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698