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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 scoped_ptr<base::DictionaryValue> shill_properties) { | 219 scoped_ptr<base::DictionaryValue> shill_properties) { |
219 scoped_ptr<base::DictionaryValue> onc_network( | 220 scoped_ptr<base::DictionaryValue> onc_network( |
220 onc::TranslateShillServiceToONCPart( | 221 onc::TranslateShillServiceToONCPart( |
221 *shill_properties, ::onc::ONC_SOURCE_UNKNOWN, | 222 *shill_properties, ::onc::ONC_SOURCE_UNKNOWN, |
222 &onc::kNetworkWithStateSignature)); | 223 &onc::kNetworkWithStateSignature)); |
223 callback.Run(service_path, *onc_network); | 224 callback.Run(service_path, *onc_network); |
224 } | 225 } |
225 | 226 |
226 // SetProperties | 227 // SetProperties |
227 | 228 |
228 void ManagedNetworkConfigurationHandlerImpl::SetProperties( | 229 void ManagedNetworkConfigurationHandlerImpl::SetProperties( |
pneubeck (no reviews)
2014/11/18 13:21:38
since you seem to prefer SetProperties to do a mer
stevenjb
2014/11/18 23:12:06
I'm not sure I understand what you mean.
If by "m
| |
229 const std::string& service_path, | 230 const std::string& service_path, |
230 const base::DictionaryValue& user_settings, | 231 const base::DictionaryValue& user_settings, |
231 const base::Closure& callback, | 232 const base::Closure& callback, |
232 const network_handler::ErrorCallback& error_callback) const { | 233 const network_handler::ErrorCallback& error_callback) const { |
233 const NetworkState* state = | 234 const NetworkState* state = |
234 network_state_handler_->GetNetworkStateFromServicePath( | 235 network_state_handler_->GetNetworkStateFromServicePath( |
235 service_path, true /* configured_only */); | 236 service_path, true /* configured_only */); |
236 if (!state) { | 237 if (!state) { |
237 InvokeErrorCallback(service_path, error_callback, kUnknownNetwork); | 238 InvokeErrorCallback(service_path, error_callback, kUnknownNetwork); |
238 return; | 239 return; |
(...skipping 19 matching lines...) Expand all 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. | |
pneubeck (no reviews)
2014/11/18 13:21:38
as you mentioned in your review-comment you need i
stevenjb
2014/11/18 23:12:06
Sorry, I assumed it was the validation that was fa
pneubeck (no reviews)
2014/11/19 06:59:39
I guess, originally you ran into issues with the v
| |
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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 properties->SetWithoutPathExpansion(shill::kIPConfigsProperty, ip_configs); | 721 properties->SetWithoutPathExpansion(shill::kIPConfigsProperty, ip_configs); |
712 } | 722 } |
713 | 723 |
714 void ManagedNetworkConfigurationHandlerImpl::GetPropertiesCallback( | 724 void ManagedNetworkConfigurationHandlerImpl::GetPropertiesCallback( |
715 GetDevicePropertiesCallback send_callback, | 725 GetDevicePropertiesCallback send_callback, |
716 const std::string& service_path, | 726 const std::string& service_path, |
717 const base::DictionaryValue& shill_properties) { | 727 const base::DictionaryValue& shill_properties) { |
718 scoped_ptr<base::DictionaryValue> shill_properties_copy( | 728 scoped_ptr<base::DictionaryValue> shill_properties_copy( |
719 shill_properties.DeepCopy()); | 729 shill_properties.DeepCopy()); |
720 | 730 |
721 // Add associated Device properties before the ONC translation. | 731 std::string type; |
722 GetDeviceStateProperties(service_path, shill_properties_copy.get()); | 732 shill_properties_copy->GetStringWithoutPathExpansion(shill::kTypeProperty, |
733 &type); | |
734 // Add associated DeviceState properties for non-VPN networks. | |
735 if (type != shill::kTypeVPN) | |
736 GetDeviceStateProperties(service_path, shill_properties_copy.get()); | |
723 | 737 |
724 // Only request Device properties for Cellular networks with a valid device. | 738 // Only request additional Device properties for Cellular networks with a |
725 std::string type, device_path; | 739 // valid device. |
740 std::string device_path; | |
726 if (!network_device_handler_ || | 741 if (!network_device_handler_ || |
727 !shill_properties_copy->GetStringWithoutPathExpansion( | |
728 shill::kTypeProperty, &type) || | |
729 type != shill::kTypeCellular || | 742 type != shill::kTypeCellular || |
730 !shill_properties_copy->GetStringWithoutPathExpansion( | 743 !shill_properties_copy->GetStringWithoutPathExpansion( |
731 shill::kDeviceProperty, &device_path) || | 744 shill::kDeviceProperty, &device_path) || |
732 device_path.empty()) { | 745 device_path.empty()) { |
733 send_callback.Run(service_path, shill_properties_copy.Pass()); | 746 send_callback.Run(service_path, shill_properties_copy.Pass()); |
734 return; | 747 return; |
735 } | 748 } |
736 | 749 |
737 // Request the device properties. On success or failure pass (a possibly | 750 // Request the device properties. On success or failure pass (a possibly |
738 // modified) |shill_properties| to |send_callback|. | 751 // modified) |shill_properties| to |send_callback|. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 scoped_ptr<base::DictionaryValue> network_properties, | 784 scoped_ptr<base::DictionaryValue> network_properties, |
772 GetDevicePropertiesCallback send_callback, | 785 GetDevicePropertiesCallback send_callback, |
773 const std::string& error_name, | 786 const std::string& error_name, |
774 scoped_ptr<base::DictionaryValue> error_data) { | 787 scoped_ptr<base::DictionaryValue> error_data) { |
775 NET_LOG_ERROR("Error getting device properties", service_path); | 788 NET_LOG_ERROR("Error getting device properties", service_path); |
776 send_callback.Run(service_path, network_properties.Pass()); | 789 send_callback.Run(service_path, network_properties.Pass()); |
777 } | 790 } |
778 | 791 |
779 | 792 |
780 } // namespace chromeos | 793 } // namespace chromeos |
OLD | NEW |