From b76be6c790b8f26ff68c2a15a29bfc3c41ed8088 Mon Sep 17 00:00:00 2001 From: "chocobo@chromium.org" Date: Sat, 13 Mar 2010 00:29:33 +0000 Subject: Implement connect to hidden networks. And show passphrase in wifi config dialog. Review URL: http://codereview.chromium.org/913003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41512 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/chromeos/cros/network_library.cc | 17 +++++++++++++---- chrome/browser/chromeos/cros/network_library.h | 2 ++ chrome/browser/chromeos/options/wifi_config_view.cc | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index 6075332..8278ce4 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -93,11 +93,20 @@ void NetworkLibrary::ConnectToWifiNetwork(WifiNetwork network, void NetworkLibrary::ConnectToWifiNetwork(const string16& ssid, const string16& password) { if (CrosLibrary::EnsureLoaded()) { - // TODO(chocobo): Implement connect to hidden network. // First create a service from hidden network. - // Now connect to that service.. -// chromeos::ConnectToNetwork(service_path, -// password.empty() ? NULL : UTF16ToUTF8(password).c_str()); + chromeos::ServiceInfo* service = + chromeos::GetWifiService(UTF16ToUTF8(ssid).c_str(), + chromeos::SECURITY_UNKNOWN); + // Now connect to that service. + if (service) { + chromeos::ConnectToNetwork(service->service_path, + password.empty() ? NULL : UTF16ToUTF8(password).c_str()); + // Clean up ServiceInfo object. + chromeos::FreeServiceInfo(service); + } else { + LOG(WARNING) << "Cannot find hidden network: " << ssid; + // TODO(chocobo): Show error message. + } } } diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index ab0ee2dc6..e18e71f 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -44,6 +44,7 @@ struct WifiNetwork { ssid(service.name), encrypted(service.passphrase_required), encryption(service.security), + passphrase(service.passphrase), strength(service.strength), connecting(connecting), connected(connected), @@ -59,6 +60,7 @@ struct WifiNetwork { std::string ssid; bool encrypted; chromeos::ConnectionSecurity encryption; + std::string passphrase; int strength; bool connecting; bool connected; diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc index 2e09b8d..6756131 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.cc +++ b/chrome/browser/chromeos/options/wifi_config_view.cc @@ -103,6 +103,8 @@ void WifiConfigView::Init() { passphrase_textfield_ = new views::Textfield( views::Textfield::STYLE_PASSWORD); passphrase_textfield_->SetController(this); + if (!wifi_.passphrase.empty()) + passphrase_textfield_->SetText(UTF8ToUTF16(wifi_.passphrase)); layout->AddView(passphrase_textfield_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); } -- cgit v1.1