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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 net::HostPortPair proxy_server; | 80 net::HostPortPair proxy_server; |
81 | 81 |
82 // Optional message pump that overrides the default. Must outlive the browser. | 82 // Optional message pump that overrides the default. Must outlive the browser. |
83 base::MessagePump* message_pump; | 83 base::MessagePump* message_pump; |
84 | 84 |
85 // Run the browser in single process mode instead of using separate renderer | 85 // Run the browser in single process mode instead of using separate renderer |
86 // processes as per default. Note that this also disables any sandboxing of | 86 // processes as per default. Note that this also disables any sandboxing of |
87 // web content, which can be a security risk. | 87 // web content, which can be a security risk. |
88 bool single_process_mode; | 88 bool single_process_mode; |
89 | 89 |
| 90 // Comma-separated list of rules that control how hostnames are mapped. See |
| 91 // chrome::switches::kHostRules for a description for the format. |
| 92 std::string host_resolver_rules; |
| 93 |
90 private: | 94 private: |
91 Options(int argc, const char** argv); | 95 Options(int argc, const char** argv); |
92 }; | 96 }; |
93 | 97 |
94 class HeadlessBrowser::Options::Builder { | 98 class HeadlessBrowser::Options::Builder { |
95 public: | 99 public: |
96 Builder(int argc, const char** argv); | 100 Builder(int argc, const char** argv); |
97 Builder(); | 101 Builder(); |
98 ~Builder(); | 102 ~Builder(); |
99 | 103 |
100 Builder& SetUserAgent(const std::string& user_agent); | 104 Builder& SetUserAgent(const std::string& user_agent); |
101 Builder& EnableDevToolsServer(const net::IPEndPoint& endpoint); | 105 Builder& EnableDevToolsServer(const net::IPEndPoint& endpoint); |
102 Builder& SetMessagePump(base::MessagePump* message_pump); | 106 Builder& SetMessagePump(base::MessagePump* message_pump); |
103 Builder& SetProxyServer(const net::HostPortPair& proxy_server); | 107 Builder& SetProxyServer(const net::HostPortPair& proxy_server); |
104 Builder& SetSingleProcessMode(bool single_process_mode); | 108 Builder& SetSingleProcessMode(bool single_process_mode); |
| 109 Builder& SetHostResolverRules(const std::string& host_resolver_rules); |
105 | 110 |
106 Options Build(); | 111 Options Build(); |
107 | 112 |
108 private: | 113 private: |
109 Options options_; | 114 Options options_; |
110 | 115 |
111 DISALLOW_COPY_AND_ASSIGN(Builder); | 116 DISALLOW_COPY_AND_ASSIGN(Builder); |
112 }; | 117 }; |
113 | 118 |
114 // Main entry point for running the headless browser. This function constructs | 119 // Main entry point for running the headless browser. This function constructs |
115 // the headless browser instance, passing it to the given | 120 // the headless browser instance, passing it to the given |
116 // |on_browser_start_callback| callback. Note that since this function executes | 121 // |on_browser_start_callback| callback. Note that since this function executes |
117 // the main loop, it will only return after HeadlessBrowser::Shutdown() is | 122 // the main loop, it will only return after HeadlessBrowser::Shutdown() is |
118 // called, returning the exit code for the process. | 123 // called, returning the exit code for the process. |
119 int HeadlessBrowserMain( | 124 int HeadlessBrowserMain( |
120 const HeadlessBrowser::Options& options, | 125 const HeadlessBrowser::Options& options, |
121 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); | 126 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); |
122 | 127 |
123 } // namespace headless | 128 } // namespace headless |
124 | 129 |
125 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 130 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
OLD | NEW |