Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: chromeos/network/network_change_notifier_chromeos.cc

Issue 328793002: Add wifi AP info to system profile metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..329d23e1bd5483963ad313f1966b8e6c5dde1ae0 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) {
+ 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,62 @@ 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) {
+ // Return if not the current service.
+ if (service_path != service_path_)
+ return;
+
+ // Reset AP info.
+ wifi_ap_info_ = net::NetworkChangeNotifier::WifiApInfo();
+ // 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)) {
+ 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(

Powered by Google App Engine
This is Rietveld 408576698