| 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,
|
|
|