Chromium Code Reviews| Index: chrome/browser/local_discovery/wifi/wifi_manager_nonchromeos.cc |
| diff --git a/chrome/browser/local_discovery/wifi/wifi_manager_nonchromeos.cc b/chrome/browser/local_discovery/wifi/wifi_manager_nonchromeos.cc |
| index 601070fa10b2dd909af92677e01168f69202da9f..50e8bcaf1fd0b0329519b38844d2391eccbd003a 100644 |
| --- a/chrome/browser/local_discovery/wifi/wifi_manager_nonchromeos.cc |
| +++ b/chrome/browser/local_discovery/wifi/wifi_manager_nonchromeos.cc |
| @@ -12,6 +12,10 @@ |
| #include "content/public/browser/browser_thread.h" |
| #include "net/base/network_change_notifier.h" |
| +#if defined(OS_WIN) |
| +#include "chrome/browser/local_discovery/wifi/credential_getter_win.h" |
| +#endif // OS_WIN |
| + |
| using ::wifi::WiFiService; |
| namespace local_discovery { |
| @@ -96,6 +100,13 @@ class WifiManagerNonChromeos::WifiServiceWrapper |
| const std::string& password, |
| std::string* network_guid); |
| +#if defined(OS_WIN) |
| + void PostCredentialsCallback(const WifiManager::CredentialsCallback& callback, |
| + const std::string& ssid, |
| + bool success, |
| + const std::string& password); |
| +#endif // OS_WIN |
| + |
| scoped_ptr<WiFiService> wifi_service_; |
| base::WeakPtr<WifiManagerNonChromeos> wifi_manager_; |
| @@ -113,6 +124,10 @@ class WifiManagerNonChromeos::WifiServiceWrapper |
| base::WeakPtrFactory<WifiServiceWrapper> weak_factory_; |
| +#if defined(OS_WIN) |
| + scoped_refptr<CredentialGetterWin> credential_getter_; |
| +#endif // OS_WIN |
| + |
| DISALLOW_COPY_AND_ASSIGN(WifiServiceWrapper); |
| }; |
| @@ -286,10 +301,6 @@ void WifiManagerNonChromeos::WifiServiceWrapper::RequestNetworkCredentials( |
| std::string ssid; |
| std::string key; |
| -#if defined(OS_WIN) |
| - NOTIMPLEMENTED(); |
| - success = false; |
| -#else |
| base::DictionaryValue properties; |
| std::string error_string; |
| wifi_service_->GetProperties(network_guid, &properties, &error_string); |
| @@ -304,16 +315,29 @@ void WifiManagerNonChromeos::WifiServiceWrapper::RequestNetworkCredentials( |
| success = false; |
| } |
| - if (success) { |
| + if (!success) { |
| + PostClosure(base::Bind(callback, success, "", "")); |
| + return; |
| + } |
| + |
| +#if defined(OS_WIN) |
| + credential_getter_ = new CredentialGetterWin(); |
| + credential_getter_->StartGetCredentials( |
| + network_guid, |
| + base::Bind(&WifiServiceWrapper::PostCredentialsCallback, |
| + AsWeakPtr(), |
| + callback, |
| + ssid)); |
| +#else |
| wifi_service_->GetKeyFromSystem(network_guid, &key, &error_string); |
| if (!error_string.empty()) { |
| LOG(ERROR) << "Could not get key from system: " << error_string; |
| success = false; |
| } |
| - } |
| + |
| + PostClosure(base::Bind(callback, success, ssid, key)); |
| #endif // OS_WIN |
| - PostClosure(base::Bind(callback, success, ssid, key)); |
| } |
| void WifiManagerNonChromeos::WifiServiceWrapper::OnNetworkChanged( |
| @@ -414,6 +438,17 @@ void WifiManagerNonChromeos::WifiServiceWrapper::PostClosure( |
| base::Bind(&WifiManagerNonChromeos::PostClosure, wifi_manager_, closure)); |
| } |
| +#if defined(OS_WIN) |
|
stevenjb
2014/06/23 17:12:20
nit: WS
Noam Samuel
2014/06/23 17:55:44
Done.
|
| +void WifiManagerNonChromeos::WifiServiceWrapper::PostCredentialsCallback( |
| + const WifiManager::CredentialsCallback& callback, |
| + const std::string& ssid, |
| + bool success, |
| + const std::string& password) { |
| + PostClosure(base::Bind(callback, success, ssid, password)); |
| +} |
| + |
| +#endif // OS_WIN |
| + |
| scoped_ptr<WifiManager> WifiManager::CreateDefault() { |
| return scoped_ptr<WifiManager>(new WifiManagerNonChromeos()); |
| } |