| 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..b039889973c470822d06454fe7c228ec1640c9cf 100644
|
| --- a/chrome/browser/metrics/network_metrics_provider.cc
|
| +++ b/chrome/browser/metrics/network_metrics_provider.cc
|
| @@ -5,10 +5,17 @@
|
| #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/task_runner_util.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| #include "content/public/browser/browser_thread.h"
|
|
|
| +#if defined(OS_CHROMEOS)
|
| +#include "chrome/browser/metrics/wifi_access_point_info_provider_chromeos.h"
|
| +#endif // OS_CHROMEOS
|
| +
|
| using metrics::SystemProfileProto;
|
|
|
| NetworkMetricsProvider::NetworkMetricsProvider()
|
| @@ -39,6 +46,21 @@ void NetworkMetricsProvider::ProvideSystemProfileMetrics(
|
| // TODO(isherman): This line seems unnecessary.
|
| connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
|
| wifi_phy_layer_protocol_is_ambiguous_ = false;
|
| +
|
| + if (!wifi_access_point_info_provider_.get()) {
|
| +#if defined(OS_CHROMEOS)
|
| + wifi_access_point_info_provider_.reset(
|
| + new WifiAccessPointInfoProviderChromeos());
|
| +#else
|
| + wifi_access_point_info_provider_.reset(
|
| + new WifiAccessPointInfoProvider());
|
| +#endif // OS_CHROMEOS
|
| + }
|
| +
|
| + // Connected wifi access point information.
|
| + WifiAccessPointInfoProvider::WifiAccessPointInfo info;
|
| + if (wifi_access_point_info_provider_->GetInfo(&info))
|
| + WriteWifiAccessPointProto(info, network);
|
| }
|
|
|
| void NetworkMetricsProvider::OnConnectionTypeChanged(
|
| @@ -116,3 +138,83 @@ void NetworkMetricsProvider::OnWifiPHYLayerProtocolResult(
|
| }
|
| wifi_phy_layer_protocol_ = mode;
|
| }
|
| +
|
| +void NetworkMetricsProvider::WriteWifiAccessPointProto(
|
| + const WifiAccessPointInfoProvider::WifiAccessPointInfo& info,
|
| + SystemProfileProto::Network* network_proto) {
|
| + SystemProfileProto::Network::WifiAccessPoint* access_point_info =
|
| + network_proto->mutable_access_point_info();
|
| + SystemProfileProto::Network::WifiAccessPoint::SecurityMode security =
|
| + SystemProfileProto::Network::WifiAccessPoint::SECURITY_UNKNOWN;
|
| + switch (info.security) {
|
| + case WifiAccessPointInfoProvider::WIFI_SECURITY_NONE:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_NONE;
|
| + break;
|
| + case WifiAccessPointInfoProvider::WIFI_SECURITY_WPA:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_WPA;
|
| + break;
|
| + case WifiAccessPointInfoProvider::WIFI_SECURITY_WEP:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_WEP;
|
| + break;
|
| + case WifiAccessPointInfoProvider::WIFI_SECURITY_RSN:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_RSN;
|
| + break;
|
| + case WifiAccessPointInfoProvider::WIFI_SECURITY_802_1X:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_802_1X;
|
| + break;
|
| + case WifiAccessPointInfoProvider::WIFI_SECURITY_PSK:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_PSK;
|
| + break;
|
| + case WifiAccessPointInfoProvider::WIFI_SECURITY_UNKNOWN:
|
| + security = SystemProfileProto::Network::WifiAccessPoint::SECURITY_UNKNOWN;
|
| + break;
|
| + }
|
| + access_point_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() == 17 && bssid[2] == ':' && bssid[5] == ':' &&
|
| + bssid[8] == ':' && bssid[11] == ':' && bssid[14] == ':') {
|
| + std::string vendor_prefix_str;
|
| + uint32 vendor_prefix;
|
| +
|
| + base::RemoveChars(bssid.substr(0, 9), ":", &vendor_prefix_str);
|
| + DCHECK_EQ(6U, vendor_prefix_str.size());
|
| + if (base::HexStringToUInt(vendor_prefix_str, &vendor_prefix))
|
| + access_point_info->set_vendor_prefix(vendor_prefix);
|
| + else
|
| + NOTREACHED();
|
| + }
|
| +
|
| + // Return if vendor information is not provided.
|
| + if (info.model_number.empty() && info.model_name.empty() &&
|
| + info.device_name.empty() && info.oui_list.empty())
|
| + return;
|
| +
|
| + SystemProfileProto::Network::WifiAccessPoint::VendorInformation* vendor =
|
| + access_point_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);
|
| +
|
| + // Return if OUI list is not provided.
|
| + if (info.oui_list.empty())
|
| + return;
|
| +
|
| + // Parse OUI list.
|
| + std::vector<std::string> oui_list;
|
| + base::SplitString(info.oui_list, ' ', &oui_list);
|
| + for (std::vector<std::string>::const_iterator it = oui_list.begin();
|
| + it != oui_list.end();
|
| + ++it) {
|
| + uint32 oui;
|
| + if (base::HexStringToUInt(*it, &oui))
|
| + vendor->add_element_identifier(oui);
|
| + else
|
| + NOTREACHED();
|
| + }
|
| +}
|
|
|