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

Side by Side Diff: chromeos/network/managed_network_configuration_handler_impl.cc

Issue 285233008: Add MacAddress to ONC and networkingPrivate (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: Rebase Created 6 years, 7 months 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 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 NOTREACHED(); 155 NOTREACHED();
156 } else if (profile) { 156 } else if (profile) {
157 NET_LOG_ERROR("Service contains empty or invalid UIData", service_path); 157 NET_LOG_ERROR("Service contains empty or invalid UIData", service_path);
158 // TODO(pneubeck): add a conversion of user configured entries of old 158 // TODO(pneubeck): add a conversion of user configured entries of old
159 // ChromeOS versions. We will have to use a heuristic to determine which 159 // ChromeOS versions. We will have to use a heuristic to determine which
160 // properties _might_ be user configured. 160 // properties _might_ be user configured.
161 } 161 }
162 162
163 scoped_ptr<base::DictionaryValue> properties_copy( 163 scoped_ptr<base::DictionaryValue> properties_copy(
164 shill_properties.DeepCopy()); 164 shill_properties.DeepCopy());
165 // Add the IPConfigs to the dictionary before the ONC translation. 165 // Add associated Device properties before the ONC translation.
166 GetIPConfigs(service_path, properties_copy.get()); 166 GetDeviceProperties(service_path, properties_copy.get());
167 167
168 scoped_ptr<base::DictionaryValue> active_settings( 168 scoped_ptr<base::DictionaryValue> active_settings(
169 onc::TranslateShillServiceToONCPart( 169 onc::TranslateShillServiceToONCPart(
170 *properties_copy, 170 *properties_copy,
171 &onc::kNetworkWithStateSignature)); 171 &onc::kNetworkWithStateSignature));
172 172
173 std::string guid; 173 std::string guid;
174 active_settings->GetStringWithoutPathExpansion(::onc::network_config::kGUID, 174 active_settings->GetStringWithoutPathExpansion(::onc::network_config::kGUID,
175 &guid); 175 &guid);
176 176
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 callback), 216 callback),
217 error_callback); 217 error_callback);
218 } 218 }
219 219
220 void ManagedNetworkConfigurationHandlerImpl::GetPropertiesCallback( 220 void ManagedNetworkConfigurationHandlerImpl::GetPropertiesCallback(
221 const network_handler::DictionaryResultCallback& callback, 221 const network_handler::DictionaryResultCallback& callback,
222 const std::string& service_path, 222 const std::string& service_path,
223 const base::DictionaryValue& shill_properties) { 223 const base::DictionaryValue& shill_properties) {
224 scoped_ptr<base::DictionaryValue> properties_copy( 224 scoped_ptr<base::DictionaryValue> properties_copy(
225 shill_properties.DeepCopy()); 225 shill_properties.DeepCopy());
226 // Add the IPConfigs to the dictionary before the ONC translation. 226 // Add associated Device properties before the ONC translation.
227 GetIPConfigs(service_path, properties_copy.get()); 227 GetDeviceProperties(service_path, properties_copy.get());
228 228
229 scoped_ptr<base::DictionaryValue> onc_network( 229 scoped_ptr<base::DictionaryValue> onc_network(
230 onc::TranslateShillServiceToONCPart( 230 onc::TranslateShillServiceToONCPart(
231 *properties_copy, 231 *properties_copy,
232 &onc::kNetworkWithStateSignature)); 232 &onc::kNetworkWithStateSignature));
233 callback.Run(service_path, *onc_network); 233 callback.Run(service_path, *onc_network);
234 } 234 }
235 235
236 void ManagedNetworkConfigurationHandlerImpl::SetProperties( 236 void ManagedNetworkConfigurationHandlerImpl::SetProperties(
237 const std::string& service_path, 237 const std::string& service_path,
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 } 606 }
607 607
608 void ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork( 608 void ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork(
609 const std::string& service_path) { 609 const std::string& service_path) {
610 if (service_path.empty()) 610 if (service_path.empty())
611 return; 611 return;
612 FOR_EACH_OBSERVER( 612 FOR_EACH_OBSERVER(
613 NetworkPolicyObserver, observers_, PolicyApplied(service_path)); 613 NetworkPolicyObserver, observers_, PolicyApplied(service_path));
614 } 614 }
615 615
616 void ManagedNetworkConfigurationHandlerImpl::GetIPConfigs( 616 void ManagedNetworkConfigurationHandlerImpl::GetDeviceProperties(
617 const std::string& service_path, 617 const std::string& service_path,
618 base::DictionaryValue* properties) { 618 base::DictionaryValue* properties) {
619 std::string connection_state; 619 std::string connection_state;
620 properties->GetStringWithoutPathExpansion( 620 properties->GetStringWithoutPathExpansion(
621 shill::kStateProperty, &connection_state); 621 shill::kStateProperty, &connection_state);
622 if (!NetworkState::StateIsConnected(connection_state)) 622 if (!NetworkState::StateIsConnected(connection_state))
623 return; 623 return;
624 624
625 // Get the IPConfig properties from the device and store them in "IPConfigs" 625 // Get the IPConfig properties from the device and store them in "IPConfigs"
626 // (plural) in the properties dictionary. (Note: Shill only provides a single 626 // (plural) in the properties dictionary. (Note: Shill only provides a single
627 // "IPConfig" property for a network service, but a consumer of this API may 627 // "IPConfig" property for a network service, but a consumer of this API may
628 // want information about all ipv4 and ipv6 IPConfig properties. 628 // want information about all ipv4 and ipv6 IPConfig properties.
629 std::string device; 629 std::string device;
630 properties->GetStringWithoutPathExpansion(shill::kDeviceProperty, &device); 630 properties->GetStringWithoutPathExpansion(shill::kDeviceProperty, &device);
631 const DeviceState* device_state = 631 const DeviceState* device_state =
632 network_state_handler_->GetDeviceState(device); 632 network_state_handler_->GetDeviceState(device);
633 if (!device_state) { 633 if (!device_state) {
634 NET_LOG_ERROR("GetIPConfigs: no device: " + device, service_path); 634 NET_LOG_ERROR("GetDeviceProperties: no device: " + device, service_path);
635 return; 635 return;
636 } 636 }
637
638 // Get the hardware MAC address from the DeviceState.
639 if (!device_state->mac_address().empty()) {
640 properties->SetStringWithoutPathExpansion(
641 shill::kAddressProperty, device_state->mac_address());
642 }
643
637 // Convert IPConfig dictionary to a ListValue. 644 // Convert IPConfig dictionary to a ListValue.
638 base::ListValue* ip_configs = new base::ListValue; 645 base::ListValue* ip_configs = new base::ListValue;
639 for (base::DictionaryValue::Iterator iter(device_state->ip_configs()); 646 for (base::DictionaryValue::Iterator iter(device_state->ip_configs());
640 !iter.IsAtEnd(); iter.Advance()) { 647 !iter.IsAtEnd(); iter.Advance()) {
641 ip_configs->Append(iter.value().DeepCopy()); 648 ip_configs->Append(iter.value().DeepCopy());
642 } 649 }
643 properties->SetWithoutPathExpansion(shill::kIPConfigsProperty, ip_configs); 650 properties->SetWithoutPathExpansion(shill::kIPConfigsProperty, ip_configs);
644 } 651 }
645 652
646 } // namespace chromeos 653 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/managed_network_configuration_handler_impl.h ('k') | chromeos/network/network_state_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698