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

Unified Diff: chrome/browser/automation/testing_automation_provider_chromeos.cc

Issue 6732040: PyAuto automation hooks: blocking wifi connect, disconnect, and network scan. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes per comments. Created 9 years, 9 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: 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..9ca8f98cf4e32d0ee2f4c60d54f8714466ae4388 100644
--- a/chrome/browser/automation/testing_automation_provider_chromeos.cc
+++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc
@@ -66,7 +66,7 @@ void TestingAutomationProvider::Login(DictionaryValue* args,
if (!args->GetString("username", &username) ||
!args->GetString("password", &password)) {
AutomationJSONReply(this, reply_message).SendError(
- "Invalid or missing args");
+ "Invalid or missing args.");
return;
}
@@ -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();
+ 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);
@@ -204,7 +220,7 @@ void TestingAutomationProvider::ConnectToWifiNetwork(
!args->GetString("password", &password) ||
!args->GetString("identity", &identity) ||
!args->GetString("certpath", &certpath)) {
- reply.SendError("Invalid or missing args");
+ reply.SendError("Invalid or missing args.");
return;
}
@@ -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);
- network_library->ConnectToWifiNetwork(service_path);
- // TODO(stevenjb): Observe the network library and check for a successful
- // connection.
+ // Set up an observer (it will delete itself).
+ new NetworkConnectObserver(this, reply_message, service_path);
+
+ network_library->ConnectToWifiNetwork(wifi);
+ network_library->RequestNetworkScan();
+}
+
+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.");
+ return;
+ }
+
+ if (!CrosLibrary::Get()->EnsureLoaded()) {
+ reply.SendError("Could not load cros library.");
+ return;
+ }
+
+ NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary();
+ 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);
}

Powered by Google App Engine
This is Rietveld 408576698