Index: components/wifi/wifi_test.cc |
diff --git a/components/wifi/wifi_test.cc b/components/wifi/wifi_test.cc |
index eae084ffef5bb98cd695f6a4f95e852a41e4a66b..ff27b0d2403ac60d5ce9cad6c6bc0d6f04ef6747 100644 |
--- a/components/wifi/wifi_test.cc |
+++ b/components/wifi/wifi_test.cc |
@@ -67,10 +67,13 @@ WiFiTest::Result WiFiTest::Main(int argc, const char* argv[]) { |
VLOG(0) << "Usage: " << argv[0] << |
" [--list]" |
" [--get_properties]" |
+ " [--create]" |
" [--connect]" |
" [--disconnect]" |
" [--network_guid=<network_guid>]" |
" [--frequency=0|2400|5000]" |
+ " [--security=none|WEP-PSK|WPA-PSK|WPA2-PSK]" |
+ " [--password=<wifi password>]" |
" [<network_guid>]\n"; |
return RESULT_WRONG_USAGE; |
} |
@@ -88,6 +91,10 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { |
parsed_command_line.GetSwitchValueASCII("network_guid"); |
std::string frequency = |
parsed_command_line.GetSwitchValueASCII("frequency"); |
+ std::string password = |
+ parsed_command_line.GetSwitchValueASCII("password"); |
+ std::string security = |
+ parsed_command_line.GetSwitchValueASCII("security"); |
if (parsed_command_line.GetArgs().size() == 1) { |
#if defined(OS_WIN) |
@@ -127,26 +134,45 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { |
} |
} |
- // Optional properties (frequency, password) to use for connect. |
- scoped_ptr<DictionaryValue> connect_properties(new DictionaryValue()); |
+ // Optional properties (frequency, password) to use for connect or create. |
+ scoped_ptr<DictionaryValue> properties(new DictionaryValue()); |
- if (parsed_command_line.HasSwitch("frequency")) { |
+ if (!frequency.empty()) { |
int value = 0; |
- if (!network_guid.empty() && |
- !frequency.empty() && |
- base::StringToInt(frequency, &value)) { |
- connect_properties->SetInteger("WiFi.Frequency", value); |
+ if (base::StringToInt(frequency, &value)) { |
+ properties->SetInteger("WiFi.Frequency", value); |
// fall through to connect. |
} |
} |
+ if (!password.empty()) |
+ properties->SetString("WiFi.Passphrase", password); |
+ |
+ if (!security.empty()) |
+ properties->SetString("WiFi.Security", security); |
+ |
+ if (parsed_command_line.HasSwitch("create")) { |
+ if (!network_guid.empty()) { |
+ std::string error; |
+ std::string new_network_guid; |
+ properties->SetString("WiFi.SSID", network_guid); |
+ VLOG(0) << "Creating Network: " << *properties; |
+ wifi_service->CreateNetwork(false, |
+ properties.Pass(), |
+ &new_network_guid, |
+ &error); |
+ VLOG(0) << error << ":\n" << new_network_guid; |
+ return true; |
+ } |
+ } |
+ |
if (parsed_command_line.HasSwitch("connect")) { |
- if (network_guid.length() > 0) { |
+ if (!network_guid.empty()) { |
std::string error; |
- if (!connect_properties->empty()) { |
- VLOG(0) << "Using connect properties: " << *connect_properties; |
+ if (!properties->empty()) { |
+ VLOG(0) << "Using connect properties: " << *properties; |
wifi_service->SetProperties(network_guid, |
- connect_properties.Pass(), |
+ properties.Pass(), |
&error); |
} |
wifi_service->StartConnect(network_guid, &error); |