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

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: Merge branch 'master' of https://chromium.googlesource.com/chromium/src into headlessport Created 3 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 | « headless/public/headless_browser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #if !defined(OS_MACOSX) 34 #if !defined(OS_MACOSX)
34 gl_implementation("osmesa"), 35 gl_implementation("osmesa"),
35 #else 36 #else
36 gl_implementation("any"), 37 gl_implementation("any"),
37 #endif 38 #endif
38 product_name_and_version(GetProductNameAndVersion()), 39 product_name_and_version(GetProductNameAndVersion()),
39 user_agent(content::BuildUserAgentFromProduct(product_name_and_version)), 40 user_agent(content::BuildUserAgentFromProduct(product_name_and_version)),
40 window_size(kDefaultWindowSize), 41 window_size(kDefaultWindowSize),
41 incognito_mode(true), 42 incognito_mode(true),
42 enable_crash_reporter(false) { 43 enable_crash_reporter(false) {
43 } 44 }
44 45
45 Options::Options(Options&& options) = default; 46 Options::Options(Options&& options) = default;
46 47
47 Options::~Options() {} 48 Options::~Options() {}
48 49
49 Options& Options::operator=(Options&& options) = default; 50 Options& Options::operator=(Options&& options) = default;
50 51
52 bool Options::DevtoolsServerEnabled() {
53 return (devtools_endpoint.address().IsValid() || devtools_socket_fd != 0);
54 }
55
51 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {} 56 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {}
52 57
53 Builder::Builder() : options_(0, nullptr) {} 58 Builder::Builder() : options_(0, nullptr) {}
54 59
55 Builder::~Builder() {} 60 Builder::~Builder() {}
56 61
57 Builder& Builder::SetProductNameAndVersion( 62 Builder& Builder::SetProductNameAndVersion(
58 const std::string& product_name_and_version) { 63 const std::string& product_name_and_version) {
59 options_.product_name_and_version = product_name_and_version; 64 options_.product_name_and_version = product_name_and_version;
60 return *this; 65 return *this;
61 } 66 }
62 67
63 Builder& Builder::SetUserAgent(const std::string& user_agent) { 68 Builder& Builder::SetUserAgent(const std::string& user_agent) {
64 options_.user_agent = user_agent; 69 options_.user_agent = user_agent;
65 return *this; 70 return *this;
66 } 71 }
67 72
68 Builder& Builder::EnableDevToolsServer(const net::IPEndPoint& endpoint) { 73 Builder& Builder::EnableDevToolsServer(const net::IPEndPoint& endpoint) {
69 options_.devtools_endpoint = endpoint; 74 options_.devtools_endpoint = endpoint;
70 return *this; 75 return *this;
71 } 76 }
72 77
78 Builder& Builder::EnableDevToolsServer(const size_t socket_fd) {
79 options_.devtools_socket_fd = socket_fd;
80 return *this;
81 }
82
73 Builder& Builder::SetMessagePump(base::MessagePump* message_pump) { 83 Builder& Builder::SetMessagePump(base::MessagePump* message_pump) {
74 options_.message_pump = message_pump; 84 options_.message_pump = message_pump;
75 return *this; 85 return *this;
76 } 86 }
77 87
78 Builder& Builder::SetProxyServer(const net::HostPortPair& proxy_server) { 88 Builder& Builder::SetProxyServer(const net::HostPortPair& proxy_server) {
79 options_.proxy_server = proxy_server; 89 options_.proxy_server = proxy_server;
80 return *this; 90 return *this;
81 } 91 }
82 92
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 Builder& Builder::SetCrashDumpsDir(const base::FilePath& dir) { 144 Builder& Builder::SetCrashDumpsDir(const base::FilePath& dir) {
135 options_.crash_dumps_dir = dir; 145 options_.crash_dumps_dir = dir;
136 return *this; 146 return *this;
137 } 147 }
138 148
139 Options Builder::Build() { 149 Options Builder::Build() {
140 return std::move(options_); 150 return std::move(options_);
141 } 151 }
142 152
143 } // namespace headless 153 } // namespace headless
OLDNEW
« no previous file with comments | « headless/public/headless_browser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698