| Index: chrome/browser/metrics/network_metrics_provider.cc
|
| diff --git a/chrome/browser/metrics/network_metrics_provider.cc b/chrome/browser/metrics/network_metrics_provider.cc
|
| index b339d4b93adcddd000756500e58073e19f3c359a..bb14e8e4f7e64632fd09494acd7f1020bef0f73b 100644
|
| --- a/chrome/browser/metrics/network_metrics_provider.cc
|
| +++ b/chrome/browser/metrics/network_metrics_provider.cc
|
| @@ -5,6 +5,10 @@
|
| #include "chrome/browser/metrics/network_metrics_provider.h"
|
|
|
| #include "base/compiler_specific.h"
|
| +#include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/string_split.h"
|
| +#include "base/strings/string_util.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "base/task_runner_util.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| #include "content/public/browser/browser_thread.h"
|
| @@ -39,6 +43,12 @@ void NetworkMetricsProvider::ProvideSystemProfileMetrics(
|
| // TODO(isherman): This line seems unnecessary.
|
| connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
|
| wifi_phy_layer_protocol_is_ambiguous_ = false;
|
| +
|
| + // Connected wifi AP information.
|
| + net::NetworkChangeNotifier::WifiApInfo info;
|
| + if (net::NetworkChangeNotifier::GetWifiApInfo(&info)) {
|
| + WriteWifiApProto(network, info);
|
| + }
|
| }
|
|
|
| void NetworkMetricsProvider::OnConnectionTypeChanged(
|
| @@ -116,3 +126,80 @@ void NetworkMetricsProvider::OnWifiPHYLayerProtocolResult(
|
| }
|
| wifi_phy_layer_protocol_ = mode;
|
| }
|
| +
|
| +void NetworkMetricsProvider::WriteWifiApProto(
|
| + SystemProfileProto::Network *network_proto,
|
| + const net::NetworkChangeNotifier::WifiApInfo &info) {
|
| + SystemProfileProto::Network::WifiAccessPoint* ap_info =
|
| + network_proto->mutable_ap_info();
|
| +
|
| + SystemProfileProto::Network::WifiAccessPoint::SecurityMode security;
|
| + switch (info.security) {
|
| + case net::NetworkChangeNotifier::WIFI_SECURITY_NONE:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_NONE;
|
| + break;
|
| + case net::NetworkChangeNotifier::WIFI_SECURITY_WPA:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_WPA;
|
| + break;
|
| + case net::NetworkChangeNotifier::WIFI_SECURITY_WEP:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_WEP;
|
| + break;
|
| + case net::NetworkChangeNotifier::WIFI_SECURITY_RSN:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_RSN;
|
| + break;
|
| + case net::NetworkChangeNotifier::WIFI_SECURITY_802_1X:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_802_1X;
|
| + break;
|
| + case net::NetworkChangeNotifier::WIFI_SECURITY_PSK:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_PSK;
|
| + break;
|
| + default:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_UNKNOWN;
|
| + break;
|
| + }
|
| + ap_info->set_security_mode(security);
|
| +
|
| + // |bssid| is xx:xx:xx:xx:xx:xx, extract the first three components and
|
| + // pack into a uint32.
|
| + std::string bssid = info.bssid;
|
| + if (bssid.size() > 9 && bssid[2] == ':' && bssid[5] == ':' &&
|
| + bssid[8] == ':') {
|
| + std::string vendor_prefix_str;
|
| + uint32 vendor_prefix;
|
| +
|
| + base::RemoveChars(bssid.substr(0, 9), ":", &vendor_prefix_str);
|
| + DCHECK_EQ(6U, vendor_prefix_str.size());
|
| + base::HexStringToUInt(vendor_prefix_str, &vendor_prefix);
|
| +
|
| + ap_info->set_vendor_prefix(vendor_prefix);
|
| + }
|
| +
|
| + // Fill in vendor information if it is provided.
|
| + if (!info.model_number.empty() || !info.model_name.empty() ||
|
| + !info.device_name.empty() || !info.oui_list.empty()) {
|
| + SystemProfileProto::Network::WifiAccessPoint::VendorInformation *vendor =
|
| + ap_info->mutable_vendor_info();
|
| + if (!info.model_number.empty()) {
|
| + vendor->set_model_number(info.model_number);
|
| + }
|
| + if (!info.model_name.empty()) {
|
| + vendor->set_model_name(info.model_name);
|
| + }
|
| + if (!info.device_name.empty()) {
|
| + vendor->set_device_name(info.device_name);
|
| + }
|
| +
|
| + // Parse OUI list.
|
| + if (!info.oui_list.empty()) {
|
| + std::vector<std::string> oui_list;
|
| + base::SplitString(info.oui_list, ' ', &oui_list);
|
| + for (std::vector<std::string>::const_iterator i = oui_list.begin();
|
| + i != oui_list.end();
|
| + ++i) {
|
| + uint32 oui;
|
| + base::HexStringToUInt(*i, &oui);
|
| + vendor->add_oui(oui);
|
| + }
|
| + }
|
| + }
|
| +}
|
|
|