Chromium Code Reviews| Index: chromeos/network/network_change_notifier_chromeos.cc |
| diff --git a/chromeos/network/network_change_notifier_chromeos.cc b/chromeos/network/network_change_notifier_chromeos.cc |
| index 84ed8563a3833cabb0275688a01e652f13fb7fee..ade1c564d54c46fbb1201c90e4de1b8864d67d83 100644 |
| --- a/chromeos/network/network_change_notifier_chromeos.cc |
| +++ b/chromeos/network/network_change_notifier_chromeos.cc |
| @@ -10,9 +10,11 @@ |
| #include "base/strings/stringprintf.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| #include "chromeos/network/network_change_notifier_chromeos.h" |
| +#include "chromeos/network/network_configuration_handler.h" |
| #include "chromeos/network/network_event_log.h" |
| #include "chromeos/network/network_state.h" |
| #include "chromeos/network/network_state_handler.h" |
| +#include "chromeos/network/shill_property_util.h" |
| #include "net/base/network_change_notifier.h" |
| #include "net/dns/dns_config_service_posix.h" |
| #include "third_party/cros_system_api/dbus/service_constants.h" |
| @@ -83,6 +85,17 @@ NetworkChangeNotifierChromeos::GetCurrentConnectionType() const { |
| return connection_type_; |
| } |
| +bool NetworkChangeNotifierChromeos::GetCurrentWifiAccessPointInfo( |
| + net::NetworkChangeNotifier::WifiAccessPointInfo* info) { |
| + // Wifi access point information is not provided if the BSSID is empty. |
| + // This assumes the BSSID is never empty when access point information exists. |
| + if (wifi_ap_info_.bssid.empty()) |
| + return false; |
| + |
| + *info = wifi_ap_info_; |
| + return true; |
| +} |
| + |
| void NetworkChangeNotifierChromeos::SuspendDone( |
| const base::TimeDelta& sleep_duration) { |
| // Force invalidation of network resources on resume. |
| @@ -105,6 +118,69 @@ void NetworkChangeNotifierChromeos::DefaultNetworkChanged( |
| NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); |
| if (dns_changed) |
| dns_config_service_->OnNetworkChange(); |
| + |
| + // Reset access point info to prevent reporting of out-dated data. |
| + wifi_ap_info_ = net::NetworkChangeNotifier::WifiAccessPointInfo(); |
| + |
| + // Retrieve access point info for wifi connection. |
| + if (connection_type_ == CONNECTION_WIFI) { |
| + NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| + default_network->path(), |
| + base::Bind(&NetworkChangeNotifierChromeos::ParseWifiAccessPointInfo, |
| + AsWeakPtr()), |
| + network_handler::ErrorCallback()); |
| + } |
| +} |
| + |
| +void NetworkChangeNotifierChromeos::ParseWifiAccessPointInfo( |
| + const std::string &service_path, |
| + const base::DictionaryValue& properties) { |
| + // Return if not the current service. |
| + if (service_path != service_path_) |
| + return; |
| + |
| + // Skip services that contain "_nomap" in the SSID. |
| + std::string ssid = shill_property_util::GetSSIDFromProperties( |
| + properties, NULL); |
| + if (ssid.find("_nomap", 0) != std::string::npos) |
| + return; |
| + |
| + // Parse security info. |
| + std::string security; |
| + properties.GetStringWithoutPathExpansion( |
| + shill::kSecurityProperty, &security); |
| + wifi_ap_info_.security = WIFI_SECURITY_UNKNOWN; |
| + if (security == shill::kSecurityWpa) |
| + wifi_ap_info_.security = WIFI_SECURITY_WPA; |
| + else if (security == shill::kSecurityWep) |
| + wifi_ap_info_.security = WIFI_SECURITY_WEP; |
| + else if (security == shill::kSecurityRsn) |
| + wifi_ap_info_.security = WIFI_SECURITY_RSN; |
| + else if (security == shill::kSecurity8021x) |
| + wifi_ap_info_.security = WIFI_SECURITY_802_1X; |
| + else if (security == shill::kSecurityPsk) |
| + wifi_ap_info_.security = WIFI_SECURITY_PSK; |
| + else if (security == shill::kSecurityNone) |
| + wifi_ap_info_.security = WIFI_SECURITY_NONE; |
| + |
| + properties.GetStringWithoutPathExpansion( |
| + shill::kWifiBSsid, &wifi_ap_info_.bssid); |
| + const base::DictionaryValue* vendor_dict = NULL; |
| + if (!properties.GetDictionaryWithoutPathExpansion( |
| + shill::kWifiVendorInformationProperty, |
| + &vendor_dict)) |
| + return; |
|
stevenjb
2014/07/16 19:57:29
nit: WS after early exit (or, better, use {} after
zqiu1
2014/07/16 20:01:52
Done.
|
| + vendor_dict->GetStringWithoutPathExpansion( |
| + shill::kVendorWPSModelNumberProperty, |
| + &wifi_ap_info_.model_number); |
| + vendor_dict->GetStringWithoutPathExpansion( |
| + shill::kVendorWPSModelNameProperty, |
| + &wifi_ap_info_.model_name); |
| + vendor_dict->GetStringWithoutPathExpansion( |
| + shill::kVendorWPSDeviceNameProperty, |
| + &wifi_ap_info_.device_name); |
| + vendor_dict->GetStringWithoutPathExpansion(shill::kVendorOUIListProperty, |
| + &wifi_ap_info_.oui_list); |
| } |
| void NetworkChangeNotifierChromeos::UpdateState( |