OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Need AtExitManager to support AsWeakPtr (in NetLog). | 59 // Need AtExitManager to support AsWeakPtr (in NetLog). |
60 base::AtExitManager exit_manager_; | 60 base::AtExitManager exit_manager_; |
61 | 61 |
62 Result result_; | 62 Result result_; |
63 }; | 63 }; |
64 | 64 |
65 WiFiTest::Result WiFiTest::Main(int argc, const char* argv[]) { | 65 WiFiTest::Result WiFiTest::Main(int argc, const char* argv[]) { |
66 if (!ParseCommandLine(argc, argv)) { | 66 if (!ParseCommandLine(argc, argv)) { |
67 VLOG(0) << "Usage: " << argv[0] << | 67 VLOG(0) << "Usage: " << argv[0] << |
68 " [--list]" | 68 " [--list]" |
| 69 " [--get_password]" |
69 " [--get_properties]" | 70 " [--get_properties]" |
70 " [--create]" | 71 " [--create]" |
71 " [--connect]" | 72 " [--connect]" |
72 " [--disconnect]" | 73 " [--disconnect]" |
73 " [--network_guid=<network_guid>]" | 74 " [--network_guid=<network_guid>]" |
74 " [--frequency=0|2400|5000]" | 75 " [--frequency=0|2400|5000]" |
75 " [--security=none|WEP-PSK|WPA-PSK|WPA2-PSK]" | 76 " [--security=none|WEP-PSK|WPA-PSK|WPA2-PSK]" |
76 " [--password=<wifi_password>]" | 77 " [--password=<wifi_password>]" |
77 " [<network_guid>]\n"; | 78 " [<network_guid>]\n"; |
78 return RESULT_WRONG_USAGE; | 79 return RESULT_WRONG_USAGE; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 184 |
184 if (parsed_command_line.HasSwitch("disconnect")) { | 185 if (parsed_command_line.HasSwitch("disconnect")) { |
185 if (network_guid.length() > 0) { | 186 if (network_guid.length() > 0) { |
186 std::string error; | 187 std::string error; |
187 wifi_service->StartDisconnect(network_guid, &error); | 188 wifi_service->StartDisconnect(network_guid, &error); |
188 VLOG(0) << error; | 189 VLOG(0) << error; |
189 return true; | 190 return true; |
190 } | 191 } |
191 } | 192 } |
192 | 193 |
| 194 if (parsed_command_line.HasSwitch("get_password")) { |
| 195 if (network_guid.length() > 0) { |
| 196 std::string error; |
| 197 std::string password; |
| 198 wifi_service->GetPassphraseFromSystem(network_guid, |
| 199 &password, |
| 200 &error); |
| 201 VLOG(0) << password << error; |
| 202 return true; |
| 203 } |
| 204 } |
| 205 |
193 return false; | 206 return false; |
194 } | 207 } |
195 | 208 |
196 } // namespace wifi | 209 } // namespace wifi |
197 | 210 |
198 int main(int argc, const char* argv[]) { | 211 int main(int argc, const char* argv[]) { |
199 CommandLine::Init(argc, argv); | 212 CommandLine::Init(argc, argv); |
200 logging::LoggingSettings settings; | 213 logging::LoggingSettings settings; |
201 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 214 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
202 logging::InitLogging(settings); | 215 logging::InitLogging(settings); |
203 | 216 |
204 wifi::WiFiTest wifi_test; | 217 wifi::WiFiTest wifi_test; |
205 return wifi_test.Main(argc, argv); | 218 return wifi_test.Main(argc, argv); |
206 } | 219 } |
OLD | NEW |