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

Unified Diff: content/browser/geolocation/wifi_data_provider_win.cc

Issue 10535157: [WIP] attempt to allow chrome OS to inject its wifi data provider (Closed) Base URL: http://git.chromium.org/chromium/src.git@remove_radio
Patch Set: Created 8 years, 6 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 | « content/browser/geolocation/wifi_data_provider_unittest.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/geolocation/wifi_data_provider_win.cc
diff --git a/content/browser/geolocation/wifi_data_provider_win.cc b/content/browser/geolocation/wifi_data_provider_win.cc
index 8837c2ecca4cb245cf7500aa12de5e3f55b45dde..bcd731d95d78fa208aba4e2824cdcc36c975fcb6 100644
--- a/content/browser/geolocation/wifi_data_provider_win.cc
+++ b/content/browser/geolocation/wifi_data_provider_win.cc
@@ -153,7 +153,6 @@ bool ResizeBuffer(int requested_size, scoped_ptr_malloc<BYTE>* buffer);
bool GetSystemDirectory(string16* path);
} // namespace
-template<>
WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() {
return new Win32WifiDataProvider();
}
@@ -184,6 +183,47 @@ PollingPolicyInterface* Win32WifiDataProvider::NewPollingPolicy() {
// Local classes and functions
namespace {
+bool ConvertToAccessPointData(const NDIS_WLAN_BSSID& data,
+ AccessPointData *access_point_data) {
+ // Currently we get only MAC address, signal strength and SSID.
+ // TODO(steveblock): Work out how to get age, channel and signal-to-noise.
+ DCHECK(access_point_data);
+ access_point_data->mac_address = MacAddressAsString16(data.MacAddress);
+ access_point_data->radio_signal_strength = data.Rssi;
+ // Note that _NDIS_802_11_SSID::Ssid::Ssid is not null-terminated.
+ UTF8ToUTF16(reinterpret_cast<const char*>(data.Ssid.Ssid),
+ data.Ssid.SsidLength,
+ &access_point_data->ssid);
+ return true;
+}
+
+int GetDataFromBssIdList(const NDIS_802_11_BSSID_LIST& bss_id_list,
+ int list_size,
+ WifiData::AccessPointDataSet* data) {
+ // Walk through the BSS IDs.
+ int found = 0;
+ const uint8 *iterator = reinterpret_cast<const uint8*>(&bss_id_list.Bssid[0]);
+ const uint8 *end_of_buffer =
+ reinterpret_cast<const uint8*>(&bss_id_list) + list_size;
+ for (int i = 0; i < static_cast<int>(bss_id_list.NumberOfItems); ++i) {
+ const NDIS_WLAN_BSSID *bss_id =
+ reinterpret_cast<const NDIS_WLAN_BSSID*>(iterator);
+ // Check that the length of this BSS ID is reasonable.
+ if (bss_id->Length < sizeof(NDIS_WLAN_BSSID) ||
+ iterator + bss_id->Length > end_of_buffer) {
+ break;
+ }
+ AccessPointData access_point_data;
+ if (ConvertToAccessPointData(*bss_id, &access_point_data)) {
+ data->insert(access_point_data);
+ ++found;
+ }
+ // Move to the next BSS ID.
+ iterator += bss_id->Length;
+ }
+ return found;
+}
+
// WindowsWlanApi
WindowsWlanApi::WindowsWlanApi(HINSTANCE library)
: library_(library) {
« no previous file with comments | « content/browser/geolocation/wifi_data_provider_unittest.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698