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

Unified Diff: headless/app/headless_shell.cc

Issue 1920773003: headless: Make it possible to override the DevTools server address (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stricter hostname validation Created 4 years, 8 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
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/app/headless_shell.cc
diff --git a/headless/app/headless_shell.cc b/headless/app/headless_shell.cc
index cc79e1ec75d039ffb771445c8bab37e0fe107c75..542f4584459ce73b617ec5415933ec6a2395cce5 100644
--- a/headless/app/headless_shell.cc
+++ b/headless/app/headless_shell.cc
@@ -122,18 +122,29 @@ int main(int argc, const char** argv) {
// Enable devtools if requested.
base::CommandLine command_line(argc, argv);
if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
+ std::string address = kDevToolsHttpServerAddress;
+ if (command_line.HasSwitch(headless::switches::kRemoteDebuggingAddress)) {
+ address = command_line.GetSwitchValueASCII(
+ headless::switches::kRemoteDebuggingAddress);
+ net::IPAddress parsed_address;
+ if (!net::ParseURLHostnameToAddress(address, &parsed_address)) {
+ LOG(ERROR) << "Invalid devtools server address";
+ return EXIT_FAILURE;
+ }
+ }
int parsed_port;
std::string port_str =
command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
- if (base::StringToInt(port_str, &parsed_port) &&
- base::IsValueInRangeForNumericType<uint16_t>(parsed_port)) {
- net::IPAddress devtools_address;
- bool result =
- devtools_address.AssignFromIPLiteral(kDevToolsHttpServerAddress);
- DCHECK(result);
- builder.EnableDevToolsServer(net::IPEndPoint(
- devtools_address, base::checked_cast<uint16_t>(parsed_port)));
+ if (!base::StringToInt(port_str, &parsed_port) ||
+ !base::IsValueInRangeForNumericType<uint16_t>(parsed_port)) {
+ LOG(ERROR) << "Invalid devtools server port";
+ return EXIT_FAILURE;
}
+ net::IPAddress devtools_address;
+ bool result = devtools_address.AssignFromIPLiteral(address);
+ DCHECK(result);
+ builder.EnableDevToolsServer(net::IPEndPoint(
+ devtools_address, base::checked_cast<uint16_t>(parsed_port)));
}
if (command_line.HasSwitch(headless::switches::kProxyServer)) {
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698