| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Provides wifi scan API binding for chromeos, using proprietary APIs. | 5 // Provides wifi scan API binding for chromeos, using proprietary APIs. |
| 6 | 6 |
| 7 #include "content/browser/geolocation/wifi_data_provider_chromeos.h" | 7 #include "content/browser/geolocation/wifi_data_provider_chromeos.h" |
| 8 | 8 |
| 9 #include <stdint.h> |
| 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chromeos/network/geolocation_handler.h" | 13 #include "chromeos/network/geolocation_handler.h" |
| 12 #include "content/browser/geolocation/wifi_data_provider_manager.h" | 14 #include "content/browser/geolocation/wifi_data_provider_manager.h" |
| 13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 14 | 16 |
| 15 namespace content { | 17 namespace content { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 139 } |
| 138 | 140 |
| 139 bool WifiDataProviderChromeOs::GetAccessPointData( | 141 bool WifiDataProviderChromeOs::GetAccessPointData( |
| 140 WifiData::AccessPointDataSet* result) { | 142 WifiData::AccessPointDataSet* result) { |
| 141 // If wifi isn't enabled, we've effectively completed the task. | 143 // If wifi isn't enabled, we've effectively completed the task. |
| 142 // Return true to indicate an empty access point list. | 144 // Return true to indicate an empty access point list. |
| 143 if (!chromeos::NetworkHandler::Get()->geolocation_handler()->wifi_enabled()) | 145 if (!chromeos::NetworkHandler::Get()->geolocation_handler()->wifi_enabled()) |
| 144 return true; | 146 return true; |
| 145 | 147 |
| 146 chromeos::WifiAccessPointVector access_points; | 148 chromeos::WifiAccessPointVector access_points; |
| 147 int64 age_ms = 0; | 149 int64_t age_ms = 0; |
| 148 if (!chromeos::NetworkHandler::Get()->geolocation_handler()-> | 150 if (!chromeos::NetworkHandler::Get()->geolocation_handler()-> |
| 149 GetWifiAccessPoints(&access_points, &age_ms)) { | 151 GetWifiAccessPoints(&access_points, &age_ms)) { |
| 150 return false; | 152 return false; |
| 151 } | 153 } |
| 152 for (chromeos::WifiAccessPointVector::const_iterator i | 154 for (chromeos::WifiAccessPointVector::const_iterator i |
| 153 = access_points.begin(); | 155 = access_points.begin(); |
| 154 i != access_points.end(); ++i) { | 156 i != access_points.end(); ++i) { |
| 155 AccessPointData ap_data; | 157 AccessPointData ap_data; |
| 156 ap_data.mac_address = base::ASCIIToUTF16(i->mac_address); | 158 ap_data.mac_address = base::ASCIIToUTF16(i->mac_address); |
| 157 ap_data.radio_signal_strength = i->signal_strength; | 159 ap_data.radio_signal_strength = i->signal_strength; |
| 158 ap_data.channel = i->channel; | 160 ap_data.channel = i->channel; |
| 159 ap_data.signal_to_noise = i->signal_to_noise; | 161 ap_data.signal_to_noise = i->signal_to_noise; |
| 160 ap_data.ssid = base::UTF8ToUTF16(i->ssid); | 162 ap_data.ssid = base::UTF8ToUTF16(i->ssid); |
| 161 result->insert(ap_data); | 163 result->insert(ap_data); |
| 162 } | 164 } |
| 163 // If the age is significantly longer than our long polling time, assume the | 165 // If the age is significantly longer than our long polling time, assume the |
| 164 // data is stale and return false which will trigger a faster update. | 166 // data is stale and return false which will trigger a faster update. |
| 165 if (age_ms > kTwoNoChangePollingIntervalMilliseconds * 2) | 167 if (age_ms > kTwoNoChangePollingIntervalMilliseconds * 2) |
| 166 return false; | 168 return false; |
| 167 return true; | 169 return true; |
| 168 } | 170 } |
| 169 | 171 |
| 170 // static | 172 // static |
| 171 WifiDataProvider* WifiDataProviderManager::DefaultFactoryFunction() { | 173 WifiDataProvider* WifiDataProviderManager::DefaultFactoryFunction() { |
| 172 return new WifiDataProviderChromeOs(); | 174 return new WifiDataProviderChromeOs(); |
| 173 } | 175 } |
| 174 | 176 |
| 175 } // namespace content | 177 } // namespace content |
| OLD | NEW |