| Index: components/wifi/wifi_service_win.cc
|
| diff --git a/components/wifi/wifi_service_win.cc b/components/wifi/wifi_service_win.cc
|
| index 4fe0724bf50726b24c1fef14e574ea14e1aabedf..04718a4e1f7c9111d02e87f555072ff5a3811fc5 100644
|
| --- a/components/wifi/wifi_service_win.cc
|
| +++ b/components/wifi/wifi_service_win.cc
|
| @@ -25,6 +25,8 @@
|
|
|
| namespace {
|
| const char kWiFiServiceError[] = "Error.WiFiService";
|
| +const char kWiFiServiceErrorNotImplemented[] =
|
| + "Error.WiFiService.NotImplemented";
|
| const wchar_t kNwCategoryWizardRegKey[] =
|
| L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Network\\"
|
| L"NwCategoryWizard";
|
| @@ -208,6 +210,10 @@ class WiFiServiceImpl : public WiFiService {
|
| virtual void StartDisconnect(const std::string& network_guid,
|
| std::string* error) OVERRIDE;
|
|
|
| + virtual void GetPassphraseFromSystem(const std::string& network_guid,
|
| + std::string* passphrase,
|
| + std::string* error) OVERRIDE;
|
| +
|
| virtual void SetEventObservers(
|
| scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| const NetworkGuidListCallback& networks_changed_observer,
|
| @@ -637,6 +643,38 @@ void WiFiServiceImpl::StartDisconnect(const std::string& network_guid,
|
| CheckError(error_code, kWiFiServiceError, error);
|
| }
|
|
|
| +void WiFiServiceImpl::GetPassphraseFromSystem(const std::string& network_guid,
|
| + std::string* passphrase,
|
| + std::string* error) {
|
| + DWORD error_code = EnsureInitialized();
|
| + if (CheckError(error_code, kWiFiServiceError, error))
|
| + return;
|
| +
|
| + std::string profile_xml;
|
| + error_code = GetProfile(network_guid, &profile_xml);
|
| + if (CheckError(error_code, kWiFiServiceError, error))
|
| + return;
|
| +
|
| + // Quick check to verify presence of <sharedKey> element.
|
| + if (profile_xml.find("<sharedKey>") == std::string::npos) {
|
| + *error = kWiFiServiceError;
|
| + return;
|
| + }
|
| +
|
| + XmlReader reader;
|
| + if (reader.Load(profile_xml)) {
|
| + while(reader.Read()) {
|
| + reader.SkipToElement();
|
| + if (reader.NodeName() == "keyMaterial") {
|
| + reader.ReadElementContent(passphrase);
|
| + return;
|
| + }
|
| + }
|
| + }
|
| + // Did not find passphrase in the profile.
|
| + *error = kWiFiServiceError;
|
| +}
|
| +
|
| void WiFiServiceImpl::SetEventObservers(
|
| scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| const NetworkGuidListCallback& networks_changed_observer,
|
| @@ -1450,13 +1488,14 @@ DWORD WiFiServiceImpl::GetProfile(const std::string& network_guid,
|
|
|
| DWORD error = ERROR_SUCCESS;
|
| base::string16 profile_name = ProfileNameFromGUID(network_guid);
|
| + DWORD flags = WLAN_PROFILE_GET_PLAINTEXT_KEY;
|
| LPWSTR str_profile_xml = NULL;
|
| error = WlanGetProfile_function_(client_,
|
| &interface_guid_,
|
| profile_name.c_str(),
|
| NULL,
|
| &str_profile_xml,
|
| - NULL,
|
| + &flags,
|
| NULL);
|
|
|
| if (error == ERROR_SUCCESS && str_profile_xml != NULL) {
|
|
|