OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chromeos/network/managed_network_configuration_handler_impl.h" | 5 #include "chromeos/network/managed_network_configuration_handler_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chromeos/network/network_device_handler.h" | 23 #include "chromeos/network/network_device_handler.h" |
24 #include "chromeos/network/network_event_log.h" | 24 #include "chromeos/network/network_event_log.h" |
25 #include "chromeos/network/network_policy_observer.h" | 25 #include "chromeos/network/network_policy_observer.h" |
26 #include "chromeos/network/network_profile.h" | 26 #include "chromeos/network/network_profile.h" |
27 #include "chromeos/network/network_profile_handler.h" | 27 #include "chromeos/network/network_profile_handler.h" |
28 #include "chromeos/network/network_state.h" | 28 #include "chromeos/network/network_state.h" |
29 #include "chromeos/network/network_state_handler.h" | 29 #include "chromeos/network/network_state_handler.h" |
30 #include "chromeos/network/network_ui_data.h" | 30 #include "chromeos/network/network_ui_data.h" |
31 #include "chromeos/network/onc/onc_merger.h" | 31 #include "chromeos/network/onc/onc_merger.h" |
32 #include "chromeos/network/onc/onc_signature.h" | 32 #include "chromeos/network/onc/onc_signature.h" |
| 33 #include "chromeos/network/onc/onc_translation_tables.h" |
33 #include "chromeos/network/onc/onc_translator.h" | 34 #include "chromeos/network/onc/onc_translator.h" |
34 #include "chromeos/network/onc/onc_validator.h" | 35 #include "chromeos/network/onc/onc_validator.h" |
35 #include "chromeos/network/policy_util.h" | 36 #include "chromeos/network/policy_util.h" |
36 #include "chromeos/network/shill_property_util.h" | 37 #include "chromeos/network/shill_property_util.h" |
37 #include "components/onc/onc_constants.h" | 38 #include "components/onc/onc_constants.h" |
38 #include "third_party/cros_system_api/dbus/service_constants.h" | 39 #include "third_party/cros_system_api/dbus/service_constants.h" |
39 | 40 |
40 namespace chromeos { | 41 namespace chromeos { |
41 | 42 |
42 namespace { | 43 namespace { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 259 |
259 VLOG(2) << "SetProperties: Found GUID " << guid << " and profile " | 260 VLOG(2) << "SetProperties: Found GUID " << guid << " and profile " |
260 << profile->ToDebugString(); | 261 << profile->ToDebugString(); |
261 | 262 |
262 const Policies* policies = GetPoliciesForProfile(*profile); | 263 const Policies* policies = GetPoliciesForProfile(*profile); |
263 if (!policies) { | 264 if (!policies) { |
264 InvokeErrorCallback(service_path, error_callback, kPoliciesNotInitialized); | 265 InvokeErrorCallback(service_path, error_callback, kPoliciesNotInitialized); |
265 return; | 266 return; |
266 } | 267 } |
267 | 268 |
| 269 // We need to ensure that required configuration properties (e.g. Type) are |
| 270 // included for ONC validation. |
| 271 scoped_ptr<base::DictionaryValue> user_settings_copy( |
| 272 network_util::TranslateNetworkConfigurationStateToONC(state)); |
| 273 user_settings_copy->MergeDictionary(&user_settings); |
| 274 |
268 // Validate the ONC dictionary. We are liberal and ignore unknown field | 275 // Validate the ONC dictionary. We are liberal and ignore unknown field |
269 // names. User settings are only partial ONC, thus we ignore missing fields. | 276 // names. User settings are only partial ONC, thus we ignore missing fields. |
270 onc::Validator validator(false, // Ignore unknown fields. | 277 onc::Validator validator(false, // Ignore unknown fields. |
271 false, // Ignore invalid recommended field names. | 278 false, // Ignore invalid recommended field names. |
272 false, // Ignore missing fields. | 279 false, // Ignore missing fields. |
273 false); // This ONC does not come from policy. | 280 false); // This ONC does not come from policy. |
274 | 281 |
275 onc::Validator::Result validation_result; | 282 onc::Validator::Result validation_result; |
276 scoped_ptr<base::DictionaryValue> validated_user_settings = | 283 scoped_ptr<base::DictionaryValue> validated_user_settings = |
277 validator.ValidateAndRepairObject( | 284 validator.ValidateAndRepairObject( |
278 &onc::kNetworkConfigurationSignature, | 285 &onc::kNetworkConfigurationSignature, |
279 user_settings, | 286 *user_settings_copy, |
280 &validation_result); | 287 &validation_result); |
281 | 288 |
282 if (validation_result == onc::Validator::INVALID) { | 289 if (validation_result == onc::Validator::INVALID) { |
283 InvokeErrorCallback(service_path, error_callback, kInvalidUserSettings); | 290 InvokeErrorCallback(service_path, error_callback, kInvalidUserSettings); |
284 return; | 291 return; |
285 } | 292 } |
286 if (validation_result == onc::Validator::VALID_WITH_WARNINGS) | 293 if (validation_result == onc::Validator::VALID_WITH_WARNINGS) |
287 LOG(WARNING) << "Validation of ONC user settings produced warnings."; | 294 LOG(WARNING) << "Validation of ONC user settings produced warnings."; |
288 | 295 |
289 const base::DictionaryValue* network_policy = | 296 const base::DictionaryValue* network_policy = |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 scoped_ptr<base::DictionaryValue> network_properties, | 777 scoped_ptr<base::DictionaryValue> network_properties, |
771 GetDevicePropertiesCallback send_callback, | 778 GetDevicePropertiesCallback send_callback, |
772 const std::string& error_name, | 779 const std::string& error_name, |
773 scoped_ptr<base::DictionaryValue> error_data) { | 780 scoped_ptr<base::DictionaryValue> error_data) { |
774 NET_LOG_ERROR("Error getting device properties", service_path); | 781 NET_LOG_ERROR("Error getting device properties", service_path); |
775 send_callback.Run(service_path, network_properties.Pass()); | 782 send_callback.Run(service_path, network_properties.Pass()); |
776 } | 783 } |
777 | 784 |
778 | 785 |
779 } // namespace chromeos | 786 } // namespace chromeos |
OLD | NEW |