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

Unified Diff: headless/app/headless_shell.cc

Issue 2762593002: Add --headless flag to Windows (Closed)
Patch Set: readded headless_lib target Created 3 years, 9 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
Index: headless/app/headless_shell.cc
diff --git a/headless/app/headless_shell.cc b/headless/app/headless_shell.cc
index d6d6adeb758a5ef06ce2821d3973911297b22c74..f36b7a8c3c0404d9c965542124add07cdeb1dfca 100644
--- a/headless/app/headless_shell.cc
+++ b/headless/app/headless_shell.cc
@@ -5,6 +5,7 @@
#include <memory>
#include <sstream>
#include <string>
+#include <utility>
#include "base/base64.h"
#include "base/base_switches.h"
@@ -17,6 +18,7 @@
#include "base/memory/weak_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
+#include "content/public/app/content_main.h"
#include "headless/app/headless_shell.h"
#include "headless/app/headless_shell_switches.h"
#include "headless/public/headless_devtools_target.h"
@@ -26,6 +28,10 @@
#include "net/base/net_errors.h"
#include "ui/gfx/geometry/size.h"
+#if defined(OS_WIN)
+#include "sandbox/win/src/sandbox_types.h"
+#endif
+
namespace headless {
namespace {
// Address where to listen to incoming DevTools connections.
@@ -430,11 +436,20 @@ bool ValidateCommandLine(const base::CommandLine& command_line) {
return true;
}
+#if defined(OS_WIN)
+int HeadlessShellMain(HINSTANCE instance,
+ sandbox::SandboxInterfaceInfo* sandbox_info) {
+ base::CommandLine::Init(0, nullptr);
+ HeadlessBrowser::Options::Builder builder(0, nullptr);
+ builder.SetInstance(instance);
+ builder.SetSandboxInfo(std::move(sandbox_info));
+#else
int HeadlessShellMain(int argc, const char** argv) {
base::CommandLine::Init(argc, argv);
RunChildProcessIfNeeded(argc, argv);
- HeadlessShell shell;
HeadlessBrowser::Options::Builder builder(argc, argv);
+#endif // defined(OS_WIN)
+ HeadlessShell shell;
// Enable devtools if requested.
const base::CommandLine& command_line(
@@ -442,7 +457,7 @@ int HeadlessShellMain(int argc, const char** argv) {
if (!ValidateCommandLine(command_line))
return EXIT_FAILURE;
- if (command_line.HasSwitch(::switches::kEnableCrashReporter))
+ if (command_line.HasSwitch(switches::kEnableCrashReporter))
builder.SetCrashReporterEnabled(true);
if (command_line.HasSwitch(switches::kCrashDumpsDir)) {
builder.SetCrashDumpsDir(
@@ -524,4 +539,12 @@ int HeadlessShellMain(int argc, const char** argv) {
base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell)));
}
+int HeadlessShellMain(const content::ContentMainParams& params) {
+#if defined(OS_WIN)
+ return HeadlessShellMain(params.instance, params.sandbox_info);
+#else
+ return HeadlessShellMain(params.argc, params.argv);
+#endif
+}
+
} // namespace headless

Powered by Google App Engine
This is Rietveld 408576698