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..59b9a06d552bcffda3519171b752dfc899b1c58a 100644 |
| --- a/chromeos/network/network_change_notifier_chromeos.cc |
| +++ b/chromeos/network/network_change_notifier_chromeos.cc |
| @@ -10,6 +10,7 @@ |
| #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" |
| @@ -83,6 +84,15 @@ NetworkChangeNotifierChromeos::GetCurrentConnectionType() const { |
| return connection_type_; |
| } |
| +bool NetworkChangeNotifierChromeos::GetCurrentWifiApInfo( |
| + net::NetworkChangeNotifier::WifiApInfo &info) { |
|
stevenjb
2014/07/08 00:24:53
*info
zqiu1
2014/07/08 20:47:53
Done.
|
| + if (connection_type_ != CONNECTION_WIFI) |
| + 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 +115,59 @@ void NetworkChangeNotifierChromeos::DefaultNetworkChanged( |
| NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); |
| if (dns_changed) |
| dns_config_service_->OnNetworkChange(); |
| + |
| + // Retrieve AP info for wifi connection. |
| + if (connection_type_ == CONNECTION_WIFI) { |
| + NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| + default_network->path(), |
| + base::Bind(&NetworkChangeNotifierChromeos::ParseWifiApInfo, |
| + AsWeakPtr()), |
| + network_handler::ErrorCallback()); |
| + } |
| +} |
| + |
| +void NetworkChangeNotifierChromeos::ParseWifiApInfo( |
| + const std::string &service_path, |
| + const base::DictionaryValue& properties) { |
|
stevenjb
2014/07/08 00:24:53
Verify that service_path == service_path_, since t
zqiu1
2014/07/08 20:47:53
Done.
|
| + net::NetworkChangeNotifier::WifiApInfo info; |
| + |
| + // Parse security info. |
| + std::string security; |
| + properties.GetStringWithoutPathExpansion( |
| + shill::kSecurityProperty, &security); |
| + info.security = WIFI_SECURITY_UNKNOWN; |
| + if (security == shill::kSecurityWpa) |
| + info.security = WIFI_SECURITY_WPA; |
| + else if (security == shill::kSecurityWep) |
| + info.security = WIFI_SECURITY_WEP; |
| + else if (security == shill::kSecurityRsn) |
| + info.security = WIFI_SECURITY_RSN; |
| + else if (security == shill::kSecurity8021x) |
| + info.security = WIFI_SECURITY_802_1X; |
| + else if (security == shill::kSecurityPsk) |
| + info.security = WIFI_SECURITY_PSK; |
| + else if (security == shill::kSecurityNone) |
| + info.security = WIFI_SECURITY_NONE; |
| + |
| + properties.GetStringWithoutPathExpansion( |
| + shill::kWifiBSsid, &info.bssid); |
| + const base::DictionaryValue* vendor_dict = NULL; |
| + if (properties.GetDictionaryWithoutPathExpansion( |
| + shill::kWifiVendorInformationProperty, |
| + &vendor_dict)) { |
| + vendor_dict->GetStringWithoutPathExpansion( |
| + shill::kVendorWPSModelNumberProperty, |
| + &info.model_number); |
| + vendor_dict->GetStringWithoutPathExpansion( |
| + shill::kVendorWPSModelNameProperty, |
| + &info.model_name); |
| + vendor_dict->GetStringWithoutPathExpansion( |
| + shill::kVendorWPSDeviceNameProperty, |
| + &info.device_name); |
| + vendor_dict->GetStringWithoutPathExpansion(shill::kVendorOUIListProperty, |
| + &info.oui_list); |
| + } |
| + wifi_ap_info_ = info; |
|
stevenjb
2014/07/08 00:24:53
Why copy this instead of updating wifi_ap_info_ di
zqiu1
2014/07/08 20:47:53
The original intent was to make sure the fields in
|
| } |
| void NetworkChangeNotifierChromeos::UpdateState( |