Chromium Code Reviews| 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 <iostream> | 6 #include <iostream> |
|
tbarzic
2013/11/27 19:59:57
you should not have to use stdio/iostream. Isn't L
mef
2013/11/27 21:23:57
Is there strong preference / suggestion of one vs
tbarzic
2013/12/02 19:05:56
Yes, there is a strong preference for using VLOG/L
mef
2013/12/02 20:03:20
Done.
| |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 result_ = RESULT_PENDING; | 81 result_ = RESULT_PENDING; |
| 82 | 82 |
| 83 return result_; | 83 return result_; |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { | 86 bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) { |
| 87 CommandLine::Init(argc, argv); | 87 CommandLine::Init(argc, argv); |
| 88 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 88 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 89 std::string network_guid = | 89 std::string network_guid = |
| 90 parsed_command_line.GetSwitchValueASCII("network_guid"); | 90 parsed_command_line.GetSwitchValueASCII("network_guid"); |
| 91 std::string frequency = | |
| 92 parsed_command_line.GetSwitchValueASCII("frequency"); | |
| 91 | 93 |
| 92 if (parsed_command_line.GetArgs().size() == 1) { | 94 if (parsed_command_line.GetArgs().size() == 1) { |
| 93 #if defined(OS_WIN) | 95 #if defined(OS_WIN) |
| 94 network_guid = WideToASCII(parsed_command_line.GetArgs()[0]); | 96 network_guid = WideToASCII(parsed_command_line.GetArgs()[0]); |
| 95 #else | 97 #else |
| 96 network_guid = parsed_command_line.GetArgs()[0]; | 98 network_guid = parsed_command_line.GetArgs()[0]; |
| 97 #endif | 99 #endif |
| 98 } | 100 } |
| 99 | 101 |
| 100 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 120 if (parsed_command_line.HasSwitch("get_properties")) { | 122 if (parsed_command_line.HasSwitch("get_properties")) { |
| 121 if (network_guid.length() > 0) { | 123 if (network_guid.length() > 0) { |
| 122 DictionaryValue properties; | 124 DictionaryValue properties; |
| 123 std::string error; | 125 std::string error; |
| 124 wifi_service->GetProperties(network_guid, &properties, &error); | 126 wifi_service->GetProperties(network_guid, &properties, &error); |
| 125 std::cout << error << ":\n" << properties; | 127 std::cout << error << ":\n" << properties; |
| 126 return true; | 128 return true; |
| 127 } | 129 } |
| 128 } | 130 } |
| 129 | 131 |
| 132 // Optional properties (frequency, password) to use for connect. | |
| 133 scoped_ptr<DictionaryValue> connect_properties(new DictionaryValue()); | |
| 134 | |
| 135 if (parsed_command_line.HasSwitch("frequency")) { | |
| 136 int value = 0; | |
| 137 if (!network_guid.empty() && | |
| 138 !frequency.empty() && | |
| 139 base::StringToInt(frequency, &value)) { | |
| 140 connect_properties->SetInteger("WiFi.Frequency", value); | |
| 141 // fall through to connect. | |
| 142 } | |
| 143 } | |
| 144 | |
| 130 if (parsed_command_line.HasSwitch("connect")) { | 145 if (parsed_command_line.HasSwitch("connect")) { |
| 131 if (network_guid.length() > 0) { | 146 if (network_guid.length() > 0) { |
| 132 std::string error; | 147 std::string error; |
| 148 if (!connect_properties->empty()) { | |
| 149 std::cout << "Using connect properties: " << *connect_properties; | |
| 150 wifi_service->SetProperties(network_guid, | |
| 151 connect_properties.Pass(), | |
| 152 &error); | |
| 153 } | |
| 133 wifi_service->StartConnect(network_guid, &error); | 154 wifi_service->StartConnect(network_guid, &error); |
| 134 std::cout << error; | 155 std::cout << error; |
| 135 return true; | 156 return true; |
| 136 } | 157 } |
| 137 } | 158 } |
| 138 | 159 |
| 139 if (parsed_command_line.HasSwitch("disconnect")) { | 160 if (parsed_command_line.HasSwitch("disconnect")) { |
| 140 if (network_guid.length() > 0) { | 161 if (network_guid.length() > 0) { |
| 141 std::string error; | 162 std::string error; |
| 142 wifi_service->StartDisconnect(network_guid, &error); | 163 wifi_service->StartDisconnect(network_guid, &error); |
| 143 std::cout << error; | 164 std::cout << error; |
| 144 return true; | 165 return true; |
| 145 } | 166 } |
| 146 } | 167 } |
| 147 | 168 |
| 148 return false; | 169 return false; |
| 149 } | 170 } |
| 150 | 171 |
| 151 } // namespace wifi | 172 } // namespace wifi |
| 152 | 173 |
| 153 int main(int argc, const char* argv[]) { | 174 int main(int argc, const char* argv[]) { |
| 154 wifi::WiFiTest wifi_test; | 175 wifi::WiFiTest wifi_test; |
| 155 return wifi_test.Main(argc, argv); | 176 return wifi_test.Main(argc, argv); |
| 156 } | 177 } |
| OLD | NEW |