OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 const std::string& extension_id, | 176 const std::string& extension_id, |
177 const std::string& guid, | 177 const std::string& guid, |
178 const std::string* bssid) { | 178 const std::string* bssid) { |
179 const chromeos::NetworkState* network = chromeos::NetworkHandler::Get() | 179 const chromeos::NetworkState* network = chromeos::NetworkHandler::Get() |
180 ->network_state_handler() | 180 ->network_state_handler() |
181 ->GetNetworkStateFromGuid(guid); | 181 ->GetNetworkStateFromGuid(guid); |
182 if (!network) | 182 if (!network) |
183 return nullptr; | 183 return nullptr; |
184 | 184 |
185 // Populate the NetworkInfo object. | 185 // Populate the NetworkInfo object. |
186 extensions::core_api::networking_config::NetworkInfo network_info; | 186 extensions::api::networking_config::NetworkInfo network_info; |
187 network_info.type = | 187 network_info.type = extensions::api::networking_config::NETWORK_TYPE_WIFI; |
188 extensions::core_api::networking_config::NETWORK_TYPE_WIFI; | |
189 const std::vector<uint8_t>& raw_ssid = network->raw_ssid(); | 188 const std::vector<uint8_t>& raw_ssid = network->raw_ssid(); |
190 std::string hex_ssid = | 189 std::string hex_ssid = |
191 base::HexEncode(vector_as_array(&raw_ssid), raw_ssid.size()); | 190 base::HexEncode(vector_as_array(&raw_ssid), raw_ssid.size()); |
192 network_info.hex_ssid = make_scoped_ptr(new std::string(hex_ssid)); | 191 network_info.hex_ssid = make_scoped_ptr(new std::string(hex_ssid)); |
193 network_info.ssid = make_scoped_ptr(new std::string(network->name())); | 192 network_info.ssid = make_scoped_ptr(new std::string(network->name())); |
194 network_info.guid = make_scoped_ptr(new std::string(network->guid())); | 193 network_info.guid = make_scoped_ptr(new std::string(network->guid())); |
195 if (bssid) | 194 if (bssid) |
196 network_info.bssid.reset(new std::string(*bssid)); | 195 network_info.bssid.reset(new std::string(*bssid)); |
197 scoped_ptr<base::ListValue> results = | 196 scoped_ptr<base::ListValue> results = |
198 extensions::core_api::networking_config::OnCaptivePortalDetected::Create( | 197 extensions::api::networking_config::OnCaptivePortalDetected::Create( |
199 network_info); | 198 network_info); |
200 scoped_ptr<Event> event(new Event(events::UNKNOWN, | 199 scoped_ptr<Event> event(new Event( |
201 extensions::core_api::networking_config:: | 200 events::UNKNOWN, |
202 OnCaptivePortalDetected::kEventName, | 201 extensions::api::networking_config::OnCaptivePortalDetected::kEventName, |
203 results.Pass())); | 202 results.Pass())); |
204 return event.Pass(); | 203 return event.Pass(); |
205 } | 204 } |
206 | 205 |
207 void NetworkingConfigService::DispatchPortalDetectedEvent( | 206 void NetworkingConfigService::DispatchPortalDetectedEvent( |
208 const std::string& extension_id, | 207 const std::string& extension_id, |
209 const std::string& guid, | 208 const std::string& guid, |
210 const base::Closure& authentication_callback) { | 209 const base::Closure& authentication_callback) { |
211 // This dispatch starts a new cycle of portal detection and authentication. | 210 // This dispatch starts a new cycle of portal detection and authentication. |
212 // Ensure that any old |authentication_callback_| is dropped. | 211 // Ensure that any old |authentication_callback_| is dropped. |
213 authentication_callback_.Reset(); | 212 authentication_callback_.Reset(); |
214 | 213 |
215 // Determine |service_path| of network identified by |guid|. | 214 // Determine |service_path| of network identified by |guid|. |
216 chromeos::NetworkHandler* network_handler = chromeos::NetworkHandler::Get(); | 215 chromeos::NetworkHandler* network_handler = chromeos::NetworkHandler::Get(); |
217 const chromeos::NetworkState* network = | 216 const chromeos::NetworkState* network = |
218 network_handler->network_state_handler()->GetNetworkStateFromGuid(guid); | 217 network_handler->network_state_handler()->GetNetworkStateFromGuid(guid); |
219 if (!network) | 218 if (!network) |
220 return; | 219 return; |
221 const std::string service_path = network->path(); | 220 const std::string service_path = network->path(); |
222 | 221 |
223 network_handler->managed_network_configuration_handler()->GetProperties( | 222 network_handler->managed_network_configuration_handler()->GetProperties( |
224 service_path, base::Bind(&NetworkingConfigService::OnGotProperties, | 223 service_path, base::Bind(&NetworkingConfigService::OnGotProperties, |
225 weak_factory_.GetWeakPtr(), extension_id, guid, | 224 weak_factory_.GetWeakPtr(), extension_id, guid, |
226 authentication_callback), | 225 authentication_callback), |
227 base::Bind(&NetworkingConfigService::OnGetPropertiesFailed, | 226 base::Bind(&NetworkingConfigService::OnGetPropertiesFailed, |
228 weak_factory_.GetWeakPtr(), extension_id, guid)); | 227 weak_factory_.GetWeakPtr(), extension_id, guid)); |
229 } | 228 } |
230 | 229 |
231 } // namespace extensions | 230 } // namespace extensions |
OLD | NEW |