| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/wifi/wifi_service.h" | 5 #include "components/wifi/wifi_service.h" |
| 6 | 6 |
| 7 #import <CoreWLAN/CoreWLAN.h> | 7 #import <CoreWLAN/CoreWLAN.h> |
| 8 #import <netinet/in.h> | 8 #import <netinet/in.h> |
| 9 #import <SystemConfiguration/SystemConfiguration.h> | 9 #import <SystemConfiguration/SystemConfiguration.h> |
| 10 | 10 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 std::unique_ptr<base::DictionaryValue> properties, | 218 std::unique_ptr<base::DictionaryValue> properties, |
| 219 std::string* error) { | 219 std::string* error) { |
| 220 base::DictionaryValue* existing_properties; | 220 base::DictionaryValue* existing_properties; |
| 221 // If the network properties already exist, don't override previously set | 221 // If the network properties already exist, don't override previously set |
| 222 // properties, unless they are set in |properties|. | 222 // properties, unless they are set in |properties|. |
| 223 if (network_properties_.GetDictionaryWithoutPathExpansion( | 223 if (network_properties_.GetDictionaryWithoutPathExpansion( |
| 224 network_guid, &existing_properties)) { | 224 network_guid, &existing_properties)) { |
| 225 existing_properties->MergeDictionary(properties.get()); | 225 existing_properties->MergeDictionary(properties.get()); |
| 226 } else { | 226 } else { |
| 227 network_properties_.SetWithoutPathExpansion(network_guid, | 227 network_properties_.SetWithoutPathExpansion(network_guid, |
| 228 properties.release()); | 228 std::move(properties)); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 void WiFiServiceMac::CreateNetwork( | 232 void WiFiServiceMac::CreateNetwork( |
| 233 bool shared, | 233 bool shared, |
| 234 std::unique_ptr<base::DictionaryValue> properties, | 234 std::unique_ptr<base::DictionaryValue> properties, |
| 235 std::string* network_guid, | 235 std::string* network_guid, |
| 236 std::string* error) { | 236 std::string* error) { |
| 237 NetworkProperties network_properties; | 237 NetworkProperties network_properties; |
| 238 if (!network_properties.UpdateFromValue(*properties)) { | 238 if (!network_properties.UpdateFromValue(*properties)) { |
| 239 *error = kErrorInvalidData; | 239 *error = kErrorInvalidData; |
| 240 return; | 240 return; |
| 241 } | 241 } |
| 242 | 242 |
| 243 std::string guid = network_properties.ssid; | 243 std::string guid = network_properties.ssid; |
| 244 if (FindNetwork(guid) != networks_.end()) { | 244 if (FindNetwork(guid) != networks_.end()) { |
| 245 *error = kErrorInvalidData; | 245 *error = kErrorInvalidData; |
| 246 return; | 246 return; |
| 247 } | 247 } |
| 248 network_properties_.SetWithoutPathExpansion(guid, | 248 network_properties_.SetWithoutPathExpansion(guid, std::move(properties)); |
| 249 properties.release()); | |
| 250 *network_guid = guid; | 249 *network_guid = guid; |
| 251 } | 250 } |
| 252 | 251 |
| 253 void WiFiServiceMac::GetVisibleNetworks(const std::string& network_type, | 252 void WiFiServiceMac::GetVisibleNetworks(const std::string& network_type, |
| 254 base::ListValue* network_list, | 253 base::ListValue* network_list, |
| 255 bool include_details) { | 254 bool include_details) { |
| 256 if (!network_type.empty() && | 255 if (!network_type.empty() && |
| 257 network_type != onc::network_type::kAllTypes && | 256 network_type != onc::network_type::kAllTypes && |
| 258 network_type != onc::network_type::kWiFi) { | 257 network_type != onc::network_type::kWiFi) { |
| 259 return; | 258 return; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 DVLOG(1) << "NotifyNetworkChanged: " << network_guid; | 616 DVLOG(1) << "NotifyNetworkChanged: " << network_guid; |
| 618 NetworkGuidList changed_networks(1, network_guid); | 617 NetworkGuidList changed_networks(1, network_guid); |
| 619 event_task_runner_->PostTask( | 618 event_task_runner_->PostTask( |
| 620 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); | 619 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); |
| 621 } | 620 } |
| 622 | 621 |
| 623 // static | 622 // static |
| 624 WiFiService* WiFiService::Create() { return new WiFiServiceMac(); } | 623 WiFiService* WiFiService::Create() { return new WiFiServiceMac(); } |
| 625 | 624 |
| 626 } // namespace wifi | 625 } // namespace wifi |
| OLD | NEW |