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

Side by Side 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: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 DISALLOW_COPY_AND_ASSIGN(HeadlessShell); 94 DISALLOW_COPY_AND_ASSIGN(HeadlessShell);
95 }; 95 };
96 96
97 int main(int argc, const char** argv) { 97 int main(int argc, const char** argv) {
98 HeadlessShell shell; 98 HeadlessShell shell;
99 HeadlessBrowser::Options::Builder builder(argc, argv); 99 HeadlessBrowser::Options::Builder builder(argc, argv);
100 100
101 // Enable devtools if requested. 101 // Enable devtools if requested.
102 base::CommandLine command_line(argc, argv); 102 base::CommandLine command_line(argc, argv);
103 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { 103 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
104 std::string address = kDevToolsHttpServerAddress;
105 if (command_line.HasSwitch(headless::switches::kRemoteDebuggingAddress)) {
106 address = command_line.GetSwitchValueASCII(
107 headless::switches::kRemoteDebuggingAddress);
Mike West 2016/04/26 08:04:37 It seems reasonable to do some sanity checking her
Sami 2016/04/26 10:07:52 Good point. I've now made this use net::ParseURLHo
108 }
104 int parsed_port; 109 int parsed_port;
105 std::string port_str = 110 std::string port_str =
106 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); 111 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
107 if (base::StringToInt(port_str, &parsed_port) && 112 if (base::StringToInt(port_str, &parsed_port) &&
108 base::IsValueInRangeForNumericType<uint16_t>(parsed_port)) { 113 base::IsValueInRangeForNumericType<uint16_t>(parsed_port)) {
109 net::IPAddress devtools_address; 114 net::IPAddress devtools_address;
110 bool result = 115 bool result = devtools_address.AssignFromIPLiteral(address);
111 devtools_address.AssignFromIPLiteral(kDevToolsHttpServerAddress);
112 DCHECK(result); 116 DCHECK(result);
113 builder.EnableDevToolsServer(net::IPEndPoint( 117 builder.EnableDevToolsServer(net::IPEndPoint(
114 devtools_address, base::checked_cast<uint16_t>(parsed_port))); 118 devtools_address, base::checked_cast<uint16_t>(parsed_port)));
115 } 119 }
116 } 120 }
117 121
118 if (command_line.HasSwitch(headless::switches::kProxyServer)) { 122 if (command_line.HasSwitch(headless::switches::kProxyServer)) {
119 std::string proxy_server = 123 std::string proxy_server =
120 command_line.GetSwitchValueASCII(headless::switches::kProxyServer); 124 command_line.GetSwitchValueASCII(headless::switches::kProxyServer);
121 net::HostPortPair parsed_proxy_server = 125 net::HostPortPair parsed_proxy_server =
122 net::HostPortPair::FromString(proxy_server); 126 net::HostPortPair::FromString(proxy_server);
123 if (parsed_proxy_server.host().empty() || !parsed_proxy_server.port()) { 127 if (parsed_proxy_server.host().empty() || !parsed_proxy_server.port()) {
124 LOG(ERROR) << "Malformed proxy server url"; 128 LOG(ERROR) << "Malformed proxy server url";
125 return EXIT_FAILURE; 129 return EXIT_FAILURE;
126 } 130 }
127 builder.SetProxyServer(parsed_proxy_server); 131 builder.SetProxyServer(parsed_proxy_server);
128 } 132 }
129 133
130 if (command_line.HasSwitch(switches::kHostResolverRules)) { 134 if (command_line.HasSwitch(switches::kHostResolverRules)) {
131 builder.SetHostResolverRules( 135 builder.SetHostResolverRules(
132 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); 136 command_line.GetSwitchValueASCII(switches::kHostResolverRules));
133 } 137 }
134 138
135 return HeadlessBrowserMain( 139 return HeadlessBrowserMain(
136 builder.Build(), 140 builder.Build(),
137 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); 141 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell)));
138 } 142 }
OLDNEW
« 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