OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/arc/net/arc_net_host_impl.h" | 5 #include "components/arc/net/arc_net_host_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 kGetNetworksListLimit); | 364 kGetNetworksListLimit); |
365 | 365 |
366 // Extract info for each network and add it to the list. | 366 // Extract info for each network and add it to the list. |
367 // Even if there's no WiFi, an empty (size=0) list must be returned and not a | 367 // Even if there's no WiFi, an empty (size=0) list must be returned and not a |
368 // null one. The explicitly sized New() constructor ensures the non-null | 368 // null one. The explicitly sized New() constructor ensures the non-null |
369 // property. | 369 // property. |
370 std::vector<mojom::WifiConfigurationPtr> networks; | 370 std::vector<mojom::WifiConfigurationPtr> networks; |
371 for (const auto& value : *network_properties_list) { | 371 for (const auto& value : *network_properties_list) { |
372 mojom::WifiConfigurationPtr wc = mojom::WifiConfiguration::New(); | 372 mojom::WifiConfigurationPtr wc = mojom::WifiConfiguration::New(); |
373 | 373 |
374 base::DictionaryValue* network_dict = nullptr; | 374 const base::DictionaryValue* network_dict = nullptr; |
375 value->GetAsDictionary(&network_dict); | 375 value.GetAsDictionary(&network_dict); |
376 DCHECK(network_dict); | 376 DCHECK(network_dict); |
377 | 377 |
378 // kName is a post-processed version of kHexSSID. | 378 // kName is a post-processed version of kHexSSID. |
379 std::string tmp; | 379 std::string tmp; |
380 network_dict->GetString(onc::network_config::kName, &tmp); | 380 network_dict->GetString(onc::network_config::kName, &tmp); |
381 DCHECK(!tmp.empty()); | 381 DCHECK(!tmp.empty()); |
382 wc->ssid = tmp; | 382 wc->ssid = tmp; |
383 | 383 |
384 tmp.clear(); | 384 tmp.clear(); |
385 network_dict->GetString(onc::network_config::kGUID, &tmp); | 385 network_dict->GetString(onc::network_config::kGUID, &tmp); |
386 DCHECK(!tmp.empty()); | 386 DCHECK(!tmp.empty()); |
387 wc->guid = tmp; | 387 wc->guid = tmp; |
388 | 388 |
389 base::DictionaryValue* wifi_dict = nullptr; | 389 const base::DictionaryValue* wifi_dict = nullptr; |
390 network_dict->GetDictionary(onc::network_config::kWiFi, &wifi_dict); | 390 network_dict->GetDictionary(onc::network_config::kWiFi, &wifi_dict); |
391 DCHECK(wifi_dict); | 391 DCHECK(wifi_dict); |
392 | 392 |
393 if (!wifi_dict->GetInteger(onc::wifi::kFrequency, &wc->frequency)) | 393 if (!wifi_dict->GetInteger(onc::wifi::kFrequency, &wc->frequency)) |
394 wc->frequency = 0; | 394 wc->frequency = 0; |
395 if (!wifi_dict->GetInteger(onc::wifi::kSignalStrength, | 395 if (!wifi_dict->GetInteger(onc::wifi::kSignalStrength, |
396 &wc->signal_strength)) | 396 &wc->signal_strength)) |
397 wc->signal_strength = 0; | 397 wc->signal_strength = 0; |
398 | 398 |
399 if (!wifi_dict->GetString(onc::wifi::kSecurity, &tmp)) | 399 if (!wifi_dict->GetString(onc::wifi::kSecurity, &tmp)) |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 net_instance->WifiEnabledStateChanged(is_enabled); | 654 net_instance->WifiEnabledStateChanged(is_enabled); |
655 } | 655 } |
656 | 656 |
657 void ArcNetHostImpl::OnShuttingDown() { | 657 void ArcNetHostImpl::OnShuttingDown() { |
658 DCHECK(observing_network_state_); | 658 DCHECK(observing_network_state_); |
659 GetStateHandler()->RemoveObserver(this, FROM_HERE); | 659 GetStateHandler()->RemoveObserver(this, FROM_HERE); |
660 observing_network_state_ = false; | 660 observing_network_state_ = false; |
661 } | 661 } |
662 | 662 |
663 } // namespace arc | 663 } // namespace arc |
OLD | NEW |