| 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 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 f.write(' optional %sPolicyProto %s = %s;\n' % | 995 f.write(' optional %sPolicyProto %s = %s;\n' % |
| 996 (policy.policy_protobuf_type, policy.name, | 996 (policy.policy_protobuf_type, policy.name, |
| 997 policy.id + RESERVED_IDS)) | 997 policy.id + RESERVED_IDS)) |
| 998 f.write('}\n\n') | 998 f.write('}\n\n') |
| 999 | 999 |
| 1000 | 1000 |
| 1001 #------------------ protobuf decoder -------------------------------# | 1001 #------------------ protobuf decoder -------------------------------# |
| 1002 | 1002 |
| 1003 CPP_HEAD = ''' | 1003 CPP_HEAD = ''' |
| 1004 #include <limits> | 1004 #include <limits> |
| 1005 #include <memory> |
| 1005 #include <string> | 1006 #include <string> |
| 1006 | 1007 |
| 1007 #include "base/callback.h" | 1008 #include "base/callback.h" |
| 1008 #include "base/json/json_reader.h" | 1009 #include "base/json/json_reader.h" |
| 1009 #include "base/logging.h" | 1010 #include "base/logging.h" |
| 1010 #include "base/memory/scoped_ptr.h" | |
| 1011 #include "base/memory/weak_ptr.h" | 1011 #include "base/memory/weak_ptr.h" |
| 1012 #include "base/values.h" | 1012 #include "base/values.h" |
| 1013 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 1013 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
| 1014 #include "components/policy/core/common/external_data_fetcher.h" | 1014 #include "components/policy/core/common/external_data_fetcher.h" |
| 1015 #include "components/policy/core/common/policy_map.h" | 1015 #include "components/policy/core/common/policy_map.h" |
| 1016 #include "components/policy/core/common/policy_types.h" | 1016 #include "components/policy/core/common/policy_types.h" |
| 1017 #include "policy/policy_constants.h" | 1017 #include "policy/policy_constants.h" |
| 1018 #include "policy/proto/cloud_policy.pb.h" | 1018 #include "policy/proto/cloud_policy.pb.h" |
| 1019 | 1019 |
| 1020 using google::protobuf::RepeatedPtrField; | 1020 using google::protobuf::RepeatedPtrField; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1038 base::ListValue* list_value = new base::ListValue; | 1038 base::ListValue* list_value = new base::ListValue; |
| 1039 RepeatedPtrField<std::string>::const_iterator entry; | 1039 RepeatedPtrField<std::string>::const_iterator entry; |
| 1040 for (entry = string_list.entries().begin(); | 1040 for (entry = string_list.entries().begin(); |
| 1041 entry != string_list.entries().end(); ++entry) { | 1041 entry != string_list.entries().end(); ++entry) { |
| 1042 list_value->AppendString(*entry); | 1042 list_value->AppendString(*entry); |
| 1043 } | 1043 } |
| 1044 return list_value; | 1044 return list_value; |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 base::Value* DecodeJson(const std::string& json) { | 1047 base::Value* DecodeJson(const std::string& json) { |
| 1048 scoped_ptr<base::Value> root = | 1048 std::unique_ptr<base::Value> root = |
| 1049 base::JSONReader::Read(json, base::JSON_ALLOW_TRAILING_COMMAS); | 1049 base::JSONReader::Read(json, base::JSON_ALLOW_TRAILING_COMMAS); |
| 1050 | 1050 |
| 1051 if (!root) | 1051 if (!root) |
| 1052 LOG(WARNING) << "Invalid JSON string, ignoring: " << json; | 1052 LOG(WARNING) << "Invalid JSON string, ignoring: " << json; |
| 1053 | 1053 |
| 1054 // Accept any Value type that parsed as JSON, and leave it to the handler to | 1054 // Accept any Value type that parsed as JSON, and leave it to the handler to |
| 1055 // convert and check the concrete type. | 1055 // convert and check the concrete type. |
| 1056 return root.release(); | 1056 return root.release(); |
| 1057 } | 1057 } |
| 1058 | 1058 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 # _WriteAppRestrictions body | 1166 # _WriteAppRestrictions body |
| 1167 f.write('<restrictions xmlns:android="' | 1167 f.write('<restrictions xmlns:android="' |
| 1168 'http://schemas.android.com/apk/res/android">\n\n') | 1168 'http://schemas.android.com/apk/res/android">\n\n') |
| 1169 for policy in policies: | 1169 for policy in policies: |
| 1170 if policy.is_supported and policy.restriction_type != 'invalid': | 1170 if policy.is_supported and policy.restriction_type != 'invalid': |
| 1171 WriteAppRestriction(policy) | 1171 WriteAppRestriction(policy) |
| 1172 f.write('</restrictions>') | 1172 f.write('</restrictions>') |
| 1173 | 1173 |
| 1174 if __name__ == '__main__': | 1174 if __name__ == '__main__': |
| 1175 sys.exit(main()) | 1175 sys.exit(main()) |
| OLD | NEW |