Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1828)

Unified Diff: components/wifi/wifi_service_mac.mm

Issue 102993002: Implement Networking Private API VerifyAndEncryptCredentials method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implement GetWiFiPasswordFromSystem on Mac. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/wifi/wifi_service_mac.mm
diff --git a/components/wifi/wifi_service_mac.mm b/components/wifi/wifi_service_mac.mm
index ffe3846d8306de6ae7f35f424ccf8f45d2871016..6593516a522f6cb5759bcd4d7cd298f54f9e3a58 100644
--- a/components/wifi/wifi_service_mac.mm
+++ b/components/wifi/wifi_service_mac.mm
@@ -97,6 +97,10 @@ class WiFiServiceMac : 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,
@@ -367,6 +371,32 @@ void WiFiServiceMac::StartDisconnect(const std::string& network_guid,
}
}
+void WiFiServiceMac::GetPassphraseFromSystem(const std::string& network_guid,
+ std::string* passphrase,
+ std::string* error) {
+ const char kAirPortServiceName[] = "AirPort";
+
+ UInt32 password_length = 0;
+ void *password_data = nil;
+
+ OSStatus status = SecKeychainFindGenericPassword(NULL,
+ strlen(kAirPortServiceName),
+ kAirPortServiceName,
+ network_guid.length(),
+ network_guid.c_str(),
+ &password_length,
+ &password_data,
+ NULL);
+ if (status != noErr) {
+ *error = kErrorNotFound;
+ return;
+ }
+ *passphrase = std::string(reinterpret_cast<char*>(password_data),
+ password_length);
+ if (password_data)
+ SecKeychainItemFreeContent(NULL, password_data);
+}
+
void WiFiServiceMac::SetEventObservers(
scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
const NetworkGuidListCallback& networks_changed_observer,

Powered by Google App Engine
This is Rietveld 408576698