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

Side by Side Diff: headless/public/headless_browser.cc

Issue 2810353003: Adds a command-line flag indicating an open and listening socket to (Closed)
Patch Set: Updated upstream dependency Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "headless/public/headless_browser.h" 5 #include "headless/public/headless_browser.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/public/common/user_agent.h" 9 #include "content/public/common/user_agent.h"
10 #include "headless/public/version.h" 10 #include "headless/public/version.h"
11 11
12 using Options = headless::HeadlessBrowser::Options; 12 using Options = headless::HeadlessBrowser::Options;
13 using Builder = headless::HeadlessBrowser::Options::Builder; 13 using Builder = headless::HeadlessBrowser::Options::Builder;
14 14
15 namespace headless { 15 namespace headless {
16 16
17 namespace { 17 namespace {
18 // Product name for building the default user agent string. 18 // Product name for building the default user agent string.
19 const char kProductName[] = "HeadlessChrome"; 19 const char kProductName[] = "HeadlessChrome";
20 constexpr gfx::Size kDefaultWindowSize(800, 600); 20 constexpr gfx::Size kDefaultWindowSize(800, 600);
21 21
22 std::string GetProductNameAndVersion() { 22 std::string GetProductNameAndVersion() {
23 return std::string(kProductName) + "/" + PRODUCT_VERSION; 23 return std::string(kProductName) + "/" + PRODUCT_VERSION;
24 } 24 }
25 } // namespace 25 } // namespace
26 26
27 Options::Options(int argc, const char** argv) 27 Options::Options(int argc, const char** argv)
28 : argc(argc), 28 : argc(argc),
29 argv(argv), 29 argv(argv),
30 devtools_socket_fd(0),
30 message_pump(nullptr), 31 message_pump(nullptr),
31 single_process_mode(false), 32 single_process_mode(false),
32 disable_sandbox(false), 33 disable_sandbox(false),
33 gl_implementation("osmesa"), 34 gl_implementation("osmesa"),
34 product_name_and_version(GetProductNameAndVersion()), 35 product_name_and_version(GetProductNameAndVersion()),
35 user_agent(content::BuildUserAgentFromProduct(product_name_and_version)), 36 user_agent(content::BuildUserAgentFromProduct(product_name_and_version)),
36 window_size(kDefaultWindowSize), 37 window_size(kDefaultWindowSize),
37 incognito_mode(true), 38 incognito_mode(true),
38 enable_crash_reporter(false) {} 39 enable_crash_reporter(false) {}
39 40
40 Options::Options(Options&& options) = default; 41 Options::Options(Options&& options) = default;
41 42
42 Options::~Options() {} 43 Options::~Options() {}
43 44
44 Options& Options::operator=(Options&& options) = default; 45 Options& Options::operator=(Options&& options) = default;
45 46
47 bool Options::DevtoolsServerEnabled() {
48 return (devtools_endpoint.address().IsValid() || devtools_socket_fd != 0);
49 }
50
46 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {} 51 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {}
47 52
48 Builder::Builder() : options_(0, nullptr) {} 53 Builder::Builder() : options_(0, nullptr) {}
49 54
50 Builder::~Builder() {} 55 Builder::~Builder() {}
51 56
52 Builder& Builder::SetProductNameAndVersion( 57 Builder& Builder::SetProductNameAndVersion(
53 const std::string& product_name_and_version) { 58 const std::string& product_name_and_version) {
54 options_.product_name_and_version = product_name_and_version; 59 options_.product_name_and_version = product_name_and_version;
55 return *this; 60 return *this;
56 } 61 }
57 62
58 Builder& Builder::SetUserAgent(const std::string& user_agent) { 63 Builder& Builder::SetUserAgent(const std::string& user_agent) {
59 options_.user_agent = user_agent; 64 options_.user_agent = user_agent;
60 return *this; 65 return *this;
61 } 66 }
62 67
63 Builder& Builder::EnableDevToolsServer(const net::IPEndPoint& endpoint) { 68 Builder& Builder::EnableDevToolsServer(const net::IPEndPoint& endpoint) {
64 options_.devtools_endpoint = endpoint; 69 options_.devtools_endpoint = endpoint;
65 return *this; 70 return *this;
66 } 71 }
67 72
73 Builder& Builder::EnableDevToolsServer(const size_t socket_fd) {
74 options_.devtools_socket_fd = socket_fd;
75 return *this;
76 }
77
68 Builder& Builder::SetMessagePump(base::MessagePump* message_pump) { 78 Builder& Builder::SetMessagePump(base::MessagePump* message_pump) {
69 options_.message_pump = message_pump; 79 options_.message_pump = message_pump;
70 return *this; 80 return *this;
71 } 81 }
72 82
73 Builder& Builder::SetProxyServer(const net::HostPortPair& proxy_server) { 83 Builder& Builder::SetProxyServer(const net::HostPortPair& proxy_server) {
74 options_.proxy_server = proxy_server; 84 options_.proxy_server = proxy_server;
75 return *this; 85 return *this;
76 } 86 }
77 87
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 Builder& Builder::SetCrashDumpsDir(const base::FilePath& dir) { 139 Builder& Builder::SetCrashDumpsDir(const base::FilePath& dir) {
130 options_.crash_dumps_dir = dir; 140 options_.crash_dumps_dir = dir;
131 return *this; 141 return *this;
132 } 142 }
133 143
134 Options Builder::Build() { 144 Options Builder::Build() {
135 return std::move(options_); 145 return std::move(options_);
136 } 146 }
137 147
138 } // namespace headless 148 } // namespace headless
OLDNEW
« headless/lib/browser/headless_devtools.cc ('K') | « headless/public/headless_browser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698