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