| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 protected: | 56 protected: |
| 57 HeadlessBrowser() {} | 57 HeadlessBrowser() {} |
| 58 virtual ~HeadlessBrowser() {} | 58 virtual ~HeadlessBrowser() {} |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowser); | 61 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowser); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 // Embedding API overrides for the headless browser. | 64 // Embedding API overrides for the headless browser. |
| 65 struct HeadlessBrowser::Options { | 65 struct HeadlessBrowser::Options { |
| 66 Options(const Options& other); | 66 class Builder; |
| 67 |
| 68 Options(Options&& options); |
| 67 ~Options(); | 69 ~Options(); |
| 68 | 70 |
| 69 class Builder; | 71 Options& operator=(Options&& options); |
| 70 | 72 |
| 71 // Command line options to be passed to browser. | 73 // Command line options to be passed to browser. |
| 72 int argc; | 74 int argc; |
| 73 const char** argv; | 75 const char** argv; |
| 74 | 76 |
| 75 std::string user_agent; | 77 std::string user_agent; |
| 76 std::string navigator_platform; | 78 std::string navigator_platform; |
| 77 | 79 |
| 78 // Address at which DevTools should listen for connections. Disabled by | 80 // Address at which DevTools should listen for connections. Disabled by |
| 79 // default. | 81 // default. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 90 // chrome::switches::kHostRules for a description for the format. | 92 // chrome::switches::kHostRules for a description for the format. |
| 91 std::string host_resolver_rules; | 93 std::string host_resolver_rules; |
| 92 | 94 |
| 93 // Run the browser in single process mode instead of using separate renderer | 95 // 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 | 96 // processes as per default. Note that this also disables any sandboxing of |
| 95 // web content, which can be a security risk. | 97 // web content, which can be a security risk. |
| 96 bool single_process_mode; | 98 bool single_process_mode; |
| 97 | 99 |
| 98 private: | 100 private: |
| 99 Options(int argc, const char** argv); | 101 Options(int argc, const char** argv); |
| 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(Options); |
| 100 }; | 104 }; |
| 101 | 105 |
| 102 class HeadlessBrowser::Options::Builder { | 106 class HeadlessBrowser::Options::Builder { |
| 103 public: | 107 public: |
| 104 Builder(int argc, const char** argv); | 108 Builder(int argc, const char** argv); |
| 105 Builder(); | 109 Builder(); |
| 106 ~Builder(); | 110 ~Builder(); |
| 107 | 111 |
| 108 Builder& SetUserAgent(const std::string& user_agent); | 112 Builder& SetUserAgent(const std::string& user_agent); |
| 109 Builder& EnableDevToolsServer(const net::IPEndPoint& endpoint); | 113 Builder& EnableDevToolsServer(const net::IPEndPoint& endpoint); |
| 110 Builder& SetMessagePump(base::MessagePump* message_pump); | 114 Builder& SetMessagePump(base::MessagePump* message_pump); |
| 111 Builder& SetProxyServer(const net::HostPortPair& proxy_server); | 115 Builder& SetProxyServer(const net::HostPortPair& proxy_server); |
| 112 Builder& SetHostResolverRules(const std::string& host_resolver_rules); | 116 Builder& SetHostResolverRules(const std::string& host_resolver_rules); |
| 113 Builder& SetSingleProcessMode(bool single_process_mode); | 117 Builder& SetSingleProcessMode(bool single_process_mode); |
| 114 | 118 |
| 115 Options Build(); | 119 Options Build(); |
| 116 | 120 |
| 117 private: | 121 private: |
| 118 Options options_; | 122 Options options_; |
| 119 | 123 |
| 120 DISALLOW_COPY_AND_ASSIGN(Builder); | 124 DISALLOW_COPY_AND_ASSIGN(Builder); |
| 121 }; | 125 }; |
| 122 | 126 |
| 123 // Main entry point for running the headless browser. This function constructs | 127 // Main entry point for running the headless browser. This function constructs |
| 124 // the headless browser instance, passing it to the given | 128 // the headless browser instance, passing it to the given |
| 125 // |on_browser_start_callback| callback. Note that since this function executes | 129 // |on_browser_start_callback| callback. Note that since this function executes |
| 126 // the main loop, it will only return after HeadlessBrowser::Shutdown() is | 130 // the main loop, it will only return after HeadlessBrowser::Shutdown() is |
| 127 // called, returning the exit code for the process. | 131 // called, returning the exit code for the process. |
| 128 int HeadlessBrowserMain( | 132 int HeadlessBrowserMain( |
| 129 const HeadlessBrowser::Options& options, | 133 HeadlessBrowser::Options options, |
| 130 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); | 134 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); |
| 131 | 135 |
| 132 } // namespace headless | 136 } // namespace headless |
| 133 | 137 |
| 134 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ | 138 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ |
| OLD | NEW |