Index: chrome/utility/chrome_content_utility_client.cc |
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc |
index d7ec6a762fe402004a3e58fdc2d5628c279a88b5..7070023e42f404242555d2b6180eaad6f72ce178 100644 |
--- a/chrome/utility/chrome_content_utility_client.cc |
+++ b/chrome/utility/chrome_content_utility_client.cc |
@@ -47,7 +47,9 @@ |
#if defined(OS_WIN) |
#include "base/win/iat_patch_function.h" |
#include "base/win/scoped_handle.h" |
+#include "chrome/common/extensions/api/networking_private/networking_private_crypto.h" |
#include "chrome/utility/media_galleries/itunes_pref_parser_win.h" |
+#include "components/wifi/wifi_service.h" |
#include "printing/emf_win.h" |
#include "ui/gfx/gdi_util.h" |
#endif // defined(OS_WIN) |
@@ -400,6 +402,11 @@ bool ChromeContentUtilityClient::OnMessageReceived( |
OnIndexPicasaAlbumsContents) |
#endif // defined(OS_WIN) || defined(OS_MACOSX) |
+#if defined(OS_WIN) |
+ IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GetAndEncryptWiFiCredentials, |
+ OnGetAndEncryptWiFiCredentials) |
+#endif // defined(OS_WIN) |
+ |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
@@ -902,4 +909,27 @@ void ChromeContentUtilityClient::OnIndexPicasaAlbumsContents( |
} |
#endif // defined(OS_WIN) || defined(OS_MACOSX) |
+#if defined(OS_WIN) |
+void ChromeContentUtilityClient::OnGetAndEncryptWiFiCredentials( |
+ const std::string& network_guid, |
palmer
2014/03/05 00:20:54
Can we use the GUID type in base/guid.h instead?
mef
2014/03/05 01:21:40
It is (admittedly confusingly) called |network_gui
|
+ const std::vector<uint8>& public_key) { |
+ scoped_ptr<wifi::WiFiService> wifi_service(wifi::WiFiService::Create()); |
+ wifi_service->Initialize(NULL); |
+ |
+ std::string key_data; |
+ std::string error; |
+ wifi_service->GetKeyFromSystem(network_guid, &key_data, &error); |
palmer
2014/03/05 00:20:54
Ah, I see. This function expects strings. Is it po
mef
2014/03/05 01:21:40
Strictly speaking WiFiService is a component that
|
+ |
+ std::vector<uint8> ciphertext; |
+ bool success = error.empty() && !key_data.empty(); |
+ if (success) { |
+ NetworkingPrivateCrypto crypto; |
+ success = crypto.EncryptByteString(public_key, key_data, &ciphertext); |
+ } |
+ |
+ Send(new ChromeUtilityHostMsg_GotEncryptedWiFiCredentials(ciphertext, |
+ success)); |
+} |
+#endif // defined(OS_WIN) |
+ |
} // namespace chrome |