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 10 matching lines...) Expand all Loading... |
21 #include "chromeos/network/device_state.h" | 21 #include "chromeos/network/device_state.h" |
22 #include "chromeos/network/network_configuration_handler.h" | 22 #include "chromeos/network/network_configuration_handler.h" |
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/network_util.h" |
31 #include "chromeos/network/onc/onc_merger.h" | 32 #include "chromeos/network/onc/onc_merger.h" |
32 #include "chromeos/network/onc/onc_signature.h" | 33 #include "chromeos/network/onc/onc_signature.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 { |
(...skipping 217 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 and translation to Shill properties. |
| 271 scoped_ptr<base::DictionaryValue> user_settings_copy( |
| 272 user_settings.DeepCopy()); |
| 273 user_settings_copy->SetStringWithoutPathExpansion( |
| 274 ::onc::network_config::kType, |
| 275 network_util::TranslateShillTypeToONC(state->type())); |
| 276 user_settings_copy->MergeDictionary(&user_settings); |
| 277 |
268 // Validate the ONC dictionary. We are liberal and ignore unknown field | 278 // Validate the ONC dictionary. We are liberal and ignore unknown field |
269 // names. User settings are only partial ONC, thus we ignore missing fields. | 279 // names. User settings are only partial ONC, thus we ignore missing fields. |
270 onc::Validator validator(false, // Ignore unknown fields. | 280 onc::Validator validator(false, // Ignore unknown fields. |
271 false, // Ignore invalid recommended field names. | 281 false, // Ignore invalid recommended field names. |
272 false, // Ignore missing fields. | 282 false, // Ignore missing fields. |
273 false); // This ONC does not come from policy. | 283 false); // This ONC does not come from policy. |
274 | 284 |
275 onc::Validator::Result validation_result; | 285 onc::Validator::Result validation_result; |
276 scoped_ptr<base::DictionaryValue> validated_user_settings = | 286 scoped_ptr<base::DictionaryValue> validated_user_settings = |
277 validator.ValidateAndRepairObject( | 287 validator.ValidateAndRepairObject( |
278 &onc::kNetworkConfigurationSignature, | 288 &onc::kNetworkConfigurationSignature, |
279 user_settings, | 289 *user_settings_copy, |
280 &validation_result); | 290 &validation_result); |
281 | 291 |
282 if (validation_result == onc::Validator::INVALID) { | 292 if (validation_result == onc::Validator::INVALID) { |
283 InvokeErrorCallback(service_path, error_callback, kInvalidUserSettings); | 293 InvokeErrorCallback(service_path, error_callback, kInvalidUserSettings); |
284 return; | 294 return; |
285 } | 295 } |
286 if (validation_result == onc::Validator::VALID_WITH_WARNINGS) | 296 if (validation_result == onc::Validator::VALID_WITH_WARNINGS) |
287 LOG(WARNING) << "Validation of ONC user settings produced warnings."; | 297 LOG(WARNING) << "Validation of ONC user settings produced warnings."; |
288 | 298 |
289 const base::DictionaryValue* network_policy = | 299 const base::DictionaryValue* network_policy = |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 properties->SetWithoutPathExpansion(shill::kIPConfigsProperty, ip_configs); | 725 properties->SetWithoutPathExpansion(shill::kIPConfigsProperty, ip_configs); |
716 } | 726 } |
717 | 727 |
718 void ManagedNetworkConfigurationHandlerImpl::GetPropertiesCallback( | 728 void ManagedNetworkConfigurationHandlerImpl::GetPropertiesCallback( |
719 GetDevicePropertiesCallback send_callback, | 729 GetDevicePropertiesCallback send_callback, |
720 const std::string& service_path, | 730 const std::string& service_path, |
721 const base::DictionaryValue& shill_properties) { | 731 const base::DictionaryValue& shill_properties) { |
722 scoped_ptr<base::DictionaryValue> shill_properties_copy( | 732 scoped_ptr<base::DictionaryValue> shill_properties_copy( |
723 shill_properties.DeepCopy()); | 733 shill_properties.DeepCopy()); |
724 | 734 |
725 // Add associated Device properties before the ONC translation. | 735 std::string type; |
726 GetDeviceStateProperties(service_path, shill_properties_copy.get()); | 736 shill_properties_copy->GetStringWithoutPathExpansion(shill::kTypeProperty, |
| 737 &type); |
| 738 // Add associated DeviceState properties for non-VPN networks. |
| 739 if (type != shill::kTypeVPN) |
| 740 GetDeviceStateProperties(service_path, shill_properties_copy.get()); |
727 | 741 |
728 // Only request Device properties for Cellular networks with a valid device. | 742 // Only request additional Device properties for Cellular networks with a |
729 std::string type, device_path; | 743 // valid device. |
| 744 std::string device_path; |
730 if (!network_device_handler_ || | 745 if (!network_device_handler_ || |
731 !shill_properties_copy->GetStringWithoutPathExpansion( | |
732 shill::kTypeProperty, &type) || | |
733 type != shill::kTypeCellular || | 746 type != shill::kTypeCellular || |
734 !shill_properties_copy->GetStringWithoutPathExpansion( | 747 !shill_properties_copy->GetStringWithoutPathExpansion( |
735 shill::kDeviceProperty, &device_path) || | 748 shill::kDeviceProperty, &device_path) || |
736 device_path.empty()) { | 749 device_path.empty()) { |
737 send_callback.Run(service_path, shill_properties_copy.Pass()); | 750 send_callback.Run(service_path, shill_properties_copy.Pass()); |
738 return; | 751 return; |
739 } | 752 } |
740 | 753 |
741 // Request the device properties. On success or failure pass (a possibly | 754 // Request the device properties. On success or failure pass (a possibly |
742 // modified) |shill_properties| to |send_callback|. | 755 // modified) |shill_properties| to |send_callback|. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 scoped_ptr<base::DictionaryValue> network_properties, | 788 scoped_ptr<base::DictionaryValue> network_properties, |
776 GetDevicePropertiesCallback send_callback, | 789 GetDevicePropertiesCallback send_callback, |
777 const std::string& error_name, | 790 const std::string& error_name, |
778 scoped_ptr<base::DictionaryValue> error_data) { | 791 scoped_ptr<base::DictionaryValue> error_data) { |
779 NET_LOG_ERROR("Error getting device properties", service_path); | 792 NET_LOG_ERROR("Error getting device properties", service_path); |
780 send_callback.Run(service_path, network_properties.Pass()); | 793 send_callback.Run(service_path, network_properties.Pass()); |
781 } | 794 } |
782 | 795 |
783 | 796 |
784 } // namespace chromeos | 797 } // namespace chromeos |
OLD | NEW |