Index: chrome/browser/extensions/api/gcd_private/gcd_private_api.cc |
diff --git a/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc b/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc |
index ce5ff3a4f7c13213abb6c4bf61d1830e81a70352..a60f3a624e9f6365edeeb5d0e5c4d71e6f8a2ec5 100644 |
--- a/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc |
+++ b/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc |
@@ -285,10 +285,7 @@ void GcdPrivateAPI::SendMessage(int session_id, |
if (api == kPrivatAPISetup) { |
const base::DictionaryValue* wifi = NULL; |
- if (input.GetDictionary(kPrivetKeyWifi, &wifi) && |
- !wifi->HasKey(kPrivetKeyPassphrase)) { |
- // If the message is a setup message, has a wifi section, try sending the |
- // passphrase. |
+ if (input.GetDictionary(kPrivetKeyWifi, &wifi)) { |
std::string ssid; |
if (!wifi->GetString(kPrivetKeySSID, &ssid)) { |
@@ -297,16 +294,21 @@ void GcdPrivateAPI::SendMessage(int session_id, |
return; |
} |
- PasswordMap::iterator found = wifi_passwords_.find(ssid); |
- if (found == wifi_passwords_.end()) { |
- callback.Run(gcd_private::STATUS_WIFIPASSWORDERROR, |
- base::DictionaryValue()); |
- return; |
- } |
+ if (!wifi->HasKey(kPrivetKeyPassphrase)) { |
+ // If the message is a setup message, has a wifi section, try sending |
+ // the passphrase. |
- input_cloned.reset(input.DeepCopy()); |
- input_cloned->SetString(kPrivetKeyPassphraseDotted, found->second); |
- input_actual = input_cloned.get(); |
+ PasswordMap::iterator found = wifi_passwords_.find(ssid); |
+ if (found == wifi_passwords_.end()) { |
+ callback.Run(gcd_private::STATUS_WIFIPASSWORDERROR, |
+ base::DictionaryValue()); |
+ return; |
+ } |
+ |
+ input_cloned.reset(input.DeepCopy()); |
+ input_cloned->SetString(kPrivetKeyPassphraseDotted, found->second); |
+ input_actual = input_cloned.get(); |
+ } |
} |
} |
#endif |
@@ -360,6 +362,20 @@ void GcdPrivateAPI::RemoveSession(int session_id) { |
sessions_.erase(session_id); |
} |
+scoped_ptr<base::ListValue> GcdPrivateAPI::GetPrefetchedSSIDList() { |
+ scoped_ptr<base::ListValue> retval(new base::ListValue); |
+ |
+#if defined(ENABLE_WIFI_BOOTSTRAPPING) |
+ for (PasswordMap::iterator i = wifi_passwords_.begin(); |
+ i != wifi_passwords_.end(); |
+ i++) { |
+ retval->AppendString(i->first); |
+ } |
+#endif |
+ |
+ return retval.Pass(); |
+} |
+ |
// static |
void GcdPrivateAPI::SetGCDApiFlowFactoryForTests( |
GCDApiFlowFactoryForTests* factory) { |
@@ -567,8 +583,6 @@ bool GcdPrivateQueryForNewLocalDevicesFunction::RunSync() { |
GcdPrivateAPI* gcd_api = |
BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile()); |
- if (!gcd_api) |
- return false; |
if (!gcd_api->QueryForDevices()) { |
error_ = |
@@ -631,8 +645,6 @@ bool GcdPrivateEstablishSessionFunction::RunAsync() { |
GcdPrivateAPI* gcd_api = |
BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile()); |
- if (!gcd_api) |
- return false; |
gcd_api->EstablishSession( |
params->ip_address, |
@@ -669,8 +681,6 @@ bool GcdPrivateConfirmCodeFunction::RunAsync() { |
GcdPrivateAPI* gcd_api = |
BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile()); |
- if (!gcd_api) |
- return false; |
gcd_api->ConfirmCode( |
params->session_id, |
@@ -702,8 +712,6 @@ bool GcdPrivateSendMessageFunction::RunAsync() { |
GcdPrivateAPI* gcd_api = |
BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile()); |
- if (!gcd_api) |
- return false; |
gcd_api->SendMessage( |
params->session_id, |
@@ -740,8 +748,6 @@ bool GcdPrivateTerminateSessionFunction::RunAsync() { |
GcdPrivateAPI* gcd_api = |
BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile()); |
- if (!gcd_api) |
- return false; |
gcd_api->RemoveSession(params->session_id); |
@@ -757,6 +763,26 @@ GcdPrivateGetCommandDefinitionsFunction:: |
~GcdPrivateGetCommandDefinitionsFunction() { |
} |
+GcdPrivateGetPrefetchedWifiNameListFunction:: |
+ GcdPrivateGetPrefetchedWifiNameListFunction() { |
+} |
+ |
+GcdPrivateGetPrefetchedWifiNameListFunction:: |
+ ~GcdPrivateGetPrefetchedWifiNameListFunction() { |
+} |
+ |
+bool GcdPrivateGetPrefetchedWifiNameListFunction::RunSync() { |
+ GcdPrivateAPI* gcd_api = |
+ BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile()); |
+ |
+ DCHECK(gcd_api); |
+ scoped_ptr<base::ListValue> ssid_list = gcd_api->GetPrefetchedSSIDList(); |
+ |
+ SetResult(ssid_list.release()); |
+ |
+ return true; |
+} |
+ |
bool GcdPrivateGetCommandDefinitionsFunction::RunAsync() { |
return false; |
} |