| 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 b01e6f486a860947a1ebe56c5d34dd62f8298bd6..e68c5f8fb9af619849b1625ec7e2c9f924bf7751 100644
|
| --- a/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc
|
| +++ b/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc
|
| @@ -136,8 +136,6 @@
|
|
|
| void RemoveSession(int session_id);
|
|
|
| - scoped_ptr<base::ListValue> GetPrefetchedSSIDList();
|
| -
|
| private:
|
| typedef std::map<std::string /* id_string */,
|
| linked_ptr<api::gcd_private::GCDDevice> > GCDDeviceMap;
|
| @@ -393,7 +391,10 @@
|
| if (api == kPrivatAPISetup) {
|
| const base::DictionaryValue* wifi = NULL;
|
|
|
| - if (input.GetDictionary(kPrivetKeyWifi, &wifi)) {
|
| + if (input.GetDictionary(kPrivetKeyWifi, &wifi) &&
|
| + !wifi->HasKey(kPrivetKeyPassphrase)) {
|
| + // If the message is a setup message, has a wifi section, try sending the
|
| + // passphrase.
|
| std::string ssid;
|
|
|
| if (!wifi->GetString(kPrivetKeySSID, &ssid)) {
|
| @@ -402,21 +403,16 @@
|
| return;
|
| }
|
|
|
| - if (!wifi->HasKey(kPrivetKeyPassphrase)) {
|
| - // If the message is a setup message, has a wifi section, try sending
|
| - // the passphrase.
|
| -
|
| - 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();
|
| + 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
|
| @@ -471,20 +467,6 @@
|
| sessions_.erase(session_id);
|
| }
|
|
|
| -scoped_ptr<base::ListValue> GcdPrivateAPIImpl::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();
|
| -}
|
| -
|
| GcdPrivateRequest::GcdPrivateRequest(
|
| const std::string& api,
|
| const base::DictionaryValue& input,
|
| @@ -704,6 +686,9 @@
|
| bool GcdPrivateQueryForNewLocalDevicesFunction::RunSync() {
|
| GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile());
|
|
|
| + if (!gcd_api)
|
| + return false;
|
| +
|
| if (!gcd_api->QueryForDevices()) {
|
| error_ =
|
| "You must first subscribe to onDeviceStateChanged or onDeviceRemoved "
|
| @@ -730,6 +715,9 @@
|
| return false;
|
|
|
| GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile());
|
| +
|
| + if (!gcd_api)
|
| + return false;
|
|
|
| gcd_api->RequestWifiPassword(
|
| params->ssid,
|
| @@ -759,6 +747,9 @@
|
| return false;
|
|
|
| GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile());
|
| +
|
| + if (!gcd_api)
|
| + return false;
|
|
|
| gcd_api->EstablishSession(
|
| params->ip_address,
|
| @@ -794,6 +785,9 @@
|
|
|
| GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile());
|
|
|
| + if (!gcd_api)
|
| + return false;
|
| +
|
| gcd_api->ConfirmCode(
|
| params->session_id,
|
| base::Bind(&GcdPrivateConfirmCodeFunction::OnSessionEstablishedCallback,
|
| @@ -823,6 +817,8 @@
|
|
|
| GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile());
|
|
|
| + if (!gcd_api)
|
| + return false;
|
|
|
| gcd_api->SendMessage(
|
| params->session_id,
|
| @@ -858,6 +854,9 @@
|
|
|
| GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile());
|
|
|
| + if (!gcd_api)
|
| + return false;
|
| +
|
| gcd_api->RemoveSession(params->session_id);
|
|
|
| SendResponse(true);
|
| @@ -872,24 +871,6 @@
|
| ~GcdPrivateGetCommandDefinitionsFunction() {
|
| }
|
|
|
| -GcdPrivateGetPrefetchedWifiNameListFunction::
|
| - GcdPrivateGetPrefetchedWifiNameListFunction() {
|
| -}
|
| -
|
| -GcdPrivateGetPrefetchedWifiNameListFunction::
|
| - ~GcdPrivateGetPrefetchedWifiNameListFunction() {
|
| -}
|
| -
|
| -bool GcdPrivateGetPrefetchedWifiNameListFunction::RunSync() {
|
| - GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile());
|
| -
|
| - scoped_ptr<base::ListValue> ssid_list = gcd_api->GetPrefetchedSSIDList();
|
| -
|
| - SetResult(ssid_list.release());
|
| -
|
| - return true;
|
| -}
|
| -
|
| bool GcdPrivateGetCommandDefinitionsFunction::RunAsync() {
|
| return false;
|
| }
|
|
|