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

Unified Diff: components/wifi/wifi_service_win.cc

Issue 880143003: Add SSID getter to WiFiService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mef comments Created 5 years, 11 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
« no previous file with comments | « components/wifi/wifi_service_mac.mm ('k') | components/wifi/wifi_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/wifi/wifi_service_win.cc
diff --git a/components/wifi/wifi_service_win.cc b/components/wifi/wifi_service_win.cc
index 812686841d6257dc46f8854ba7b34e7b37213eb8..50fb21f54b5a2b06cbe39d851f5d317995815e93 100644
--- a/components/wifi/wifi_service_win.cc
+++ b/components/wifi/wifi_service_win.cc
@@ -226,6 +226,9 @@ class WiFiServiceImpl : public WiFiService {
virtual void RequestConnectedNetworkUpdate() override {}
+ virtual void GetConnectedNetworkSSID(std::string* ssid,
+ std::string* error) override;
+
private:
typedef int32 EncryptionType;
enum EncryptionTypeEnum {
@@ -357,6 +360,11 @@ class WiFiServiceImpl : public WiFiService {
// by interface. Populate |current_properties| on success.
DWORD GetCurrentProperties(NetworkProperties* current_properties);
+ // Get the SSID of the network currently used (connected or in transition)
+ // by interface. Populate |ssid| on success. This is a stripped down version
+ // of GetCurrentProperties that doesn't use the BSS list;
+ DWORD GetCurrentSSID(std::string* ssid);
+
// Connect to network |network_guid| using previosly stored profile if exists,
// or just network sid. If |frequency| is not |kFrequencyUnknown| then
// connects only to BSS which uses that frequency and returns
@@ -806,6 +814,18 @@ void WiFiServiceImpl::SetEventObservers(
}
}
+void WiFiServiceImpl::GetConnectedNetworkSSID(std::string* ssid,
+ std::string* error) {
+ DWORD error_code = EnsureInitialized();
+ if (CheckError(error_code, kErrorWiFiService, error))
+ return;
+ std::string current_ssid;
+ error_code = GetCurrentSSID(&current_ssid);
+ if (CheckError(error_code, kErrorWiFiService, error))
+ return;
+ *ssid = current_ssid;
+}
+
void WiFiServiceImpl::OnWlanNotificationCallback(
PWLAN_NOTIFICATION_DATA wlan_notification_data,
PVOID context) {
@@ -1462,6 +1482,37 @@ DWORD WiFiServiceImpl::GetCurrentProperties(NetworkProperties* properties) {
return error;
}
+
+DWORD WiFiServiceImpl::GetCurrentSSID(std::string* ssid) {
+ if (client_ == NULL) {
+ NOTREACHED();
+ return ERROR_NOINTERFACE;
+ }
+ DWORD error = ERROR_SUCCESS;
+ DWORD data_size = 0;
+ PWLAN_CONNECTION_ATTRIBUTES wlan_connection_attributes = NULL;
+ error = WlanQueryInterface_function_(
+ client_,
+ &interface_guid_,
+ wlan_intf_opcode_current_connection,
+ NULL,
+ &data_size,
+ reinterpret_cast<PVOID*>(&wlan_connection_attributes),
+ NULL);
+ if (error == ERROR_SUCCESS &&
+ wlan_connection_attributes != NULL) {
+ WLAN_ASSOCIATION_ATTRIBUTES& connected_wlan =
+ wlan_connection_attributes->wlanAssociationAttributes;
+ *ssid = GUIDFromSSID(connected_wlan.dot11Ssid);
+ }
+
+ // Clean up.
+ if (wlan_connection_attributes != NULL)
+ WlanFreeMemory_function_(wlan_connection_attributes);
+
+ return error;
+}
+
Frequency WiFiServiceImpl::GetFrequencyToConnect(
const std::string& network_guid) const {
// Check whether desired frequency is set in |connect_properties_|.
« no previous file with comments | « components/wifi/wifi_service_mac.mm ('k') | components/wifi/wifi_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698