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

Side by Side Diff: chrome/browser/geolocation/wifi_data_provider_windows_common.cc

Issue 553069: Revert 37009 - Adding geolocation data provider infrastructure to Chrome.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/geolocation/wifi_data_provider_windows_common.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2008, Google Inc.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
5 //
6 // 1. Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright notice,
9 // this list of conditions and the following disclaimer in the documentation
10 // and/or other materials provided with the distribution.
11 // 3. Neither the name of Google Inc. nor the names of its contributors may be
12 // used to endorse or promote products derived from this software without
13 // specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 #if defined(WIN32) || defined(OS_WINCE)
27
28 #include "gears/geolocation/wifi_data_provider_windows_common.h"
29
30 #include <assert.h>
31 #include "gears/base/common/string_utils.h"
32 #include "gears/geolocation/device_data_provider.h"
33 #include "gears/geolocation/wifi_data_provider_common.h"
34
35 bool ConvertToGearsFormat(const NDIS_WLAN_BSSID &data,
36 AccessPointData *access_point_data) {
37 // Currently we get only MAC address, signal strength and SSID.
38 // TODO(steveblock): Work out how to get age, channel and signal-to-noise.
39 assert(access_point_data);
40 access_point_data->mac_address = MacAddressAsString16(data.MacAddress);
41 access_point_data->radio_signal_strength = data.Rssi;
42 // Note that _NDIS_802_11_SSID::Ssid::Ssid is not null-terminated.
43 UTF8ToString16(reinterpret_cast<const char*>(data.Ssid.Ssid),
44 data.Ssid.SsidLength,
45 &access_point_data->ssid);
46 return true;
47 }
48
49 int GetDataFromBssIdList(const NDIS_802_11_BSSID_LIST &bss_id_list,
50 int list_size,
51 WifiData::AccessPointDataSet *data) {
52 // Walk through the BSS IDs.
53 int found = 0;
54 const uint8 *iterator = reinterpret_cast<const uint8*>(&bss_id_list.Bssid[0]);
55 const uint8 *end_of_buffer =
56 reinterpret_cast<const uint8*>(&bss_id_list) + list_size;
57 for (int i = 0; i < static_cast<int>(bss_id_list.NumberOfItems); ++i) {
58 const NDIS_WLAN_BSSID *bss_id =
59 reinterpret_cast<const NDIS_WLAN_BSSID*>(iterator);
60 // Check that the length of this BSS ID is reasonable.
61 if (bss_id->Length < sizeof(NDIS_WLAN_BSSID) ||
62 iterator + bss_id->Length > end_of_buffer) {
63 break;
64 }
65 AccessPointData access_point_data;
66 if (ConvertToGearsFormat(*bss_id, &access_point_data)) {
67 data->insert(access_point_data);
68 ++found;
69 }
70 // Move to the next BSS ID.
71 iterator += bss_id->Length;
72 }
73 return found;
74 }
75
76 #endif // WIN32 || OS_WINCE
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/wifi_data_provider_windows_common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698