Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 &onc::kNetworkWithStateSignature)); | 219 &onc::kNetworkWithStateSignature)); |
| 220 callback.Run(service_path, *onc_network); | 220 callback.Run(service_path, *onc_network); |
| 221 } | 221 } |
| 222 | 222 |
| 223 // SetProperties | 223 // SetProperties |
| 224 | 224 |
| 225 void ManagedNetworkConfigurationHandlerImpl::SetProperties( | 225 void ManagedNetworkConfigurationHandlerImpl::SetProperties( |
| 226 const std::string& service_path, | 226 const std::string& service_path, |
| 227 const base::DictionaryValue& user_settings, | 227 const base::DictionaryValue& user_settings, |
| 228 const base::Closure& callback, | 228 const base::Closure& callback, |
| 229 const network_handler::ErrorCallback& error_callback) const { | 229 const network_handler::ErrorCallback& error_callback) { |
| 230 const NetworkState* state = | 230 const NetworkState* state = |
| 231 network_state_handler_->GetNetworkStateFromServicePath( | 231 network_state_handler_->GetNetworkStateFromServicePath( |
| 232 service_path, true /* configured_only */); | 232 service_path, true /* configured_only */); |
| 233 if (!state) { | 233 if (!state) { |
| 234 InvokeErrorCallback(service_path, error_callback, kUnknownNetwork); | 234 InvokeErrorCallback(service_path, error_callback, kUnknownNetwork); |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| 238 std::string guid = state->guid(); | 238 std::string guid = state->guid(); |
| 239 DCHECK(!guid.empty()); | 239 DCHECK(!guid.empty()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 VLOG(2) << "This configuration is " << (network_policy ? "" : "not ") | 298 VLOG(2) << "This configuration is " << (network_policy ? "" : "not ") |
| 299 << "managed."; | 299 << "managed."; |
| 300 | 300 |
| 301 scoped_ptr<base::DictionaryValue> shill_dictionary( | 301 scoped_ptr<base::DictionaryValue> shill_dictionary( |
| 302 policy_util::CreateShillConfiguration(*profile, | 302 policy_util::CreateShillConfiguration(*profile, |
| 303 guid, | 303 guid, |
| 304 &policies->global_network_config, | 304 &policies->global_network_config, |
| 305 network_policy, | 305 network_policy, |
| 306 validated_user_settings.get())); | 306 validated_user_settings.get())); |
| 307 | 307 |
| 308 // 'Carrier' needs to be handled specially if set. | |
|
pneubeck (no reviews)
2015/03/27 18:26:46
BIG NOTE:
you do this now only for SetProperties b
stevenjb
2015/03/27 23:18:04
I prefer keeping this as an ONC special case inste
| |
| 309 base::DictionaryValue* cellular; | |
|
pneubeck (no reviews)
2015/03/27 18:26:46
pls initialize to nullptr
stevenjb
2015/03/27 23:18:04
We always disagree on this. It is really not neces
| |
| 310 if (validated_user_settings->GetDictionaryWithoutPathExpansion( | |
| 311 ::onc::network_config::kCellular, &cellular)) { | |
| 312 std::string carrier; | |
| 313 if (cellular->GetStringWithoutPathExpansion(::onc::cellular::kCarrier, | |
| 314 &carrier)) { | |
| 315 network_device_handler_->SetCarrier( | |
| 316 state->device_path(), carrier, | |
|
pneubeck (no reviews)
2015/03/27 18:26:46
do you have to check whether device_path is valid?
stevenjb
2015/03/27 23:18:04
device_path must always be valid for NetworkState.
| |
| 317 base::Bind( | |
| 318 &ManagedNetworkConfigurationHandlerImpl::SetShillProperties, | |
|
pneubeck (no reviews)
2015/03/27 18:26:46
We really need a helper to collect callbacks of se
stevenjb
2015/03/27 23:18:04
Agreed.
| |
| 319 weak_ptr_factory_.GetWeakPtr(), service_path, | |
| 320 base::Passed(&shill_dictionary), callback, error_callback), | |
| 321 error_callback); | |
| 322 return; | |
| 323 } | |
| 324 } | |
| 325 | |
| 326 SetShillProperties(service_path, shill_dictionary.Pass(), callback, | |
| 327 error_callback); | |
| 328 } | |
| 329 | |
| 330 void ManagedNetworkConfigurationHandlerImpl::SetShillProperties( | |
| 331 const std::string& service_path, | |
| 332 scoped_ptr<base::DictionaryValue> shill_dictionary, | |
| 333 const base::Closure& callback, | |
| 334 const network_handler::ErrorCallback& error_callback) { | |
| 308 network_configuration_handler_->SetShillProperties( | 335 network_configuration_handler_->SetShillProperties( |
| 309 service_path, *shill_dictionary, | 336 service_path, *shill_dictionary, |
| 310 NetworkConfigurationObserver::SOURCE_USER_ACTION, callback, | 337 NetworkConfigurationObserver::SOURCE_USER_ACTION, callback, |
| 311 error_callback); | 338 error_callback); |
| 312 } | 339 } |
| 313 | 340 |
| 314 void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration( | 341 void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration( |
| 315 const std::string& userhash, | 342 const std::string& userhash, |
| 316 const base::DictionaryValue& properties, | 343 const base::DictionaryValue& properties, |
| 317 const network_handler::StringResultCallback& callback, | 344 const network_handler::StringResultCallback& callback, |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 801 scoped_ptr<base::DictionaryValue> network_properties, | 828 scoped_ptr<base::DictionaryValue> network_properties, |
| 802 GetDevicePropertiesCallback send_callback, | 829 GetDevicePropertiesCallback send_callback, |
| 803 const std::string& error_name, | 830 const std::string& error_name, |
| 804 scoped_ptr<base::DictionaryValue> error_data) { | 831 scoped_ptr<base::DictionaryValue> error_data) { |
| 805 NET_LOG_ERROR("Error getting device properties", service_path); | 832 NET_LOG_ERROR("Error getting device properties", service_path); |
| 806 send_callback.Run(service_path, network_properties.Pass()); | 833 send_callback.Run(service_path, network_properties.Pass()); |
| 807 } | 834 } |
| 808 | 835 |
| 809 | 836 |
| 810 } // namespace chromeos | 837 } // namespace chromeos |
| OLD | NEW |