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

Side by Side Diff: chrome/browser/policy/configuration_policy_handler_chromeos.cc

Issue 11469026: Extending ONC validator's logging. Completing toplevel validation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@add_error_handling_to_validator
Patch Set: Initial patch. Created 8 years 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 // 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::string json_error; 52 std::string json_error;
53 scoped_ptr<base::DictionaryValue> root_dict = 53 scoped_ptr<base::DictionaryValue> root_dict =
54 onc::ReadDictionaryFromJson(onc_blob, &json_error); 54 onc::ReadDictionaryFromJson(onc_blob, &json_error);
55 if (root_dict.get() == NULL) { 55 if (root_dict.get() == NULL) {
56 errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_PARSE_ERROR, 56 errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_PARSE_FAILED,
57 json_error); 57 json_error);
58 return false; 58 return false;
59 } 59 }
60 60
61 // Validate the ONC dictionary. We are liberal and ignore unknown field 61 // Validate the ONC dictionary. We are liberal and ignore unknown field
62 // names and ignore invalid field names in kRecommended arrays. 62 // names and ignore invalid field names in kRecommended arrays.
63 onc::Validator validator(false, // Ignore unknown fields. 63 onc::Validator validator(false, // Ignore unknown fields.
64 false, // Ignore invalid recommended field names. 64 false, // Ignore invalid recommended field names.
65 true, // Fail on missing fields. 65 true, // Fail on missing fields.
66 true); // Validate for managed ONC 66 true); // Validate for managed ONC
67 67
68 // ONC policies are always unencrypted. 68 // ONC policies are always unencrypted.
69 onc::Validator::Result validation_result;
69 root_dict = validator.ValidateAndRepairObject( 70 root_dict = validator.ValidateAndRepairObject(
70 &onc::kUnencryptedConfigurationSignature, 71 &onc::kToplevelConfigurationSignature, *root_dict, &validation_result);
71 *root_dict); 72 if (validation_result == onc::Validator::VALID_WITH_WARNINGS) {
73 errors->AddError(policy_name(),
74 IDS_POLICY_NETWORK_CONFIG_VALID_WITH_WARNINGS);
75 } else if (validation_result == onc::Validator::INVALID) {
76 errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_INVALID);
77 }
72 78
73 if (root_dict.get() == NULL) { 79 // In any case, don't reject the policy as some networks or certificates
74 errors->AddError(policy_name(), IDS_POLICY_NETWORK_CONFIG_PARSE_ERROR); 80 // could still be applied.
75 // Don't reject the policy, as some networks or certificates could still
76 // be applied.
77 return true;
78 }
79 } 81 }
80 82
81 return true; 83 return true;
82 } 84 }
83 85
84 void NetworkConfigurationPolicyHandler::ApplyPolicySettings( 86 void NetworkConfigurationPolicyHandler::ApplyPolicySettings(
85 const PolicyMap& policies, 87 const PolicyMap& policies,
86 PrefValueMap* prefs) { 88 PrefValueMap* prefs) {
87 // Network policy is read directly from the provider and injected into 89 // Network policy is read directly from the provider and injected into
88 // NetworkLibrary, so no need to convert the policy settings into prefs. 90 // NetworkLibrary, so no need to convert the policy settings into prefs.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 base::DictionaryValue* app_dict = new base::DictionaryValue(); 197 base::DictionaryValue* app_dict = new base::DictionaryValue();
196 app_dict->SetString(ash::kPinnedAppsPrefAppIDPath, id); 198 app_dict->SetString(ash::kPinnedAppsPrefAppIDPath, id);
197 pinned_apps_list->Append(app_dict); 199 pinned_apps_list->Append(app_dict);
198 } 200 }
199 } 201 }
200 prefs->SetValue(pref_path(), pinned_apps_list); 202 prefs->SetValue(pref_path(), pinned_apps_list);
201 } 203 }
202 } 204 }
203 205
204 } // namespace policy 206 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698