diff options
author | meacer <meacer@chromium.org> | 2015-01-30 13:15:44 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-30 21:16:54 +0000 |
commit | 4770e8a571858a672cae59a4b818244df4520ac1 (patch) | |
tree | 5efecbd81af385a32cfe58428da392bfe75f74af /components/wifi/wifi_service_win.cc | |
parent | 983206f104e5495e5a126356ce8a0d965d8c6f1f (diff) | |
download | chromium_src-4770e8a571858a672cae59a4b818244df4520ac1.zip chromium_src-4770e8a571858a672cae59a4b818244df4520ac1.tar.gz chromium_src-4770e8a571858a672cae59a4b818244df4520ac1.tar.bz2 |
Add SSID getter to WiFiService.
The SSID is going to be displayed in the captive portal interstitial as such: "The network you are using (Google Guest)..."
BUG=451272
Review URL: https://codereview.chromium.org/880143003
Cr-Commit-Position: refs/heads/master@{#313995}
Diffstat (limited to 'components/wifi/wifi_service_win.cc')
-rw-r--r-- | components/wifi/wifi_service_win.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/components/wifi/wifi_service_win.cc b/components/wifi/wifi_service_win.cc index 8126868..50fb21f 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(¤t_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_|. |