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