OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/policy/configuration_policy_handler_chromeos.h" | 5 #include "chrome/browser/policy/configuration_policy_handler_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 const base::Value* value; | 45 const base::Value* value; |
46 if (!CheckAndGetValue(policies, errors, &value)) | 46 if (!CheckAndGetValue(policies, errors, &value)) |
47 return false; | 47 return false; |
48 | 48 |
49 if (value) { | 49 if (value) { |
50 std::string onc_blob; | 50 std::string onc_blob; |
51 value->GetAsString(&onc_blob); | 51 value->GetAsString(&onc_blob); |
52 scoped_ptr<base::DictionaryValue> root_dict = | 52 scoped_ptr<base::DictionaryValue> root_dict = |
53 onc::ReadDictionaryFromJson(onc_blob); | 53 onc::ReadDictionaryFromJson(onc_blob); |
54 if (root_dict.get() == NULL) { | 54 if (root_dict.get() == NULL) { |
55 errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_PARSE_ERROR); | 55 errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_PARSE_FAILED); |
56 return false; | 56 return false; |
57 } | 57 } |
58 | 58 |
59 // Validate the ONC dictionary. We are liberal and ignore unknown field | 59 // Validate the ONC dictionary. We are liberal and ignore unknown field |
60 // names and ignore invalid field names in kRecommended arrays. | 60 // names and ignore invalid field names in kRecommended arrays. |
61 onc::Validator validator(false, // Ignore unknown fields. | 61 onc::Validator validator(false, // Ignore unknown fields. |
62 false, // Ignore invalid recommended field names. | 62 false, // Ignore invalid recommended field names. |
63 true, // Fail on missing fields. | 63 true, // Fail on missing fields. |
64 true); // Validate for managed ONC | 64 true); // Validate for managed ONC |
65 | 65 |
66 // ONC policies are always unencrypted. | 66 // ONC policies are always unencrypted. |
| 67 onc::Validator::Result validation_result; |
67 root_dict = validator.ValidateAndRepairObject( | 68 root_dict = validator.ValidateAndRepairObject( |
68 &onc::kUnencryptedConfigurationSignature, | 69 &onc::kToplevelConfigurationSignature, *root_dict, &validation_result); |
69 *root_dict); | 70 if (validation_result == onc::Validator::VALID_WITH_WARNINGS) { |
| 71 errors->AddError(policy_name(), |
| 72 IDS_POLICY_NETWORK_CONFIG_IMPORT_PARTIAL); |
| 73 } else if (validation_result == onc::Validator::INVALID) { |
| 74 errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_IMPORT_FAILED); |
| 75 } |
70 | 76 |
71 if (root_dict.get() == NULL) { | 77 // In any case, don't reject the policy as some networks or certificates |
72 errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_PARSE_ERROR); | 78 // could still be applied. |
73 // Don't reject the policy, as some networks or certificates could still | |
74 // be applied. | |
75 return true; | |
76 } | |
77 } | 79 } |
78 | 80 |
79 return true; | 81 return true; |
80 } | 82 } |
81 | 83 |
82 void NetworkConfigurationPolicyHandler::ApplyPolicySettings( | 84 void NetworkConfigurationPolicyHandler::ApplyPolicySettings( |
83 const PolicyMap& policies, | 85 const PolicyMap& policies, |
84 PrefValueMap* prefs) { | 86 PrefValueMap* prefs) { |
85 // Network policy is read directly from the provider and injected into | 87 // Network policy is read directly from the provider and injected into |
86 // NetworkLibrary, so no need to convert the policy settings into prefs. | 88 // NetworkLibrary, so no need to convert the policy settings into prefs. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 base::DictionaryValue* app_dict = new base::DictionaryValue(); | 195 base::DictionaryValue* app_dict = new base::DictionaryValue(); |
194 app_dict->SetString(ash::kPinnedAppsPrefAppIDPath, id); | 196 app_dict->SetString(ash::kPinnedAppsPrefAppIDPath, id); |
195 pinned_apps_list->Append(app_dict); | 197 pinned_apps_list->Append(app_dict); |
196 } | 198 } |
197 } | 199 } |
198 prefs->SetValue(pref_path(), pinned_apps_list); | 200 prefs->SetValue(pref_path(), pinned_apps_list); |
199 } | 201 } |
200 } | 202 } |
201 | 203 |
202 } // namespace policy | 204 } // namespace policy |
OLD | NEW |