OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/chromeos/cros/network_library.h" | 5 #include "chrome/browser/chromeos/cros/network_library.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 WifiNetwork* wifi = GetPreferredNetwork(); | 326 WifiNetwork* wifi = GetPreferredNetwork(); |
327 return wifi && wifi->connected(); | 327 return wifi && wifi->connected(); |
328 } | 328 } |
329 | 329 |
330 bool NetworkLibraryImpl::PreferredNetworkFailed() { | 330 bool NetworkLibraryImpl::PreferredNetworkFailed() { |
331 WifiNetwork* wifi = GetPreferredNetwork(); | 331 WifiNetwork* wifi = GetPreferredNetwork(); |
332 return !wifi || wifi->failed(); | 332 return !wifi || wifi->failed(); |
333 } | 333 } |
334 | 334 |
335 void NetworkLibraryImpl::ConnectToWifiNetwork(WifiNetwork network, | 335 void NetworkLibraryImpl::ConnectToWifiNetwork(WifiNetwork network, |
336 const string16& password, | 336 const std::string& password, |
337 const string16& identity, | 337 const std::string& identity, |
338 const string16& certpath) { | 338 const std::string& certpath) { |
339 if (CrosLibrary::Get()->EnsureLoaded()) { | 339 if (CrosLibrary::Get()->EnsureLoaded()) { |
340 ConnectToNetworkWithCertInfo(network.service_path().c_str(), | 340 ConnectToNetworkWithCertInfo(network.service_path().c_str(), |
341 password.empty() ? NULL : UTF16ToUTF8(password).c_str(), | 341 password.empty() ? NULL : password.c_str(), |
342 identity.empty() ? NULL : UTF16ToUTF8(identity).c_str(), | 342 identity.empty() ? NULL : identity.c_str(), |
343 certpath.empty() ? NULL : UTF16ToUTF8(certpath).c_str()); | 343 certpath.empty() ? NULL : certpath.c_str()); |
344 } | 344 } |
345 } | 345 } |
346 | 346 |
347 void NetworkLibraryImpl::ConnectToWifiNetwork(const string16& ssid, | 347 void NetworkLibraryImpl::ConnectToWifiNetwork(const std::string& ssid, |
348 const string16& password, | 348 const std::string& password, |
349 const string16& identity, | 349 const std::string& identity, |
350 const string16& certpath, | 350 const std::string& certpath, |
351 bool auto_connect) { | 351 bool auto_connect) { |
352 if (CrosLibrary::Get()->EnsureLoaded()) { | 352 if (CrosLibrary::Get()->EnsureLoaded()) { |
353 // First create a service from hidden network. | 353 // First create a service from hidden network. |
354 ServiceInfo* service = GetWifiService(UTF16ToUTF8(ssid).c_str(), | 354 ServiceInfo* service = GetWifiService(ssid.c_str(), |
355 SECURITY_UNKNOWN); | 355 SECURITY_UNKNOWN); |
356 if (service) { | 356 if (service) { |
357 // Set auto-connect. | 357 // Set auto-connect. |
358 SetAutoConnect(service->service_path, auto_connect); | 358 SetAutoConnect(service->service_path, auto_connect); |
359 // Now connect to that service. | 359 // Now connect to that service. |
360 ConnectToNetworkWithCertInfo(service->service_path, | 360 ConnectToNetworkWithCertInfo(service->service_path, |
361 password.empty() ? NULL : UTF16ToUTF8(password).c_str(), | 361 password.empty() ? NULL : password.c_str(), |
362 identity.empty() ? NULL : UTF16ToUTF8(identity).c_str(), | 362 identity.empty() ? NULL : identity.c_str(), |
363 certpath.empty() ? NULL : UTF16ToUTF8(certpath).c_str()); | 363 certpath.empty() ? NULL : certpath.c_str()); |
364 | 364 |
365 // Clean up ServiceInfo object. | 365 // Clean up ServiceInfo object. |
366 FreeServiceInfo(service); | 366 FreeServiceInfo(service); |
367 } else { | 367 } else { |
368 LOG(WARNING) << "Cannot find hidden network: " << ssid; | 368 LOG(WARNING) << "Cannot find hidden network: " << ssid; |
369 // TODO(chocobo): Show error message. | 369 // TODO(chocobo): Show error message. |
370 } | 370 } |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 if (ethernet_connected()) | 743 if (ethernet_connected()) |
744 return ethernet_.ip_address(); | 744 return ethernet_.ip_address(); |
745 if (wifi_connected()) | 745 if (wifi_connected()) |
746 return wifi_.ip_address(); | 746 return wifi_.ip_address(); |
747 if (cellular_connected()) | 747 if (cellular_connected()) |
748 return cellular_.ip_address(); | 748 return cellular_.ip_address(); |
749 return ethernet_.ip_address(); | 749 return ethernet_.ip_address(); |
750 } | 750 } |
751 | 751 |
752 } // namespace chromeos | 752 } // namespace chromeos |
OLD | NEW |