OLD | NEW |
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 "content/public/common/user_agent.h" |
5 #include "headless/public/headless_browser.h" | 6 #include "headless/public/headless_browser.h" |
| 7 #include "net/url_request/url_request_context_getter.h" |
6 | 8 |
7 using Options = headless::HeadlessBrowser::Options; | 9 using Options = headless::HeadlessBrowser::Options; |
8 using Builder = headless::HeadlessBrowser::Options::Builder; | 10 using Builder = headless::HeadlessBrowser::Options::Builder; |
9 | 11 |
10 namespace headless { | 12 namespace headless { |
11 | 13 |
| 14 // Product name for building the default user agent string. |
| 15 namespace { |
| 16 const char kProductName[] = "HeadlessChrome"; |
| 17 } |
| 18 |
12 Options::Options(int argc, const char** argv) | 19 Options::Options(int argc, const char** argv) |
13 : argc(argc), argv(argv), devtools_http_port(kInvalidPort) {} | 20 : argc(argc), |
| 21 argv(argv), |
| 22 user_agent(content::BuildUserAgentFromProduct(kProductName)), |
| 23 devtools_http_port(kInvalidPort), |
| 24 message_pump(nullptr) {} |
14 | 25 |
15 Options::~Options() {} | 26 Options::~Options() {} |
16 | 27 |
17 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {} | 28 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {} |
18 | 29 |
19 Builder::~Builder() {} | 30 Builder::~Builder() {} |
20 | 31 |
21 Builder& Builder::SetUserAgent(const std::string& user_agent) { | 32 Builder& Builder::SetUserAgent(const std::string& user_agent) { |
22 options_.user_agent = user_agent; | 33 options_.user_agent = user_agent; |
23 return *this; | 34 return *this; |
24 } | 35 } |
25 | 36 |
26 Builder& Builder::EnableDevToolsServer(int port) { | 37 Builder& Builder::EnableDevToolsServer(const std::string& address, int port) { |
| 38 options_.devtools_http_address = address; |
27 options_.devtools_http_port = port; | 39 options_.devtools_http_port = port; |
28 return *this; | 40 return *this; |
29 } | 41 } |
30 | 42 |
31 Builder& Builder::SetURLRequestContextGetter( | 43 Builder& Builder::SetMessagePump(base::MessagePump* message_pump) { |
32 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) { | 44 options_.message_pump = message_pump; |
33 options_.url_request_context_getter = url_request_context_getter; | |
34 return *this; | 45 return *this; |
35 } | 46 } |
36 | 47 |
37 Options Builder::Build() { | 48 Options Builder::Build() { |
38 return options_; | 49 return options_; |
39 } | 50 } |
40 | 51 |
41 } // namespace headless | 52 } // namespace headless |
OLD | NEW |