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