Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Unified Diff: headless/public/headless_browser.h

Issue 2762593002: Add --headless flag to Windows (Closed)
Patch Set: added TODO Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/lib/headless_content_main_delegate.cc ('k') | headless/public/headless_browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/headless_browser.h
diff --git a/headless/public/headless_browser.h b/headless/public/headless_browser.h
index 19694ec18af19b40f4e72857a1850a01b0745155..92b2610abd15be9500f13331b24a691e168aba85 100644
--- a/headless/public/headless_browser.h
+++ b/headless/public/headless_browser.h
@@ -22,6 +22,10 @@
#include "net/base/ip_endpoint.h"
#include "ui/gfx/geometry/size.h"
+#if defined(OS_WIN)
+#include "sandbox/win/src/sandbox_types.h"
+#endif
+
namespace base {
class MessagePump;
class SingleThreadTaskRunner;
@@ -95,7 +99,7 @@ class HEADLESS_EXPORT HeadlessBrowser {
};
// Embedding API overrides for the headless browser.
-struct HeadlessBrowser::Options {
+struct HEADLESS_EXPORT HeadlessBrowser::Options {
class Builder;
Options(Options&& options);
@@ -107,6 +111,14 @@ struct HeadlessBrowser::Options {
int argc;
const char** argv;
+#if defined(OS_WIN)
+ // Set hardware instance if available, otherwise it defaults to 0.
+ HINSTANCE instance;
+
+ // Set with sandbox information. This has to be already initialized.
+ sandbox::SandboxInterfaceInfo* sandbox_info;
+#endif
+
// Address at which DevTools should listen for connections. Disabled by
// default. Mutually exclusive with devtools_socket_fd.
net::IPEndPoint devtools_endpoint;
@@ -185,7 +197,7 @@ struct HeadlessBrowser::Options {
DISALLOW_COPY_AND_ASSIGN(Options);
};
-class HeadlessBrowser::Options::Builder {
+class HEADLESS_EXPORT HeadlessBrowser::Options::Builder {
public:
Builder(int argc, const char** argv);
Builder();
@@ -200,6 +212,10 @@ class HeadlessBrowser::Options::Builder {
Builder& SetDisableSandbox(bool disable_sandbox);
Builder& SetGLImplementation(const std::string& gl_implementation);
Builder& AddMojoServiceName(const std::string& mojo_service_name);
+#if defined(OS_WIN)
+ Builder& SetInstance(HINSTANCE instance);
+ Builder& SetSandboxInfo(sandbox::SandboxInterfaceInfo* sandbox_info);
+#endif
// Per-context settings.
@@ -224,6 +240,7 @@ class HeadlessBrowser::Options::Builder {
DISALLOW_COPY_AND_ASSIGN(Builder);
};
+#if !defined(OS_WIN)
// The headless browser may need to create child processes (e.g., a renderer
// which runs web content). This is done by re-executing the parent process as
// a zygote[1] and forking each child process from that zygote.
@@ -243,7 +260,17 @@ class HeadlessBrowser::Options::Builder {
//
// [1]
// https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote.md
-void RunChildProcessIfNeeded(int argc, const char** argv);
+HEADLESS_EXPORT void RunChildProcessIfNeeded(int argc, const char** argv);
+#else
+// In Windows, the headless browser may need to create child processes. This is
+// done by re-executing the parent process which may have been initialized with
+// different libraries (e.g. child_dll). In this case, the embedder has to pass
+// the appropiate HINSTANCE and initalization sandbox_info to properly launch
+// the child process.
+HEADLESS_EXPORT void RunChildProcessIfNeeded(
+ HINSTANCE instance,
+ sandbox::SandboxInterfaceInfo* sandbox_info);
+#endif // !defined(OS_WIN)
// Main entry point for running the headless browser. This function constructs
// the headless browser instance, passing it to the given
@@ -251,7 +278,7 @@ void RunChildProcessIfNeeded(int argc, const char** argv);
// the main loop, it will only return after HeadlessBrowser::Shutdown() is
// called, returning the exit code for the process. It is not possible to
// initialize the browser again after it has been torn down.
-int HeadlessBrowserMain(
+HEADLESS_EXPORT int HeadlessBrowserMain(
HeadlessBrowser::Options options,
const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback);
« no previous file with comments | « headless/lib/headless_content_main_delegate.cc ('k') | headless/public/headless_browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698