OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <locale> | 6 #include <locale> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 280 } |
281 if (cmd_line->HasSwitch("url-base")) | 281 if (cmd_line->HasSwitch("url-base")) |
282 url_base = cmd_line->GetSwitchValueASCII("url-base"); | 282 url_base = cmd_line->GetSwitchValueASCII("url-base"); |
283 if (url_base.empty() || url_base[0] != '/') | 283 if (url_base.empty() || url_base[0] != '/') |
284 url_base = "/" + url_base; | 284 url_base = "/" + url_base; |
285 if (url_base[url_base.length() - 1] != '/') | 285 if (url_base[url_base.length() - 1] != '/') |
286 url_base = url_base + "/"; | 286 url_base = url_base + "/"; |
287 if (cmd_line->HasSwitch("whitelisted-ips")) { | 287 if (cmd_line->HasSwitch("whitelisted-ips")) { |
288 allow_remote = true; | 288 allow_remote = true; |
289 std::string whitelist = cmd_line->GetSwitchValueASCII("whitelisted-ips"); | 289 std::string whitelist = cmd_line->GetSwitchValueASCII("whitelisted-ips"); |
290 base::SplitString(whitelist, ',', &whitelisted_ips); | 290 whitelisted_ips = base::SplitString( |
| 291 whitelist, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
291 } | 292 } |
292 if (!cmd_line->HasSwitch("silent")) { | 293 if (!cmd_line->HasSwitch("silent")) { |
293 printf("Starting ChromeDriver %s on port %u\n", kChromeDriverVersion, port); | 294 printf("Starting ChromeDriver %s on port %u\n", kChromeDriverVersion, port); |
294 if (!allow_remote) { | 295 if (!allow_remote) { |
295 printf("Only local connections are allowed.\n"); | 296 printf("Only local connections are allowed.\n"); |
296 } else if (!whitelisted_ips.empty()) { | 297 } else if (!whitelisted_ips.empty()) { |
297 printf("Remote connections are allowed by a whitelist (%s).\n", | 298 printf("Remote connections are allowed by a whitelist (%s).\n", |
298 cmd_line->GetSwitchValueASCII("whitelisted-ips").c_str()); | 299 cmd_line->GetSwitchValueASCII("whitelisted-ips").c_str()); |
299 } else { | 300 } else { |
300 printf("All remote connections are allowed. Use a whitelist instead!\n"); | 301 printf("All remote connections are allowed. Use a whitelist instead!\n"); |
301 } | 302 } |
302 fflush(stdout); | 303 fflush(stdout); |
303 } | 304 } |
304 | 305 |
305 if (!InitLogging()) { | 306 if (!InitLogging()) { |
306 printf("Unable to initialize logging. Exiting...\n"); | 307 printf("Unable to initialize logging. Exiting...\n"); |
307 return 1; | 308 return 1; |
308 } | 309 } |
309 RunServer(port, allow_remote, whitelisted_ips, | 310 RunServer(port, allow_remote, whitelisted_ips, |
310 url_base, adb_port, port_server.Pass()); | 311 url_base, adb_port, port_server.Pass()); |
311 return 0; | 312 return 0; |
312 } | 313 } |
OLD | NEW |