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 |
12 Options::Options(int argc, const char** argv) | 14 Options::Options(int argc, const char** argv) |
13 : argc(argc), argv(argv), devtools_http_port(kInvalidPort) {} | 15 : argc(argc), |
16 argv(argv), | |
17 user_agent(content::BuildUserAgentFromProduct("HeadlessChrome")), | |
Ryan Sleevi
2016/02/22 22:01:21
This is the sort of thing that likely belongs as a
Sami
2016/02/23 20:19:08
Yep, done.
| |
18 devtools_http_port(kInvalidPort), | |
19 message_pump(nullptr) {} | |
14 | 20 |
15 Options::~Options() {} | 21 Options::~Options() {} |
16 | 22 |
17 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {} | 23 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {} |
18 | 24 |
19 Builder::~Builder() {} | 25 Builder::~Builder() {} |
20 | 26 |
21 Builder& Builder::SetUserAgent(const std::string& user_agent) { | 27 Builder& Builder::SetUserAgent(const std::string& user_agent) { |
22 options_.user_agent = user_agent; | 28 options_.user_agent = user_agent; |
23 return *this; | 29 return *this; |
24 } | 30 } |
25 | 31 |
26 Builder& Builder::EnableDevToolsServer(int port) { | 32 Builder& Builder::EnableDevToolsServer(int port) { |
27 options_.devtools_http_port = port; | 33 options_.devtools_http_port = port; |
28 return *this; | 34 return *this; |
29 } | 35 } |
30 | 36 |
31 Builder& Builder::SetURLRequestContextGetter( | 37 Builder& Builder::SetURLRequestContextGetter( |
32 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) { | 38 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) { |
33 options_.url_request_context_getter = url_request_context_getter; | 39 options_.url_request_context_getter = url_request_context_getter; |
34 return *this; | 40 return *this; |
35 } | 41 } |
36 | 42 |
43 Builder& Builder::SetMessagePump(base::MessagePump* message_pump) { | |
44 options_.message_pump = message_pump; | |
45 return *this; | |
46 } | |
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 |