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 #ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 5 #ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "headless/public/headless_export.h" | 14 #include "headless/public/headless_export.h" |
| 15 #include "net/base/host_port_pair.h" |
15 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class MessagePump; | 19 class MessagePump; |
19 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
20 } | 21 } |
21 | 22 |
22 namespace gfx { | 23 namespace gfx { |
23 class Size; | 24 class Size; |
24 } | 25 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 61 |
61 class Builder; | 62 class Builder; |
62 | 63 |
63 // Command line options to be passed to browser. | 64 // Command line options to be passed to browser. |
64 int argc; | 65 int argc; |
65 const char** argv; | 66 const char** argv; |
66 | 67 |
67 std::string user_agent; | 68 std::string user_agent; |
68 std::string navigator_platform; | 69 std::string navigator_platform; |
69 | 70 |
| 71 // Address at which DevTools should listen for connections. Disabled by |
| 72 // default. |
70 net::IPEndPoint devtools_endpoint; | 73 net::IPEndPoint devtools_endpoint; |
71 | 74 |
| 75 // Address of the HTTP/HTTPS proxy server to use. The system proxy settings |
| 76 // are used by default. |
| 77 net::HostPortPair proxy_server; |
| 78 |
72 // Optional message pump that overrides the default. Must outlive the browser. | 79 // Optional message pump that overrides the default. Must outlive the browser. |
73 base::MessagePump* message_pump; | 80 base::MessagePump* message_pump; |
74 | 81 |
75 private: | 82 private: |
76 Options(int argc, const char** argv); | 83 Options(int argc, const char** argv); |
77 }; | 84 }; |
78 | 85 |
79 class HeadlessBrowser::Options::Builder { | 86 class HeadlessBrowser::Options::Builder { |
80 public: | 87 public: |
81 Builder(int argc, const char** argv); | 88 Builder(int argc, const char** argv); |
| 89 Builder(); |
82 ~Builder(); | 90 ~Builder(); |
83 | 91 |
84 Builder& SetUserAgent(const std::string& user_agent); | 92 Builder& SetUserAgent(const std::string& user_agent); |
85 Builder& EnableDevToolsServer(const net::IPEndPoint& endpoint); | 93 Builder& EnableDevToolsServer(const net::IPEndPoint& endpoint); |
86 Builder& SetMessagePump(base::MessagePump* message_pump); | 94 Builder& SetMessagePump(base::MessagePump* message_pump); |
| 95 Builder& SetProxyServer(const net::HostPortPair& proxy_server); |
87 | 96 |
88 Options Build(); | 97 Options Build(); |
89 | 98 |
90 private: | 99 private: |
91 Options options_; | 100 Options options_; |
92 | 101 |
93 DISALLOW_COPY_AND_ASSIGN(Builder); | 102 DISALLOW_COPY_AND_ASSIGN(Builder); |
94 }; | 103 }; |
95 | 104 |
96 // Main entry point for running the headless browser. This function constructs | 105 // Main entry point for running the headless browser. This function constructs |
97 // the headless browser instance, passing it to the given | 106 // the headless browser instance, passing it to the given |
98 // |on_browser_start_callback| callback. Note that since this function executes | 107 // |on_browser_start_callback| callback. Note that since this function executes |
99 // the main loop, it will only return after HeadlessBrowser::Shutdown() is | 108 // the main loop, it will only return after HeadlessBrowser::Shutdown() is |
100 // called, returning the exit code for the process. | 109 // called, returning the exit code for the process. |
101 int HeadlessBrowserMain( | 110 int HeadlessBrowserMain( |
102 const HeadlessBrowser::Options& options, | 111 const HeadlessBrowser::Options& options, |
103 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); | 112 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); |
104 | 113 |
105 } // namespace headless | 114 } // namespace headless |
106 | 115 |
107 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 116 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
OLD | NEW |