Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/wifi/wifi_service.h" | 5 #include "components/wifi/wifi_service.h" |
| 6 | 6 |
| 7 #include <iphlpapi.h> | 7 #include <iphlpapi.h> |
| 8 #include <objbase.h> | 8 #include <objbase.h> |
| 9 #include <wlanapi.h> | 9 #include <wlanapi.h> |
| 10 | 10 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 std::string* key_data, | 219 std::string* key_data, |
| 220 std::string* error) override; | 220 std::string* error) override; |
| 221 | 221 |
| 222 virtual void SetEventObservers( | 222 virtual void SetEventObservers( |
| 223 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 223 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
| 224 const NetworkGuidListCallback& networks_changed_observer, | 224 const NetworkGuidListCallback& networks_changed_observer, |
| 225 const NetworkGuidListCallback& network_list_changed_observer) override; | 225 const NetworkGuidListCallback& network_list_changed_observer) override; |
| 226 | 226 |
| 227 virtual void RequestConnectedNetworkUpdate() override {} | 227 virtual void RequestConnectedNetworkUpdate() override {} |
| 228 | 228 |
| 229 virtual void GetConnectedNetworkSSID(std::string* ssid, | |
| 230 std::string* error) override; | |
| 231 | |
| 229 private: | 232 private: |
| 230 typedef int32 EncryptionType; | 233 typedef int32 EncryptionType; |
| 231 enum EncryptionTypeEnum { | 234 enum EncryptionTypeEnum { |
| 232 kEncryptionTypeAny = 0, | 235 kEncryptionTypeAny = 0, |
| 233 kEncryptionTypeAES = 1, | 236 kEncryptionTypeAES = 1, |
| 234 kEncryptionTypeTKIP = 2 | 237 kEncryptionTypeTKIP = 2 |
| 235 }; | 238 }; |
| 236 | 239 |
| 237 // Static callback for Windows WLAN_NOTIFICATION. Calls OnWlanNotification | 240 // Static callback for Windows WLAN_NOTIFICATION. Calls OnWlanNotification |
| 238 // on WiFiServiceImpl passed back as |context|. | 241 // on WiFiServiceImpl passed back as |context|. |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 WlanRegisterNotification_function_(client_, | 802 WlanRegisterNotification_function_(client_, |
| 800 WLAN_NOTIFICATION_SOURCE_ALL, | 803 WLAN_NOTIFICATION_SOURCE_ALL, |
| 801 FALSE, | 804 FALSE, |
| 802 OnWlanNotificationCallback, | 805 OnWlanNotificationCallback, |
| 803 this, | 806 this, |
| 804 NULL, | 807 NULL, |
| 805 NULL); | 808 NULL); |
| 806 } | 809 } |
| 807 } | 810 } |
| 808 | 811 |
| 812 void WiFiServiceImpl::GetConnectedNetworkSSID(std::string* ssid, | |
| 813 std::string* error) { | |
| 814 DWORD error_code = EnsureInitialized(); | |
| 815 if (CheckError(error_code, kErrorWiFiService, error)) | |
| 816 return; | |
| 817 NetworkProperties connected_properties; | |
| 818 error_code = GetCurrentProperties(&connected_properties); | |
|
mef
2015/01/30 17:45:41
GetCurrentProperties may be a little overkill for
meacer
2015/01/30 19:11:50
Added a lightweight version that doesn't use the B
mef
2015/01/30 19:45:11
Yeah, I think this has less performance concerns.
| |
| 819 if (CheckError(error_code, kErrorWiFiService, error)) | |
| 820 return; | |
| 821 *ssid = connected_properties.ssid; | |
| 822 } | |
| 823 | |
| 809 void WiFiServiceImpl::OnWlanNotificationCallback( | 824 void WiFiServiceImpl::OnWlanNotificationCallback( |
| 810 PWLAN_NOTIFICATION_DATA wlan_notification_data, | 825 PWLAN_NOTIFICATION_DATA wlan_notification_data, |
| 811 PVOID context) { | 826 PVOID context) { |
| 812 WiFiServiceImpl* service = reinterpret_cast<WiFiServiceImpl*>(context); | 827 WiFiServiceImpl* service = reinterpret_cast<WiFiServiceImpl*>(context); |
| 813 service->OnWlanNotification(wlan_notification_data); | 828 service->OnWlanNotification(wlan_notification_data); |
| 814 } | 829 } |
| 815 | 830 |
| 816 void WiFiServiceImpl::OnWlanNotification( | 831 void WiFiServiceImpl::OnWlanNotification( |
| 817 PWLAN_NOTIFICATION_DATA wlan_notification_data) { | 832 PWLAN_NOTIFICATION_DATA wlan_notification_data) { |
| 818 if (message_loop_proxy_.get() == NULL) | 833 if (message_loop_proxy_.get() == NULL) |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1840 NetworkGuidList changed_networks(1, network_guid); | 1855 NetworkGuidList changed_networks(1, network_guid); |
| 1841 message_loop_proxy_->PostTask( | 1856 message_loop_proxy_->PostTask( |
| 1842 FROM_HERE, | 1857 FROM_HERE, |
| 1843 base::Bind(networks_changed_observer_, changed_networks)); | 1858 base::Bind(networks_changed_observer_, changed_networks)); |
| 1844 } | 1859 } |
| 1845 } | 1860 } |
| 1846 | 1861 |
| 1847 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } | 1862 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } |
| 1848 | 1863 |
| 1849 } // namespace wifi | 1864 } // namespace wifi |
| OLD | NEW |