Chromium Code Reviews| Index: chrome/browser/automation/testing_automation_provider_chromeos.cc |
| diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc |
| index 02014979fcfb5877cfe7f822029eb2af0479ebb0..90cda2bb5fed6754e613a99da6e0ce729109becc 100644 |
| --- a/chrome/browser/automation/testing_automation_provider_chromeos.cc |
| +++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc |
| @@ -196,6 +196,22 @@ void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args, |
| reply.SendSuccess(return_value.get()); |
| } |
| +void TestingAutomationProvider::NetworkScan(DictionaryValue* args, |
| + IPC::Message* reply_message) { |
| + AutomationJSONReply reply(this, reply_message); |
| + |
| + if (!CrosLibrary::Get()->EnsureLoaded()) { |
| + reply.SendError("Could not load cros library."); |
| + return; |
| + } |
| + |
| + NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
|
dennis_jeffrey
2011/03/24 23:48:54
Are we guaranteed that this variable will be non-N
dtu
2011/03/25 22:22:11
Yes, see stevenjb's comment.
|
| + network_library->RequestNetworkScan(); |
| + |
| + // Set up an observer (it will delete itself). |
| + new NetworkScanObserver(this, reply_message); |
| +} |
| + |
| void TestingAutomationProvider::ConnectToWifiNetwork( |
| DictionaryValue* args, IPC::Message* reply_message) { |
| AutomationJSONReply reply(this, reply_message); |
| @@ -217,7 +233,7 @@ void TestingAutomationProvider::ConnectToWifiNetwork( |
| chromeos::WifiNetwork* wifi = |
| network_library->FindWifiNetworkByPath(service_path); |
| if (!wifi) { |
| - reply.SendError("Failed to connect"); |
| + reply.SendError("No network found with specified service path."); |
| return; |
| } |
| if (!password.empty()) |
| @@ -226,10 +242,36 @@ void TestingAutomationProvider::ConnectToWifiNetwork( |
| wifi->SetIdentity(identity); |
| if (!certpath.empty()) |
| wifi->SetCertPath(certpath); |
| + |
| + // Set up an observer (it will delete itself). |
| + new NetworkConnectObserver(this, reply_message, wifi); |
|
stevenjb
2011/03/25 01:12:22
See my notes in NetworkConnectObserver, but we are
dtu
2011/03/25 22:22:11
Done.
|
| + |
| network_library->ConnectToWifiNetwork(service_path); |
|
stevenjb
2011/03/25 01:12:22
It is now valid and slightly more optimal to pass
dtu
2011/03/25 22:22:11
Done.
|
| + network_library->RequestNetworkScan(); |
| +} |
| - // TODO(stevenjb): Observe the network library and check for a successful |
| - // connection. |
| +void TestingAutomationProvider::DisconnectFromWifiNetwork( |
| + DictionaryValue* args, IPC::Message* reply_message) { |
| + AutomationJSONReply reply(this, reply_message); |
| + std::string service_path; |
| + if (!args->GetString("service_path", &service_path)) { |
| + reply.SendError("Invalid or missing args"); |
|
dennis_jeffrey
2011/03/24 23:48:54
Put period at end of the string sentence (to be co
dtu
2011/03/25 22:22:11
Done.
|
| + return; |
| + } |
| + |
| + if (!CrosLibrary::Get()->EnsureLoaded()) { |
| + reply.SendError("Could not load cros library."); |
| + return; |
| + } |
| + |
| + NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
|
dennis_jeffrey
2011/03/24 23:48:54
Same comment as line 208 above.
dtu
2011/03/25 22:22:11
Same reply as line 208 above.
|
| + chromeos::WifiNetwork* wifi = |
| + network_library->FindWifiNetworkByPath(service_path); |
| + if (!wifi) { |
| + reply.SendError("No network found with specified service path."); |
| + return; |
| + } |
| + network_library->DisconnectFromWirelessNetwork(wifi); |
| reply.SendSuccess(NULL); |
| } |