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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 void GetManagedProperties(const std::string& network_guid, | 41 void GetManagedProperties(const std::string& network_guid, |
42 base::DictionaryValue* managed_properties, | 42 base::DictionaryValue* managed_properties, |
43 std::string* error) override; | 43 std::string* error) override; |
44 | 44 |
45 void GetState(const std::string& network_guid, | 45 void GetState(const std::string& network_guid, |
46 base::DictionaryValue* properties, | 46 base::DictionaryValue* properties, |
47 std::string* error) override; | 47 std::string* error) override; |
48 | 48 |
49 void SetProperties(const std::string& network_guid, | 49 void SetProperties(const std::string& network_guid, |
50 scoped_ptr<base::DictionaryValue> properties, | 50 std::unique_ptr<base::DictionaryValue> properties, |
51 std::string* error) override; | 51 std::string* error) override; |
52 | 52 |
53 void CreateNetwork(bool shared, | 53 void CreateNetwork(bool shared, |
54 scoped_ptr<base::DictionaryValue> properties, | 54 std::unique_ptr<base::DictionaryValue> properties, |
55 std::string* network_guid, | 55 std::string* network_guid, |
56 std::string* error) override; | 56 std::string* error) override; |
57 | 57 |
58 void GetVisibleNetworks(const std::string& network_type, | 58 void GetVisibleNetworks(const std::string& network_type, |
59 base::ListValue* network_list, | 59 base::ListValue* network_list, |
60 bool include_details) override; | 60 bool include_details) override; |
61 | 61 |
62 void RequestNetworkScan() override; | 62 void RequestNetworkScan() override; |
63 | 63 |
64 void StartConnect(const std::string& network_guid, | 64 void StartConnect(const std::string& network_guid, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 base::DictionaryValue* properties, | 185 base::DictionaryValue* properties, |
186 std::string* error) { | 186 std::string* error) { |
187 NetworkList::iterator it = FindNetwork(network_guid); | 187 NetworkList::iterator it = FindNetwork(network_guid); |
188 if (it == networks_.end()) { | 188 if (it == networks_.end()) { |
189 DVLOG(1) << "Network not found:" << network_guid; | 189 DVLOG(1) << "Network not found:" << network_guid; |
190 *error = kErrorNotFound; | 190 *error = kErrorNotFound; |
191 return; | 191 return; |
192 } | 192 } |
193 | 193 |
194 it->connection_state = GetNetworkConnectionState(network_guid); | 194 it->connection_state = GetNetworkConnectionState(network_guid); |
195 scoped_ptr<base::DictionaryValue> network(it->ToValue(false)); | 195 std::unique_ptr<base::DictionaryValue> network(it->ToValue(false)); |
196 properties->Swap(network.get()); | 196 properties->Swap(network.get()); |
197 DVLOG(1) << *properties; | 197 DVLOG(1) << *properties; |
198 } | 198 } |
199 | 199 |
200 void WiFiServiceMac::GetManagedProperties( | 200 void WiFiServiceMac::GetManagedProperties( |
201 const std::string& network_guid, | 201 const std::string& network_guid, |
202 base::DictionaryValue* managed_properties, | 202 base::DictionaryValue* managed_properties, |
203 std::string* error) { | 203 std::string* error) { |
204 *error = kErrorNotImplemented; | 204 *error = kErrorNotImplemented; |
205 } | 205 } |
206 | 206 |
207 void WiFiServiceMac::GetState(const std::string& network_guid, | 207 void WiFiServiceMac::GetState(const std::string& network_guid, |
208 base::DictionaryValue* properties, | 208 base::DictionaryValue* properties, |
209 std::string* error) { | 209 std::string* error) { |
210 *error = kErrorNotImplemented; | 210 *error = kErrorNotImplemented; |
211 } | 211 } |
212 | 212 |
213 void WiFiServiceMac::SetProperties( | 213 void WiFiServiceMac::SetProperties( |
214 const std::string& network_guid, | 214 const std::string& network_guid, |
215 scoped_ptr<base::DictionaryValue> properties, | 215 std::unique_ptr<base::DictionaryValue> properties, |
216 std::string* error) { | 216 std::string* error) { |
217 base::DictionaryValue* existing_properties; | 217 base::DictionaryValue* existing_properties; |
218 // If the network properties already exist, don't override previously set | 218 // If the network properties already exist, don't override previously set |
219 // properties, unless they are set in |properties|. | 219 // properties, unless they are set in |properties|. |
220 if (network_properties_.GetDictionaryWithoutPathExpansion( | 220 if (network_properties_.GetDictionaryWithoutPathExpansion( |
221 network_guid, &existing_properties)) { | 221 network_guid, &existing_properties)) { |
222 existing_properties->MergeDictionary(properties.get()); | 222 existing_properties->MergeDictionary(properties.get()); |
223 } else { | 223 } else { |
224 network_properties_.SetWithoutPathExpansion(network_guid, | 224 network_properties_.SetWithoutPathExpansion(network_guid, |
225 properties.release()); | 225 properties.release()); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 void WiFiServiceMac::CreateNetwork( | 229 void WiFiServiceMac::CreateNetwork( |
230 bool shared, | 230 bool shared, |
231 scoped_ptr<base::DictionaryValue> properties, | 231 std::unique_ptr<base::DictionaryValue> properties, |
232 std::string* network_guid, | 232 std::string* network_guid, |
233 std::string* error) { | 233 std::string* error) { |
234 NetworkProperties network_properties; | 234 NetworkProperties network_properties; |
235 if (!network_properties.UpdateFromValue(*properties)) { | 235 if (!network_properties.UpdateFromValue(*properties)) { |
236 *error = kErrorInvalidData; | 236 *error = kErrorInvalidData; |
237 return; | 237 return; |
238 } | 238 } |
239 | 239 |
240 std::string guid = network_properties.ssid; | 240 std::string guid = network_properties.ssid; |
241 if (FindNetwork(guid) != networks_.end()) { | 241 if (FindNetwork(guid) != networks_.end()) { |
(...skipping 13 matching lines...) Expand all Loading... |
255 network_type != onc::network_type::kWiFi) { | 255 network_type != onc::network_type::kWiFi) { |
256 return; | 256 return; |
257 } | 257 } |
258 | 258 |
259 if (networks_.empty()) | 259 if (networks_.empty()) |
260 UpdateNetworks(); | 260 UpdateNetworks(); |
261 | 261 |
262 for (NetworkList::const_iterator it = networks_.begin(); | 262 for (NetworkList::const_iterator it = networks_.begin(); |
263 it != networks_.end(); | 263 it != networks_.end(); |
264 ++it) { | 264 ++it) { |
265 scoped_ptr<base::DictionaryValue> network(it->ToValue(!include_details)); | 265 std::unique_ptr<base::DictionaryValue> network( |
| 266 it->ToValue(!include_details)); |
266 network_list->Append(network.release()); | 267 network_list->Append(network.release()); |
267 } | 268 } |
268 } | 269 } |
269 | 270 |
270 void WiFiServiceMac::RequestNetworkScan() { | 271 void WiFiServiceMac::RequestNetworkScan() { |
271 DVLOG(1) << "*** RequestNetworkScan"; | 272 DVLOG(1) << "*** RequestNetworkScan"; |
272 UpdateNetworks(); | 273 UpdateNetworks(); |
273 } | 274 } |
274 | 275 |
275 void WiFiServiceMac::StartConnect(const std::string& network_guid, | 276 void WiFiServiceMac::StartConnect(const std::string& network_guid, |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 DVLOG(1) << "NotifyNetworkChanged: " << network_guid; | 614 DVLOG(1) << "NotifyNetworkChanged: " << network_guid; |
614 NetworkGuidList changed_networks(1, network_guid); | 615 NetworkGuidList changed_networks(1, network_guid); |
615 event_task_runner_->PostTask( | 616 event_task_runner_->PostTask( |
616 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); | 617 FROM_HERE, base::Bind(networks_changed_observer_, changed_networks)); |
617 } | 618 } |
618 | 619 |
619 // static | 620 // static |
620 WiFiService* WiFiService::Create() { return new WiFiServiceMac(); } | 621 WiFiService* WiFiService::Create() { return new WiFiServiceMac(); } |
621 | 622 |
622 } // namespace wifi | 623 } // namespace wifi |
OLD | NEW |